[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181016142158.GA2603@hirez.programming.kicks-ass.net>
Date: Tue, 16 Oct 2018 16:21:58 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc: linux-kernel@...r.kernel.org, Petr Mladek <pmladek@...e.com>,
Steven Rostedt <rostedt@...dmis.org>,
Daniel Wang <wonderfly@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Alan Cox <gnomes@...rguk.ukuu.org.uk>,
Jiri Slaby <jslaby@...e.com>,
Peter Feiner <pfeiner@...gle.com>,
linux-serial@...r.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Subject: Re: [RFC][PATCHv2 2/4] printk: move printk_safe macros to printk
header
On Tue, Oct 16, 2018 at 02:54:15PM +0200, Peter Zijlstra wrote:
> printk will determine the current context:
>
> task, softirq, hardirq or NMI
>
> and pick the corresponding per-cpu line buffer and do the vsnprintf()
We need 4, but we don't need to do the exact context determination for
this. We can keep a simple counter:
#define MAX_IDX 4 /* task, sirq, hirq, nmi */
#define MAX_LEN 1020 /* sizeof(struct line_buffer) < 4k */
struct line_buffers {
int idx;
char line[MAX_IDX][MAX_LEN];
};
static DEFINE_PER_CPU(struct line_buffers, lbs);
static char *get_linebuf(void)
{
struct line_buffers *lbp = this_cpu_ptr(&lbs);
int idx;
idx = lbp->idx++;
return lbp->linx[idx];
}
static void put_linbuf(void)
{
this_cpu_dec(lbs.idx);
}
> thing. Then we have the actual line length and content. With the length
> we reserve the bytes from the global buffer, we memcpy into the buffer
> and commit.
Powered by blists - more mailing lists