mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qais Yousef <qyousef@layalina.io>
To: John Stultz <jstultz@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Joel Fernandes <joelaf@google.com>,
	Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Valentin Schneider <vschneid@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>,
	Zimuzo Ezeozue <zezeozue@google.com>,
	Youssef Esmat <youssefesmat@google.com>,
	Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Will Deacon <will@kernel.org>, Waiman Long <longman@redhat.com>,
	Boqun Feng <boqun.feng@gmail.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Xuewen Yan <xuewen.yan94@gmail.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	Metin Kaya <Metin.Kaya@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	kernel-team@android.com, Connor O'Brien <connoro@google.com>
Subject: Re: [PATCH v10 7/7] sched: Split scheduler and execution contexts
Date: Tue, 4 Jun 2024 15:11:03 +0100	[thread overview]
Message-ID: <20240604141103.idwodwyeecml4keh@airbuntu> (raw)
In-Reply-To: <20240507045450.895430-8-jstultz@google.com>

On 05/06/24 21:54, John Stultz wrote:
> From: Peter Zijlstra <peterz@infradead.org>
> 
> Let's define the scheduling context as all the scheduler state
> in task_struct for the task selected to run, and the execution
> context as all state required to actually run the task.
> 
> Currently both are intertwined in task_struct. We want to
> logically split these such that we can use the scheduling
> context of the task selected to be scheduled, but use the
> execution context of a different task to actually be run.
> 
> To this purpose, introduce rq_selected() macro to point to the
> task_struct selected from the runqueue by the scheduler, and
> will be used for scheduler state, and preserve rq->curr to
> indicate the execution context of the task that will actually be
> run.

This is subjective opinion of course. But I am not a fan of rq_selected().
I think we are better with more explicit

	rq->currs	/* current sched context */
	rq->currx	/* current execution context */

and the helpers

	task_curr_sctx()
	task_curr_xctx()

This will ensure all current users of rq->curr will generate a build error and
be better audited what they are supposed to be. And I think the code is more
readable this way.

Another way to do it is to split task_struct to sched and exec context (rather
than control the reference to curr as done here). Then curr would be always the
same, but reference to its sched context would change with inheritance.

ie:

	struct task_sctx {
		...
	};

	struct task_struct {
		struct task_sctx *sctx;
		/* exec context is embedded as-is */
		...
	};

Which means would just have to update all accessors to sched context to do
extra dereference. Which I am not sure if a problematic extra level of
indirection.

I see the latter approach  more intuitive and explicit about what is a sched
context that is supposed to be inherited and what is not.

I generally think breaking down task structure would be good. Hopefully the new
data perf can help us make better decision on what attributes to group
together. And generally this might be a good exercise to rethink its content
which grown organicaly over the year. Maybe we want to create similar such
smaller wrapper structs for other fields too.

I **think** with this approach we would just need go fix compilation errors to
do p->sctx->{attribute}.

Proxy exec later would only update the reference to this struct to enforce
inheritance for rq->curr->sctx to point to the donor's context.

  reply	other threads:[~2024-06-04 14:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-07  4:54 [PATCH v10 0/7] Preparatory changes for Proxy Execution v10 John Stultz
2024-05-07  4:54 ` [PATCH v10 1/7] locking/mutex: Remove wakeups from under mutex::wait_lock John Stultz
2024-05-07  4:54 ` [PATCH v10 2/7] locking/mutex: Make mutex::wait_lock irq safe John Stultz
2024-06-04 13:33   ` Qais Yousef
2024-05-07  4:54 ` [PATCH v10 3/7] locking/mutex: Expose __mutex_owner() John Stultz
2024-05-07  4:54 ` [PATCH v10 4/7] sched: Add move_queued_task_locked helper John Stultz
2024-06-04 13:12   ` Qais Yousef
2024-06-04 15:53     ` John Stultz
2024-05-07  4:54 ` [PATCH v10 5/7] sched: Consolidate pick_*_task to task_is_pushable helper John Stultz
2024-06-04 13:18   ` Qais Yousef
2024-06-04 13:53     ` Metin Kaya
2024-05-07  4:54 ` [PATCH v10 6/7] sched: Split out __schedule() deactivate task logic into a helper John Stultz
2024-06-04 13:29   ` Qais Yousef
2024-06-04 13:55     ` Metin Kaya
2024-06-04 19:34     ` John Stultz
2024-05-07  4:54 ` [PATCH v10 7/7] sched: Split scheduler and execution contexts John Stultz
2024-06-04 14:11   ` Qais Yousef [this message]
2024-06-04 19:33     ` John Stultz
2024-06-10 19:51       ` Qais Yousef

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=20240604141103.idwodwyeecml4keh@airbuntu \
    --to=qyousef@layalina.io \
    --cc=Metin.Kaya@arm.com \
    --cc=boqun.feng@gmail.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=connoro@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=joelaf@google.com \
    --cc=jstultz@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=kernel-team@android.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=will@kernel.org \
    --cc=xuewen.yan94@gmail.com \
    --cc=youssefesmat@google.com \
    --cc=zezeozue@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

all inboxes | Powered by JetHome®