[PATCH] powerpc: add dmesg command to xmon

Arnd Bergmann arnd at arndb.de
Sun May 28 22:04:25 EST 2006


On Sunday 28 May 2006 12:46, Olaf Hering wrote:
> +static int xmon_init_dmesg(void)
> +{
> +       const char **p;
> +       const int *i;
> +       const unsigned long *l;
> +
> +       if (!xmon_log_buf && setjmp(bus_error_jmp) == 0) {
> +               catch_memory_errors = 1;
> +               sync();
> +
> +               p = (const char **)kallsyms_lookup_name("log_buf");
> +               if (p) {
> +                       xmon_log_buf = *p;
> +                       sync();
> +                       __delay(200);
> +               }
> +
> +               i = (const int *)kallsyms_lookup_name("log_buf_len");
> +               if (i) {
> +                       xmon_log_buf_len = *i;
> +                       sync();
> +                       __delay(200);
> +               }
> +
> +               l = (const unsigned long *)kallsyms_lookup_name("log_end");
> +               if (l) {
> +                       xmon_log_end = *l;
> +                       sync();
> +                       __delay(200);
> +               }
> +
> +               l = (const unsigned long *)kallsyms_lookup_name("logged_chars");
> +               if (l) {
> +                       xmon_logged_chars = *l;
> +                       sync();
> +                       __delay(200);
> +               }
> +
> +       }
> +       catch_memory_errors = 0;
> +       return !!xmon_log_buf;

This whole function looks fishy to me. It seems unnecessarily rude to me to
use kallsyms_lookup_name in order to get at a static variable from another
file. Can't you instead add a global function to kernel/printk.c to return
the buffer?

Also, what's the purpose of the sync/__delay code in here? If you use that
to check for a possible machine check that may have happened, why not in
the case where the lookup fails?

	Arnd <><


More information about the Linuxppc-dev mailing list