lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87muc1zvss.fsf@linutronix.de>
Date:   Mon, 09 Dec 2019 10:34:59 +0100
From:   John Ogness <john.ogness@...utronix.de>
To:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc:     linux-kernel@...r.kernel.org,
        Peter Zijlstra <peterz@...radead.org>,
        Petr Mladek <pmladek@...e.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Andrea Parri <andrea.parri@...rulasolutions.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Brendan Higgins <brendanhiggins@...gle.com>,
        kexec@...ts.infradead.org
Subject: Re: [RFC PATCH v5 1/3] printk-rb: new printk ringbuffer implementation (writer)

On 2019-12-09, Sergey Senozhatsky <sergey.senozhatsky.work@...il.com> wrote:
>> + * Sample reader code::
>> + *
>> + *	struct printk_info info;
>> + *	char text_buf[32];
>> + *	char dict_buf[32];
>> + *	u64 next_seq = 0;
>> + *	struct printk_record r = {
>> + *		.info		= &info,
>> + *		.text_buf	= &text_buf[0],
>> + *		.dict_buf	= &dict_buf[0],
>> + *		.text_buf_size	= sizeof(text_buf),
>> + *		.dict_buf_size	= sizeof(dict_buf),
>> + *	};
>> + *
>> + *	while (prb_read_valid(&rb, next_seq, &r)) {
>> + *		if (info.seq != next_seq)
>> + *			pr_warn("lost %llu records\n", info.seq - next_seq);
>> + *
>> + *		if (info.text_len > r.text_buf_size) {
>> + *			pr_warn("record %llu text truncated\n", info.seq);
>> + *			text_buf[sizeof(text_buf) - 1] = 0;
>> + *		}
>> + *
>> + *		if (info.dict_len > r.dict_buf_size) {
>> + *			pr_warn("record %llu dict truncated\n", info.seq);
>> + *			dict_buf[sizeof(dict_buf) - 1] = 0;
>> + *		}
>> + *
>> + *		pr_info("%llu: %llu: %s;%s\n", info.seq, info.ts_nsec,
>> + *			&text_buf[0], info.dict_len ? &dict_buf[0] : "");
>> + *
>> + *		next_seq = info.seq + 1;
>> + *	}
>> + */
>
> Will this loop ever end? :)
>
> pr_info() adds data to ringbuffer, which prb_read_valid() reads, so
> pr_info() can add more data, which prb_read_valid() will read, so
> pr_info()...

The sample code is assuming that @rb is not the same ringbuffer used by
kernel/printk/printk.c. (For example, the test module is doing that to
stress test the ringbuffer code without actually affecting printk.) I
can add a sentence to clarify that.

John Ogness

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ