From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 2 Mar 2021 14:55:26 +0100 From: Petr Mladek Subject: Re: [PATCH next v3 12/15] printk: introduce a kmsg_dump iterator Message-ID: References: <20210225202438.28985-1-john.ogness@linutronix.de> <20210225202438.28985-13-john.ogness@linutronix.de> <87lfb5pu8c.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87lfb5pu8c.fsf@jogness.linutronix.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+geert=linux-m68k.org@lists.infradead.org To: John Ogness Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Jeff Dike , Richard Weinberger , Anton Ivanov , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Miquel Raynal , Vignesh Raghavendra , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck , Jason Wessel , Daniel Thompson , Douglas Anderson , Pavel Tatashin , Joel Stanley , Christophe Leroy , Jordan Niethe , Alistair Popple , Ravi Bangoria , Nicholas Piggin , Mike Rapoport , Madhavan Srinivasan , Thomas Meyer , Andy Shevchenko , Davidlohr Bueso , Oleg Nesterov , Wei Li , Michael Kelley , linuxppc-dev@lists.ozlabs.org, linux-um@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-mtd@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net List-ID: On Tue 2021-03-02 14:20:51, John Ogness wrote: > On 2021-03-01, Petr Mladek wrote: > >> diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c > >> index 532f22637783..5a64b24a91c2 100644 > >> --- a/arch/powerpc/kernel/nvram_64.c > >> +++ b/arch/powerpc/kernel/nvram_64.c > >> @@ -681,13 +680,14 @@ static void oops_to_nvram(struct kmsg_dumper *dumper, > >> return; > >> > >> if (big_oops_buf) { > >> - kmsg_dump_get_buffer(dumper, false, > >> + kmsg_dump_rewind(&iter); > > > > It would be nice to get rid of the kmsg_dump_rewind(&iter) calls > > in all callers. > > > > A solution might be to create the following in include/linux/kmsg_dump.h > > > > Then we could do the following at the beginning of both > > kmsg_dump_get_buffer() and kmsg_dump_get_line(): > > > > u64 clear_seq = latched_seq_read_nolock(&clear_seq); > > > > if (iter->cur_seq < clear_seq) > > cur_seq = clear_seq; > > I suppose we need to add this part anyway, if we want to enforce that > records before @clear_seq are not to be available for dumpers. Yup. > > It might be better to avoid the infinite loop. We could do the following: > > > > static void check_and_set_iter(struct kmsg_dump_iter) > > { > > if (iter->cur_seq == 0 && iter->next_seq == U64_MAX) { > > kmsg_dump_rewind(iter); > > } > > > > and call this at the beginning of both kmsg_dump_get_buffer() > > and kmsg_dump_get_line() > > > > What do you think? > > On a technical level, it does not make any difference. It is pure > cosmetic. Yup. > Personally, I prefer the rewind directly before the kmsg_dump_get calls > because it puts the initializer directly next to the user. > > As an example to illustrate my view, I prefer: > > for (i = 0; i < n; i++) > ...; > > instead of: > > int i = 0; > > ... > > for (; i < n; i++) > ...; > > Also, I do not really like the special use of 0/U64_MAX to identify > special actions of the kmsg_dump_get functions. Fair enough. > > Note that I do not resist on it. But it might make the API easier to > > use from my POV. > > Since you do not resist, I will keep the API the same for v4. But I will > add the @clear_seq check to the kmsg_dump_get functions. Go for it. Best Regards, Petr ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/