From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC3CAC433DB for ; Tue, 2 Mar 2021 13:55:59 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 03DEF64EE4 for ; Tue, 2 Mar 2021 13:55:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03DEF64EE4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4DqdvK18tNz3d37 for ; Wed, 3 Mar 2021 00:55:57 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=oL4v99bE; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=suse.com (client-ip=195.135.220.15; helo=mx2.suse.de; envelope-from=pmladek@suse.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=oL4v99bE; dkim-atps=neutral Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Dqdtr6sFCz30QF for ; Wed, 3 Mar 2021 00:55:31 +1100 (AEDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1614693328; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2zHzG0WPsx3xKiPqPnMCcC9JpT/COf8SAqNxgYPDcwI=; b=oL4v99bE7SLyOQloEmxBm5+k/xMRvTkk4pt/OG8qvLA6b9DdiRhtxaD+0nUB4F5N4OQcsj Ic/6CdYJx/OPu8rlCqsNQGpM38HYhSfsHpGptacoyamFaVFqs7/yek3tHvqyg/+qcdd+DL OfjwuhDgZRqJTg+9ADLiziF6AFqEqM8= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 5718AAFF5; Tue, 2 Mar 2021 13:55:28 +0000 (UTC) Date: Tue, 2 Mar 2021 14:55:26 +0100 From: Petr Mladek To: John Ogness 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lfb5pu8c.fsf@jogness.linutronix.de> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-hyperv@vger.kernel.org, Sergey Senozhatsky , Douglas Anderson , Paul Mackerras , Miquel Raynal , "K. Y. Srinivasan" , Thomas Meyer , Vignesh Raghavendra , Wei Liu , Madhavan Srinivasan , Stephen Hemminger , Anton Vorontsov , Joel Stanley , Jason Wessel , Anton Ivanov , Wei Li , Haiyang Zhang , Ravi Bangoria , Kees Cook , Alistair Popple , Jeff Dike , Colin Cross , linux-um@lists.infradead.org, Daniel Thompson , Steven Rostedt , Davidlohr Bueso , Nicholas Piggin , Oleg Nesterov , Thomas Gleixner , Andy Shevchenko , Jordan Niethe , Michael Kelley , Christophe Leroy , Tony Luck , Pavel Tatashin , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Richard Weinberger , kgdb-bugreport@lists.sourceforge.net, linux-mtd@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Mike Rapoport Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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