From: Christian Loehle <christian.loehle@arm.com>
To: John Stultz <jstultz@google.com>, LKML <linux-kernel@vger.kernel.org>
Cc: Connor O'Brien <connoro@google.com>,
Joel Fernandes <joelaf@google.com>,
Qais Yousef <qyousef@layalina.io>, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
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>,
Mel Gorman <mgorman@suse.de>, Will Deacon <will@kernel.org>,
Waiman Long <longman@redhat.com>,
Boqun Feng <boqun.feng@gmail.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
Metin Kaya <Metin.Kaya@arm.com>,
Xuewen Yan <xuewen.yan94@gmail.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Thomas Gleixner <tglx@linutronix.de>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
kernel-team@android.com
Subject: Re: [RESEND x2][PATCH v12 5/7] sched: Consolidate pick_*_task to task_is_pushable helper
Date: Thu, 12 Sep 2024 18:29:46 +0100 [thread overview]
Message-ID: <a608c2df-ce2b-45d8-94f5-16c830104d46@arm.com> (raw)
In-Reply-To: <20240910221235.2132138-6-jstultz@google.com>
On 9/10/24 23:12, John Stultz wrote:
> From: Connor O'Brien <connoro@google.com>
>
> This patch consolidates rt and deadline pick_*_task functions to
> a task_is_pushable() helper
>
> This patch was broken out from a larger chain migration
> patch originally by Connor O'Brien.
>
> Cc: Joel Fernandes <joelaf@google.com>
> Cc: Qais Yousef <qyousef@layalina.io>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Juri Lelli <juri.lelli@redhat.com>
> Cc: Vincent Guittot <vincent.guittot@linaro.org>
> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
> Cc: Valentin Schneider <vschneid@redhat.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ben Segall <bsegall@google.com>
> Cc: Zimuzo Ezeozue <zezeozue@google.com>
> Cc: Mel Gorman <mgorman@suse.de>
> Cc: Will Deacon <will@kernel.org>
> Cc: Waiman Long <longman@redhat.com>
> Cc: Boqun Feng <boqun.feng@gmail.com>
> Cc: "Paul E. McKenney" <paulmck@kernel.org>
> Cc: Metin Kaya <Metin.Kaya@arm.com>
> Cc: Xuewen Yan <xuewen.yan94@gmail.com>
> Cc: K Prateek Nayak <kprateek.nayak@amd.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: kernel-team@android.com
> Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
> Tested-by: Metin Kaya <metin.kaya@arm.com>
> Reviewed-by: Metin Kaya <metin.kaya@arm.com>
> Reviewed-by: Valentin Schneider <vschneid@redhat.com>
> Signed-off-by: Connor O'Brien <connoro@google.com>
> [jstultz: split out from larger chain migration patch,
> renamed helper function]
> Signed-off-by: John Stultz <jstultz@google.com>
> ---
> v7:
> * Split from chain migration patch
> * Renamed function
> v11:
> * Switched to bool (though later in the series it goes
> to a tri-state return) for now to simplify review.
> Will add tri-state handling later in the series when
> its needed. Suggested by Metin and others.
> ---
> kernel/sched/deadline.c | 10 +---------
> kernel/sched/rt.c | 11 +----------
> kernel/sched/sched.h | 10 ++++++++++
> 3 files changed, 12 insertions(+), 19 deletions(-)
>
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index ac60d2819bd1d..d3050f6c2958d 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -2183,14 +2183,6 @@ static void task_fork_dl(struct task_struct *p)
> /* Only try algorithms three times */
> #define DL_MAX_TRIES 3
>
> -static int pick_dl_task(struct rq *rq, struct task_struct *p, int cpu)
> -{
> - if (!task_on_cpu(rq, p) &&
> - cpumask_test_cpu(cpu, &p->cpus_mask))
> - return 1;
> - return 0;
> -}
> -
> /*
> * Return the earliest pushable rq's task, which is suitable to be executed
> * on the CPU, NULL otherwise:
> @@ -2209,7 +2201,7 @@ static struct task_struct *pick_earliest_pushable_dl_task(struct rq *rq, int cpu
> if (next_node) {
> p = __node_2_pdl(next_node);
>
> - if (pick_dl_task(rq, p, cpu))
> + if (task_is_pushable(rq, p, cpu))
> return p;
>
> next_node = rb_next(next_node);
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 496d3e6ab57d2..9f07f09641f7a 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -1790,15 +1790,6 @@ static void put_prev_task_rt(struct rq *rq, struct task_struct *p)
> /* Only try algorithms three times */
> #define RT_MAX_TRIES 3
>
> -static int pick_rt_task(struct rq *rq, struct task_struct *p, int cpu)
> -{
> - if (!task_on_cpu(rq, p) &&
> - cpumask_test_cpu(cpu, &p->cpus_mask))
> - return 1;
> -
> - return 0;
> -}
> -
> /*
> * Return the highest pushable rq's task, which is suitable to be executed
> * on the CPU, NULL otherwise
> @@ -1812,7 +1803,7 @@ static struct task_struct *pick_highest_pushable_task(struct rq *rq, int cpu)
> return NULL;
>
> plist_for_each_entry(p, head, pushable_tasks) {
> - if (pick_rt_task(rq, p, cpu))
> + if (task_is_pushable(rq, p, cpu))
> return p;
> }
>
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index d2cc31c2457e5..10ef612c078f9 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -3586,6 +3586,16 @@ void move_queued_task_locked(struct rq *src_rq, struct rq *dst_rq, struct task_s
> set_task_cpu(task, dst_rq->cpu);
> activate_task(dst_rq, task, 0);
> }
> +
> +static inline
> +bool task_is_pushable(struct rq *rq, struct task_struct *p, int cpu)
> +{
> + if (!task_on_cpu(rq, p) &&
> + cpumask_test_cpu(cpu, &p->cpus_mask))
> + return true;
> +
> + return false;
> +}
The slightly awkward
if (condition)
return true;
return false;
is more convenient for you for the tri-state later, I assume.
Fine by me FWIW.
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
next prev parent reply other threads:[~2024-09-12 17:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 22:12 [RESEND x2][PATCH v12 0/7] Preparatory changes for Proxy Execution v12 John Stultz
2024-09-10 22:12 ` [RESEND x2][PATCH v12 1/7] locking/mutex: Remove wakeups from under mutex::wait_lock John Stultz
2024-09-10 22:12 ` [RESEND x2][PATCH v12 2/7] locking/mutex: Make mutex::wait_lock irq safe John Stultz
2024-09-10 22:12 ` [RESEND x2][PATCH v12 3/7] locking/mutex: Expose __mutex_owner() John Stultz
2024-09-10 22:12 ` [RESEND x2][PATCH v12 4/7] sched: Add move_queued_task_locked helper John Stultz
2024-09-10 22:12 ` [RESEND x2][PATCH v12 5/7] sched: Consolidate pick_*_task to task_is_pushable helper John Stultz
2024-09-12 17:29 ` Christian Loehle [this message]
2024-09-14 0:37 ` John Stultz
2024-09-10 22:12 ` [RESEND x2][PATCH v12 6/7] sched: Split out __schedule() deactivate task logic into a helper John Stultz
2024-09-10 22:12 ` [RESEND x2][PATCH v12 7/7] sched: Split scheduler and execution contexts John Stultz
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=a608c2df-ce2b-45d8-94f5-16c830104d46@arm.com \
--to=christian.loehle@arm.com \
--cc=Metin.Kaya@arm.com \
--cc=boqun.feng@gmail.com \
--cc=bsegall@google.com \
--cc=connoro@google.com \
--cc=daniel.lezcano@linaro.org \
--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=qyousef@layalina.io \
--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=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®