On Fri, 17 Apr 2020 10:57:10 +1000 Michael Ellerman <m...@ellerman.id.au> wrote:
> >>> Does it needs to be a BUG_ON() ? Can't we fail gracefully with just a > >>> WARN_ON ? > >>> > >> > >> I'm not sure what failing gracefully means here? The main reason this could > >> fail is if there is not enough memory to allocate the patching_mm. The > >> previous implementation had this justification for BUG_ON(): > > > > But the system can continue running just fine after this failure. > > Only the things that make use of code patching will fail (ftrace, kgdb, > > ...) > > That's probably true of ftrace, but we can't fail patching for jump > labels (static keys). > > See: > > void arch_jump_label_transform(struct jump_entry *entry, > enum jump_label_type type) > { > u32 *addr = (u32 *)(unsigned long)entry->code; > > if (type == JUMP_LABEL_JMP) > patch_branch(addr, entry->target, 0); > else > patch_instruction(addr, PPC_INST_NOP); > } I would still error on a WARN_ON() as a lot of static keys should still work if they don't get switched over. If a user is concerned about something like this, they can always set panic_on_warn. -- Steve