Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp473610pxk; Wed, 23 Sep 2020 07:54:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzFreeYjy3gseJ6nc0/ue+4i4JrdIwmPVtY0woIA2/nqe7q38sOy/mOC11I0NgrnWGAQcj X-Received: by 2002:a50:9fe6:: with SMTP id c93mr10041744edf.151.1600872851858; Wed, 23 Sep 2020 07:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600872851; cv=none; d=google.com; s=arc-20160816; b=TMgNyJ6tbTXXujVgizJv0llqvqz6pFCELoEErdH6898BsRC2XwhdDUm9ieUF3Fxjsl DqnpBffcFIrF0VJ8cJRBjh1jdOoNYjP2nb98ZnavtP4aJjRvENmcdHtryyemR4S++QmI 1BKLiaBNTE97L8jdDmpoALyKz/siNbuxbK/0dFCCtiCIhoTY7SV7a3YlQen4cmqxs51E Cma0HDEopqLlQmXp0xPqd8KpiKrjG1A4wB6K+RqgzNDoEQfvatTbT6GXbgghu+3HvqcY atxxxjt/qVyU10d6koboldJJXdmjVmoaa1sXdX0YTgjeNZzN4Q80/8mw0ZK72WmLKNjm q1ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CUTpQM5HoufUKrkApLxYrepbdg1WoLwvxJQbyZvYlKI=; b=UQDYrdpTPVN+/z/EEbsGPODhLaRXmzXPBzHEZg5d8SCsjmzmZZmvhQjFxvLzbgEAew ITi5llxAhVMXfIQ7HojghU5TElKRDEKvbaoPYv/kDMXPvPE5aCrFF/6R080vU9Y9juv/ APuglgK61Po6q4UaQ/9JcW3f2dOydT+1TcEX70n1ZvY3mNFwFKfh8KvtEHURPd7Zn4nB RvDdNw1xvhaxnreiXnjqkrxbdWsHvhCy6o759rPnLTqCvm6gXgeoa5wrP0KlERhhVI7Q V4n1GaHxbHBOlCcbMbJfNDX9YBRo6AJNJ/Ilsg5n0q+ZfSzrACs7nWPR7hJfY9d6m1+M p8Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=VHGUJgQp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si31853edq.397.2020.09.23.07.53.46; Wed, 23 Sep 2020 07:54:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=VHGUJgQp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgIWOwL (ORCPT + 99 others); Wed, 23 Sep 2020 10:52:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:58938 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgIWOwL (ORCPT ); Wed, 23 Sep 2020 10:52:11 -0400 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=1600872729; h=from:from:reply-to:subject:subject: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=CUTpQM5HoufUKrkApLxYrepbdg1WoLwvxJQbyZvYlKI=; b=VHGUJgQpkN2viXPP+1lqdbr+ePgnIz6qnw302dVdwS5CfjP7ygWKrpSj796t6clly5bC0Q Nd95zn5JUa63C4imf9leKzZ+kVmTVIMT/P8XqaG0Z3ovJzQuHcbAG5X4WVHCTi2ZRRF+F+ noBpN0dHsxzVPnluEhN2PE1hibEFoqw= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8E3E7AD43; Wed, 23 Sep 2020 14:52:46 +0000 (UTC) Date: Wed, 23 Sep 2020 16:52:08 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk 2/5] printk: kmsg_dump_rewind_nolock: start from first record Message-ID: <20200923145208.GB6442@alley> References: <20200922153816.5883-1-john.ogness@linutronix.de> <20200922153816.5883-3-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200922153816.5883-3-john.ogness@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2020-09-22 17:44:13, John Ogness wrote: > kmsg_dump_rewind_nolock() accesses @clear_seq without any locking. > However, accessing this global variable requires holding > @logbuf_lock. For the _nolock() variant, start from the first record > in the ringbuffer rather than the @clear_seq record. > Signed-off-by: John Ogness > --- > kernel/printk/printk.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index 00bc1fce3299..cff13b33e926 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -3410,11 +3410,12 @@ EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer); > * kmsg_dump_get_buffer() can be called again and used multiple > * times within the same dumper.dump() callback. > * > - * The function is similar to kmsg_dump_rewind(), but grabs no locks. > + * The function is similar to kmsg_dump_rewind(), but grabs no locks > + * and starts from the oldest record rather than from @clear_seq. > */ > void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper) > { > - dumper->cur_seq = clear_seq; > + dumper->cur_seq = 0; Just to understand it. Is the problem that the value might be in an inconsistent state? I mean that it might be modified by more instructions, for example, because of compiler optimizations or on 32-bit system by definition. I still have to look at the later patches. But it seems that the new syslog_lock is taken mostly only around reading or writing the global @clear_seq variable. Atomic variable might do the same job. Best Regards, Petr