Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f93bebd authored by Srivatsa Vaddagiri's avatar Srivatsa Vaddagiri Committed by Syed Rameez Mustafa
Browse files

sched: window-stats: use policy_mutex in sched_set_window()



Several configuration variable change will result in
reset_all_window_stats() being called. All of them, except
sched_set_window(), are serialized via policy_mutex. Take
policy_mutex in sched_set_window() as well to serialize use of
reset_all_window_stats() function

Change-Id: Iada7ff8ac85caa1517e2adcf6394c5b050e3968a
Signed-off-by: default avatarSrivatsa Vaddagiri <vatsa@codeaurora.org>
parent e4ff6c07
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -1812,30 +1812,28 @@ void sched_set_io_is_busy(int val)
int sched_set_window(u64 window_start, unsigned int window_size)
{
	u64 ws, now;
	int delta;

	if (sched_use_pelt ||
		 (window_size * TICK_NSEC <  MIN_SCHED_RAVG_WINDOW))
			return -EINVAL;

	mutex_lock(&policy_mutex);
	update_alignment = 1;

	now = get_jiffies_64();
	if (time_after64(window_start, now)) {
		delta = window_start - now; /* how many jiffies ahead */
		delta /= window_size; /* # of windows to roll back */
		delta += 1;
		window_start -= (delta * window_size);
	}

	ws = (window_start - sched_init_jiffy); /* jiffy difference */
	ws *= TICK_NSEC;
	ws += sched_clock_at_init_jiffy;

	now = sched_clock();
	while (ws > now)
		ws -= (window_size * TICK_NSEC);

	BUG_ON(sched_clock() < ws);

	reset_all_window_stats(ws, window_size);

	mutex_unlock(&policy_mutex);

	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -1886,7 +1886,7 @@ void post_big_small_task_count_change(void)
	local_irq_enable();
}

static DEFINE_MUTEX(policy_mutex);
DEFINE_MUTEX(policy_mutex);

static inline int invalid_value(unsigned int *data)
{
+1 −0
Original line number Diff line number Diff line
@@ -687,6 +687,7 @@ extern void init_new_task_load(struct task_struct *p);
#define WINDOW_STATS_USE_AVG		2
#define WINDOW_STATS_INVALID_POLICY	3

extern struct mutex policy_mutex;
extern unsigned int sched_ravg_window;
extern unsigned int sched_use_pelt;
extern unsigned int sched_disable_window_stats;