linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>
Cc: David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] sched_ext: Track currently locked rq
Date: Tue, 22 Apr 2025 08:27:09 +0200	[thread overview]
Message-ID: <aAc2vdLzhR2BgL_q@gpd3> (raw)
In-Reply-To: <aAaWbDu-WKEhQYq_@slm.duckdns.org>

On Mon, Apr 21, 2025 at 09:03:08AM -1000, Tejun Heo wrote:
> Hello,
> 
> On Sun, Apr 20, 2025 at 09:30:21PM +0200, Andrea Righi wrote:
> ...
> > +static inline struct rq *scx_locked_rq(void)
> > +{
> > +	return __this_cpu_read(locked_rq);
> > +}
> > +
> > +#define SCX_CALL_OP(mask, rq, op, args...)					\
> >  do {										\
> > +	update_locked_rq(rq);							\
> 
> Minor but why not
> 
>         if (rq)
>                 update_locked_rq(rq);
> 
> here too to be symmetric?
> 
> >  	if (mask) {								\
> >  		scx_kf_allow(mask);						\
> >  		scx_ops.op(args);						\
> > @@ -1125,11 +1155,15 @@ do {										\
> >  	} else {								\
> >  		scx_ops.op(args);						\
> >  	}									\
> > +	if (rq)									\
> > +		update_locked_rq(NULL);						\
> 
> Or alternatively, drop `if (rq)` from both places. That's simpler and given
> that all the hot paths are called with rq locked, that may be *minutely*
> faster.

Ack, let's not complicate the code unnecessarily, that's a negligible
optimization (I tried to remove that `if (rq)` and I don't see any
measurable difference, as expected).

> 
> > @@ -2174,7 +2210,7 @@ static void do_enqueue_task(struct rq *rq, struct task_struct *p, u64 enq_flags,
> >  	WARN_ON_ONCE(*ddsp_taskp);
> >  	*ddsp_taskp = p;
> >  
> > -	SCX_CALL_OP_TASK(SCX_KF_ENQUEUE, enqueue, p, enq_flags);
> > +	SCX_CALL_OP_TASK(SCX_KF_ENQUEUE, rq, enqueue, p, enq_flags);
> 
> Let's do SCX_CALL_OP_TASK(SCX_FK_ENQUEUE, enqueue, rq, p, enq_flags) so that
> the static parts of the invocation are grouped together and we usually have
> @rq and @p next to each other when they're used as parameters.

Ack. Will change this as well and send a v3.

Thanks,
-Andrea

  reply	other threads:[~2025-04-22  6:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-20 19:30 [PATCH v2 0/2] sched_ext: Introduce rq lock tracking Andrea Righi
2025-04-20 19:30 ` [PATCH 1/2] sched_ext: Track currently locked rq Andrea Righi
2025-04-21 19:03   ` Tejun Heo
2025-04-22  6:27     ` Andrea Righi [this message]
2025-04-20 19:30 ` [PATCH 2/2] sched_ext: Fix missing rq lock in scx_bpf_cpuperf_set() Andrea Righi
2025-04-21  7:44   ` Changwoo Min
2025-04-21  8:35     ` Andrea Righi
2025-04-21 19:04     ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2025-04-22  8:26 [PATCH v3 0/2] sched_ext: Introduce rq lock tracking Andrea Righi
2025-04-22  8:26 ` [PATCH 1/2] sched_ext: Track currently locked rq Andrea Righi
2025-07-15  9:13   ` Breno Leitao
2025-07-15 17:20     ` Andrea Righi
2025-07-16 10:47       ` Breno Leitao
2025-07-16 12:40         ` Andrea Righi
2025-07-16 12:43           ` Breno Leitao
2025-04-19 12:24 [PATCH 0/2] sched_ext: Introduce rq lock tracking Andrea Righi
2025-04-19 12:24 ` [PATCH 1/2] sched_ext: Track currently locked rq Andrea Righi
2025-04-19 17:34   ` Tejun Heo
2025-04-19 20:10     ` Andrea Righi
2025-04-19 20:30       ` Andrea Righi
2025-04-19 21:27         ` Andrea Righi
2025-04-20 17:44         ` Tejun Heo
2025-04-20 18:34           ` Andrea Righi

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=aAc2vdLzhR2BgL_q@gpd3 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=void@manifault.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;
as well as URLs for NNTP newsgroup(s).