Re: [PATCH 2/2] x86: dumpstack: eliminate some #ifdefs

From: Ingo Molnar
Date: Wed Oct 07 2015 - 03:03:30 EST



* Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> wrote:

> + static const char build_flags[] = ""
> + CHOOSE_EXPR(CONFIG_PREEMPT, " PREEMPT")
> + CHOOSE_EXPR(CONFIG_SMP, " SMP")
> + CHOOSE_EXPR(CONFIG_DEBUG_PAGEALLOC, " DEBUG_PAGEALLOC")
> + CHOOSE_EXPR(CONFIG_KASAN, " KASAN");
> +
> printk(KERN_DEFAULT
> - "%s: %04lx [#%d] ", str, err & 0xffff, ++die_counter);
> -#ifdef CONFIG_PREEMPT
> - printk("PREEMPT ");
> -#endif
> -#ifdef CONFIG_SMP
> - printk("SMP ");
> -#endif
> -#ifdef CONFIG_DEBUG_PAGEALLOC
> - printk("DEBUG_PAGEALLOC ");
> -#endif
> -#ifdef CONFIG_KASAN
> - printk("KASAN");
> -#endif
> - printk("\n");
> + "%s: %04lx [#%d]%s\n", str, err & 0xffff, ++die_counter,
> + build_flags);
> +
> if (notify_die(DIE_OOPS, str, regs, err,
> current->thread.trap_nr, SIGSEGV) == NOTIFY_STOP)
> return 1;

Looks cleaner than what we had before, but I have a naming nit: CHOOSE_EXPR() is
not something I'd be able to remember, I'd have to look it up again all the time,
because it does not have 'config' in its name, and because 'choose' is usually
associated with different constructs.

So how about something more intuitive, like:

COND_CONFIG(CONFIG_PREEMPT, " PREEMPT")
COND_CONFIG(CONFIG_SMP, " SMP")
COND_CONFIG(CONFIG_DEBUG_PAGEALLOC, " DEBUG_PAGEALLOC")
COND_CONFIG(CONFIG_KASAN, " KASAN");

or:

IF_CONFIG(CONFIG_PREEMPT, " PREEMPT")
IF_CONFIG(CONFIG_SMP, " SMP")
IF_CONFIG(CONFIG_DEBUG_PAGEALLOC, " DEBUG_PAGEALLOC")
IF_CONFIG(CONFIG_KASAN, " KASAN");

?

Both names are still unused in the kernel repo.

Thanks,

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/