From: Peter Zijlstra <peterz@infradead.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
Ben Segall <bsegall@google.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>, Mel Gorman <mgorman@suse.de>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
Valentin Schneider <vschneid@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Will Deacon <will@kernel.org>,
x86@kernel.org
Subject: Re: [RFC PATCH] preempt: Add a generic function to return the preemption string.
Date: Thu, 9 Jan 2025 12:43:39 +0100 [thread overview]
Message-ID: <20250109114339.GB2981@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20241206113431.Q-VXMlru@linutronix.de>
On Fri, Dec 06, 2024 at 12:34:31PM +0100, Sebastian Andrzej Siewior wrote:
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 95e40895a5190..8f5517dbe07d4 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -7642,6 +7642,30 @@ static inline void preempt_dynamic_init(void) { }
>
> #endif /* CONFIG_PREEMPT_DYNAMIC */
>
> +const char *preempt_model_str(void)
> +{
> + if (IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY) && preempt_model_lazy()) {
> + if (preempt_model_rt())
> + return "PREEMPT_RT+LAZY";
> + if (preempt_model_full())
> + return "PREEMPT+LAZY";
> + if (preempt_model_voluntary())
> + return "VOLUNTARY+LAZY";
> + if (preempt_model_none())
> + return "NONE+LAZY";
> + } else {
> + if (preempt_model_rt())
> + return "PREEMPT_RT";
> + if (preempt_model_full())
> + return "PREEMPT";
> + if (preempt_model_voluntary())
> + return "VOLUNTARY";
> + if (preempt_model_none())
> + return "NONE";
> + }
> + return "UNKNOWN-PREEMPT";
> +}
Hurmph.. a bunch of those combinations are nonsense :/
Also, we have a string thing in sched_dynamic_show().
Can't we do something like:
const char *preempt_model_str(void)
{
static char buf[128];
size_t off = 0, len = sizeof(buf), r;
bool brace = IS_ENABLED(CONFIG_PREEMPT_RT) &&
(IS_ENABLED(CONFIG_PREEMPT_DYNAMIC) ||
IS_ENABLED(CONFIG_PREEMPT_LAZY));
if (IS_ENABLED(CONFIG_PREEMPT_BUILD)) {
r = snprintf(buf + off, len, "PREEMPT");
off += r;
len -= r;
if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
r = snprintf(buf + off, len, "%sRT%s",
brace ? "_{" : "_",
brace ? "," : "");
off += r;
len -= r;
}
if (IS_ENABLED(CONFIG_PREEMPT_DYNAMIC)) {
snprintf(buf + off, len, "(%s)%s",
preempt_modes[preempt_dynamic_mode],
brace ? "}" : "");
retun buf;
}
if (IS_ENABLED(CONFIG_PREEMPT_LAZY)) {
snprintf(buf + off, len, "LAZY%s",
brace ? "}" : "");
retun buf;
}
return buf;
}
if (IS_ENABLED(CONFIG_VOLUNTARY_BUILD))
return "VOLUNTARY";
return "NONE";
}
next prev parent reply other threads:[~2025-01-09 11:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-06 11:34 [RFC PATCH] preempt: Add a generic function to return the preemption string Sebastian Andrzej Siewior
2025-01-09 8:55 ` Sebastian Andrzej Siewior
2025-01-09 11:43 ` Peter Zijlstra [this message]
2025-01-09 14:37 ` Steven Rostedt
2025-01-09 14:37 ` Peter Zijlstra
2025-01-09 14:41 ` Sebastian Andrzej Siewior
2025-01-09 14:54 ` Peter Zijlstra
2025-01-09 15:27 ` Sebastian Andrzej Siewior
2025-01-09 17:41 ` Sebastian Andrzej Siewior
2025-01-09 15:53 ` Steven Rostedt
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=20250109114339.GB2981@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bigeasy@linutronix.de \
--cc=bsegall@google.com \
--cc=catalin.marinas@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/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