Message ID | 20221021052238.580986-3-bgray@linux.ibm.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Use per-CPU temporary mappings for patching | expand |
On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > From: "Christopher M. Riedl" <cmr@bluescreens.de> > > The latest kernel docs list BUG_ON() as 'deprecated' and that they > should be replaced with WARN_ON() (or pr_warn()) when possible. The > BUG_ON() in poking_init() warrants a WARN_ON() rather than a > pr_warn() > since the error condition is deemed "unreachable". > > Also take this opportunity to fix the failure check in the WARN_ON(): > cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, ...) returns a positive > integer > on success and a negative integer on failure. > > Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> Reviewed-by: Russell Currey <ruscur@russell.cc>
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index ad0cf3108dd0..34fc7ac34d91 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c @@ -81,16 +81,13 @@ static int text_area_cpu_down(unsigned int cpu) static __ro_after_init DEFINE_STATIC_KEY_FALSE(poking_init_done); -/* - * Although BUG_ON() is rude, in this case it should only happen if ENOMEM, and - * we judge it as being preferable to a kernel that will crash later when - * someone tries to use patch_instruction(). - */ void __init poking_init(void) { - BUG_ON(!cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, - "powerpc/text_poke:online", text_area_cpu_up, - text_area_cpu_down)); + WARN_ON(cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, + "powerpc/text_poke:online", + text_area_cpu_up, + text_area_cpu_down) < 0); + static_branch_enable(&poking_init_done); }