lkml.org 
[lkml]   [2017]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] early_printk: Add force_early_printk kernel parameter
On Fri, 13 Oct 2017 15:06:09 +0200
Petr Mladek <pmladek@suse.com> wrote:
> >
> > Can we even have !PRINTK && EARLY_PRINTK? If so it seems to me continued
> > usage of early_printk() is what makes most sense.
>
> Yes, !PRINTK && EARLY_PRINTK is possible at the moment. It makes some
> sense because EARLY_PRINTK needs only consoles and they are needed
> also for !PRINTK stuff.
>
> We either should define force_early_printk only when
> PRINTK is enabled.

I think it makes sense to have force_early_printk depend on PRINTK and
EARLY_PRINTK.


> > The reason I did it like this and not use that function pointer thing is
> > that I didn't want to risk anybody hijacking my output ever.
>
> I understand. I think about refactoring the code so that all
> *printk*() variants call printk_func(). This function
> could then call the right printk implementation according
> to the context or global setting.
>
> This way we could have all the logic on a single place and
> avoid the race.
>
> Note that printk_func() is not longer a pointer. It is
> a function since the commit 099f1c84c0052ec1b2
> ("printk: introduce per-cpu safe_print seq buffer").

Yes, I agree with Petr here. Slapping the force printk into
printk_func() should have the same effect, as everything is hard coded
now:

asmlinkage __visible int printk(const char *fmt, ...)
{
va_list args;
int r;

va_start(args, fmt);
r = vprintk_func(fmt, args);
va_end(args);

return r;
}


__printf(1, 0) int vprintk_func(const char *fmt, va_list args)
{
/* Use extra buffer in NMI when logbuf_lock is taken or in safe mode. */
if (this_cpu_read(printk_context) & PRINTK_NMI_CONTEXT_MASK)
return vprintk_nmi(fmt, args);

/* Use extra buffer to prevent a recursion deadlock in safe mode. */
if (this_cpu_read(printk_context) & PRINTK_SAFE_CONTEXT_MASK)
return vprintk_safe(fmt, args);

/*
* Use the main logbuf when logbuf_lock is available in NMI.
* But avoid calling console drivers that might have their own locks.
*/
if (this_cpu_read(printk_context) & PRINTK_NMI_DEFERRED_CONTEXT_MASK)
return vprintk_deferred(fmt, args);

/* No obstacles. */
return vprintk_default(fmt, args);
}

Thus putting in the call to early_printk() at the very beginning of
vprintk_func() would have the result that Peter would like.

-- Steve

\
 
 \ /
  Last update: 2017-10-13 15:31    [W:0.091 / U:2.672 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site