Re: [PATCH V2 9/9] jump_label: Batch up if arch supports it

From: Steven Rostedt
Date: Tue Dec 18 2018 - 15:32:14 EST


On Tue, 18 Dec 2018 20:33:48 +0100
Daniel Bristot de Oliveira <bristot@xxxxxxxxxx> wrote:

> >> +#else
> >> +static void __jump_label_update(struct static_key *key,
> >> + struct jump_entry *entry,
> >> + struct jump_entry *stop,
> >> + bool init)
> >> +{
> >> + for_each_label_entry(key, entry, stop) {
> >> +
> >> + if (!jump_label_can_update_check(entry, init))
> >> + continue;
> >> +
> >> + if (arch_jump_label_transform_queue(entry,
> >> + jump_label_type(entry)))
> >> + continue;
> >> +
> >> + /*
> >> + * Queue's overflow: Apply the current queue, and then
> >> + * queue again. If it stills not possible to queue, BUG!
> >> + */
> >> + arch_jump_label_transform_apply();
> >> + if (!arch_jump_label_transform_queue(entry,
> >> + jump_label_type(entry))) {
> >> + BUG();
> >
> > Why BUG()? Do you really want to crash Linus's machine?
>
> I am using BUG() because that is what I see in other part of jump_label code:
> If something goes wrong:
> BUG().

Where? Mostly we have BUILD_BUG_ON() which isn't bad at all.

The only other BUG I see in the jump label code is in the arch specific
code and that's from 2012. Lately, we are trying to get rid of BUG()
and panic() entirely, with a few exceptions (where there's really no
way to return. Like when the function graph stack is corrupted, and we
don't know where to go).

If there's a way to continue in a critical state, it's best to WARN()
and continue on. That way, the user can have a chance to see what
happened.

>
> What I could do here is:
>
> Add a "fallback" boll that is disabled by default.
> If I hit this case:
> WARN()
> turn "fallback" on, returning to the old mode (without batch)
>
> Sound better?

Yes, please do.

Thanks!

-- Steve