[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <025ea126-f6db-4988-b500-5fbee0a65a3e@efficios.com>
Date: Mon, 2 Sep 2024 14:14:26 -0400
From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
Kees Cook <keescook@...omium.org>, Greg KH <gregkh@...uxfoundation.org>,
Sean Christopherson <seanjc@...gle.com>, Steven Rostedt
<rostedt@...dmis.org>, Masami Hiramatsu <mhiramat@...nel.org>,
Alexei Starovoitov <ast@...nel.org>, Yonghong Song <yhs@...com>,
"Paul E . McKenney" <paulmck@...nel.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>, bpf@...r.kernel.org,
Joel Fernandes <joel@...lfernandes.org>, linux-trace-kernel@...r.kernel.org,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH v1 2/2] cleanup.h: Introduce DEFINE_INACTIVE_GUARD and
activate_guard
On 2024-09-02 14:10, Linus Torvalds wrote:
> On Mon, 2 Sept 2024 at 08:43, Peter Zijlstra <peterz@...radead.org> wrote:
>>
>> and Linus took objection to similar patterns. But perhaps my naming
>> wasn't right.
>
> Well, more of a "this stuff is new, let's start very limited and very clear".
>
> I'm not loving the inactive guard, but I did try to think of a better
> model for it, and I can't. I absolutely hate the *example*, though:
>
> void func(bool a)
> {
> DEFINE_INACTIVE_GUARD(preempt_notrace, myguard);
>
> [...]
> if (a) {
> might_sleep();
> activate_guard(preempt_notrace, myguard)();
> }
> [ protected code ]
Fair. I should have written something more like
[ conditionally protected code ]
> }
>
> because that "protected code" obviously is *NOT* protected code. It's
> conditionally protected only in one situation.
>
> Honestly, I still think the guard macros are new enough that we should
> strive to avoid them in complicated cases like this. And this *is*
> complicated. It *looks* simple, but when even the example that was
> given was pure and utter garbage, it's clearly not *actually* simple.
>
> Once some code is sometimes protected, and sometimes isn't, and you
> have magic compiler stuff that *hides* it, I'm not sure we should use
> the magic compiler stuff.
I've tried my best to come up with a scheme which would be cleaner
than the "guard_if()" proposed by Peter, because I really hate it.
I'm perfectly fine going back to goto/labels for that function if we
cannot agree on a clean way to express what is needed there.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
Powered by blists - more mailing lists