public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Domenico Cerasuolo <cerasuolodomenico@gmail.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
	surenb@google.com, brauner@kernel.org, chris@chrisdown.name
Subject: Re: [PATCH v5 4/4] sched/psi: allow unprivileged polling of N*2s period
Date: Thu, 30 Mar 2023 05:46:09 -0400	[thread overview]
Message-ID: <ZCVaYYmPZsFmc+/1@cmpxchg.org> (raw)
In-Reply-To: <20230330081100.11871-5-cerasuolodomenico@gmail.com>

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()
		...
	}

      reply	other threads:[~2023-03-30  9:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30  8:10 [PATCH v5 0/4] sched/psi: Allow unprivileged PSI polling Domenico Cerasuolo
2023-03-30  8:10 ` [PATCH v5 1/4] sched/psi: rearrange polling code in preparation Domenico Cerasuolo
2023-03-30  8:10 ` [PATCH v5 2/4] sched/psi: rename existing poll members " Domenico Cerasuolo
2023-03-30  8:10 ` [PATCH v5 3/4] sched/psi: extract update_triggers side effect Domenico Cerasuolo
2023-03-30  8:11 ` [PATCH v5 4/4] sched/psi: allow unprivileged polling of N*2s period Domenico Cerasuolo
2023-03-30  9:46   ` Johannes Weiner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZCVaYYmPZsFmc+/1@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=brauner@kernel.org \
    --cc=cerasuolodomenico@gmail.com \
    --cc=chris@chrisdown.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=surenb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox