On 2024-09-02 14:10, Linus Torvalds wrote:
On Mon, 2 Sept 2024 at 08:43, Peter Zijlstra <peterz@xxxxxxxxxxxxx> 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