[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZCVaYYmPZsFmc+/1@cmpxchg.org>
Date: Thu, 30 Mar 2023 05:46:09 -0400
From: Johannes Weiner <hannes@...xchg.org>
To: Domenico Cerasuolo <cerasuolodomenico@...il.com>
Cc: linux-kernel@...r.kernel.org, peterz@...radead.org,
surenb@...gle.com, brauner@...nel.org, chris@...isdown.name
Subject: Re: [PATCH v5 4/4] sched/psi: allow unprivileged polling of N*2s
period
Hi Domenico,
thanks, the destruction path looks right to me now.
On Thu, Mar 30, 2023 at 10:11:00AM +0200, Domenico Cerasuolo wrote:
> @@ -1319,11 +1353,16 @@ struct psi_trigger *psi_trigger_create(struct psi_group *group,
> rcu_assign_pointer(group->rtpoll_task, task);
> }
>
> - list_add(&t->node, &group->rtpoll_triggers);
> - group->rtpoll_min_period = min(group->rtpoll_min_period,
> - div_u64(t->win.size, UPDATES_PER_WINDOW));
> - group->rtpoll_nr_triggers[t->state]++;
> - group->rtpoll_states |= (1 << t->state);
> + if (privileged) {
> + list_add(&t->node, &group->rtpoll_triggers);
> + group->rtpoll_min_period = min(group->rtpoll_min_period,
> + div_u64(t->win.size, UPDATES_PER_WINDOW));
> + group->rtpoll_nr_triggers[t->state]++;
> + group->rtpoll_states |= (1 << t->state);
> + } else {
> + list_add(&t->node, &group->avg_triggers);
> + group->avg_nr_triggers[t->state]++;
> + }
>
> mutex_unlock(&group->rtpoll_trigger_lock);
But creation needs the same treatment. group->avg_triggers and
avg_nr_triggers are protected by the avgs_lock, not the
rtpoll_trigger_lock.
I suppose the lock taking and the group->rtpoll_task creation
(anything with rtpoll in the name, really) should be within a big
if (privileged) {
rtpoll_trigger_lock()
kthread_create()
init-and-link()
rtpoll_trigger_unlock()
} else {
avgs_lock()
...
}
Powered by blists - more mailing lists