Suggested-by: Petr Mladek <[email protected]>
Signed-off-by: Stephen Brennan <[email protected]>
---
We cannot define a static inline without including linux/atomic.h, so
I just added a macro for convenience in later patches. Since macros were
the only option, I didn't include a helper for
panic_in_progress_different_cpu().
include/linux/panic.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/panic.h b/include/linux/panic.h
index f5844908a089..8e8bd50494d5 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -45,6 +45,9 @@ extern bool crash_kexec_post_notifiers;
extern atomic_t panic_cpu;
#define PANIC_CPU_INVALID -1
+#define panic_in_progress() \
+ unlikely(atomic_read(&panic_cpu) != PANIC_CPU_INVALID)
+
/*
* Only to be used by arch init code. If the user over-wrote the default
* CONFIG_PANIC_TIMEOUT, honor it.
--
2.30.2
On Fri 2022-01-21 11:02:19, Stephen Brennan wrote:
Please, add explanation why the new helper is added. It will be
used in printk code to reduce risk of deadlocks during panic().
> Suggested-by: Petr Mladek <[email protected]>
> Signed-off-by: Stephen Brennan <[email protected]>
> ---
> We cannot define a static inline without including linux/atomic.h, so
> I just added a macro for convenience in later patches. Since macros were
> the only option, I didn't include a helper for
> panic_in_progress_different_cpu().
What is the exact problem with including atomic.h and using static
inline, please?
IMHO, the define is not a real solution. The macro won't be usable
without including atomic.h. So, it would work only by chance.
But it is possible that I miss something.
Best Regards,
Petr
Petr Mladek <[email protected]> writes:
> On Fri 2022-01-21 11:02:19, Stephen Brennan wrote:
>
> Please, add explanation why the new helper is added. It will be
> used in printk code to reduce risk of deadlocks during panic().
>
>> Suggested-by: Petr Mladek <[email protected]>
>> Signed-off-by: Stephen Brennan <[email protected]>
>> ---
>> We cannot define a static inline without including linux/atomic.h, so
>> I just added a macro for convenience in later patches. Since macros were
>> the only option, I didn't include a helper for
>> panic_in_progress_different_cpu().
>
> What is the exact problem with including atomic.h and using static
> inline, please?
Hi Petr,
linux/panic.h is a commonly included header, and so I didn't want to
pollute the namespaces of many other compilation units. (In fact, for
stable kernels we avoid changing headers to avoid changing the hashes
produced by genksyms). It could impact compile time too.
But I suppose I was prematurely optimizing. I can make them proper
static inlines instead :)
Stephen
>
> IMHO, the define is not a real solution. The macro won't be usable
> without including atomic.h. So, it would work only by chance.
>
> But it is possible that I miss something.
>
> Best Regards,
> Petr