Unverified Commit efc3f2d3 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files
parents cbb27a20 1cb95063
Loading
Loading
Loading
Loading
+12 −8
Original line number Original line Diff line number Diff line
@@ -439,7 +439,6 @@ static void stress_inorder_work(struct work_struct *work)
	} while (!time_after(jiffies, stress->timeout));
	} while (!time_after(jiffies, stress->timeout));


	kfree(order);
	kfree(order);
	kfree(stress);
}
}


struct reorder_lock {
struct reorder_lock {
@@ -504,7 +503,6 @@ static void stress_reorder_work(struct work_struct *work)
	list_for_each_entry_safe(ll, ln, &locks, link)
	list_for_each_entry_safe(ll, ln, &locks, link)
		kfree(ll);
		kfree(ll);
	kfree(order);
	kfree(order);
	kfree(stress);
}
}


static void stress_one_work(struct work_struct *work)
static void stress_one_work(struct work_struct *work)
@@ -525,8 +523,6 @@ static void stress_one_work(struct work_struct *work)
			break;
			break;
		}
		}
	} while (!time_after(jiffies, stress->timeout));
	} while (!time_after(jiffies, stress->timeout));

	kfree(stress);
}
}


#define STRESS_INORDER BIT(0)
#define STRESS_INORDER BIT(0)
@@ -537,15 +533,24 @@ static void stress_one_work(struct work_struct *work)
static int stress(int nlocks, int nthreads, unsigned int flags)
static int stress(int nlocks, int nthreads, unsigned int flags)
{
{
	struct ww_mutex *locks;
	struct ww_mutex *locks;
	int n;
	struct stress *stress_array;
	int n, count;


	locks = kmalloc_array(nlocks, sizeof(*locks), GFP_KERNEL);
	locks = kmalloc_array(nlocks, sizeof(*locks), GFP_KERNEL);
	if (!locks)
	if (!locks)
		return -ENOMEM;
		return -ENOMEM;


	stress_array = kmalloc_array(nthreads, sizeof(*stress_array),
				     GFP_KERNEL);
	if (!stress_array) {
		kfree(locks);
		return -ENOMEM;
	}

	for (n = 0; n < nlocks; n++)
	for (n = 0; n < nlocks; n++)
		ww_mutex_init(&locks[n], &ww_class);
		ww_mutex_init(&locks[n], &ww_class);


	count = 0;
	for (n = 0; nthreads; n++) {
	for (n = 0; nthreads; n++) {
		struct stress *stress;
		struct stress *stress;
		void (*fn)(struct work_struct *work);
		void (*fn)(struct work_struct *work);
@@ -569,9 +574,7 @@ static int stress(int nlocks, int nthreads, unsigned int flags)
		if (!fn)
		if (!fn)
			continue;
			continue;


		stress = kmalloc(sizeof(*stress), GFP_KERNEL);
		stress = &stress_array[count++];
		if (!stress)
			break;


		INIT_WORK(&stress->work, fn);
		INIT_WORK(&stress->work, fn);
		stress->locks = locks;
		stress->locks = locks;
@@ -586,6 +589,7 @@ static int stress(int nlocks, int nthreads, unsigned int flags)


	for (n = 0; n < nlocks; n++)
	for (n = 0; n < nlocks; n++)
		ww_mutex_destroy(&locks[n]);
		ww_mutex_destroy(&locks[n]);
	kfree(stress_array);
	kfree(locks);
	kfree(locks);


	return 0;
	return 0;