public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	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>,
	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 15:37:01 +0100	[thread overview]
Message-ID: <20250109143701.GA5388@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20250109093702.5fe3400d@gandalf.local.home>

On Thu, Jan 09, 2025 at 09:37:02AM -0500, Steven Rostedt wrote:
> On Thu, 9 Jan 2025 12:43:39 +0100
> Peter Zijlstra <peterz@infradead.org> wrote:
> 
> > 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;
> > 		}
> 
> I'm sorry, but I can't even tell what the above is doing without my brain
> hurting. Why make code that was easy to read into a cryptic obfuscation? I
> can't see this as an optimization as IS_ENABLED() is determined at compile
> time.

Upgrade brain. Also the proposed thing was just plain wrong.

  reply	other threads:[~2025-01-09 14:37 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
2025-01-09 14:37   ` Steven Rostedt
2025-01-09 14:37     ` Peter Zijlstra [this message]
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=20250109143701.GA5388@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