From: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
dyoung@redhat.com, linux-doc@vger.kernel.org, bhe@redhat.com,
vgoyal@redhat.com, akpm@linux-foundation.org,
andriy.shevchenko@linux.intel.com, corbet@lwn.net,
halves@canonical.com, kernel@gpiccoli.net
Subject: Re: [PATCH V2] notifier/panic: Introduce panic_notifier_filter
Date: Thu, 6 Jan 2022 18:05:09 -0300 [thread overview]
Message-ID: <4e416d20-13f2-25ea-6ff7-b8c0c1818eac@igalia.com> (raw)
In-Reply-To: <YddQOFye7Rhr9NDl@rowland.harvard.edu>
On 06/01/2022 17:25, Alan Stern wrote:
> [...]
>> + if (unlikely(panic_nf_count) && nh == &panic_notifier_list)
>> + if (!is_panic_notifier_filtered(n))
>> + goto panic_filtered_out;
>
> Forget the unlikely(); this is not a hot path.
>
Thanks for the review Alan! Sure, I can remove that in the V3 - good point.
>> +
>> ret = notifier_chain_register(&nh->head, n);
>> +
>> +panic_filtered_out:
>> spin_unlock_irqrestore(&nh->lock, flags);
>> return ret;
>> }
>
> It would be simpler to do:
>
> if (!(nh == &panic_notifier_list && panic_nf_count > 0 &&
> is_panic_notifier_filtered(n)))
> ret = notifier_chain_register(&nh->head, n);
>
> If there were special-purpose functions just for registering and
> unregistering callbacks on the panic_notifier_list, the design would be
> cleaner (no need to modify core notifier code). But making that change
> would mean altering a lot of call sites. :-(
>
Good suggestion, I'll change the code with your suggestion in the V3.
And I agree, I considered something like that when writing this "hijack"
into core code just for the sake of panic notifier filtering...
I'm not sure though it worth the effort and code addition, to change all
the call sites and add a special register mechanism to the panic
notifier only. Let's see what the others think...
Cheers,
Guilherme
>> @@ -162,10 +194,16 @@ int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh,
>> struct notifier_block *n)
>> {
>> unsigned long flags;
>> - int ret;
>> + int ret = 0;
>>
>> spin_lock_irqsave(&nh->lock, flags);
>> + if (unlikely(panic_nf_count) && nh == &panic_notifier_list)
>> + if (!is_panic_notifier_filtered(n))
>> + goto panic_filtered_out;
>> +
>> ret = notifier_chain_unregister(&nh->head, n);
>> +
>> +panic_filtered_out:
>
> Same idea here.
>
> Alan Stern
>
next prev parent reply other threads:[~2022-01-06 21:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-06 20:00 Guilherme G. Piccoli
2022-01-06 20:25 ` Alan Stern
2022-01-06 21:05 ` Guilherme G. Piccoli [this message]
2022-01-07 12:08 ` Andy Shevchenko
2022-01-07 14:39 ` Guilherme G. Piccoli
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=4e416d20-13f2-25ea-6ff7-b8c0c1818eac@igalia.com \
--to=gpiccoli@igalia.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhe@redhat.com \
--cc=corbet@lwn.net \
--cc=dyoung@redhat.com \
--cc=halves@canonical.com \
--cc=kernel@gpiccoli.net \
--cc=kexec@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=vgoyal@redhat.com \
/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
all inboxes | Powered by JetHome®