Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2849268pxb; Mon, 1 Nov 2021 03:09:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsUW1X/1W3wTbAWSO5gRsm5Gfegv5Pn7uGhKHiaBg4qYlM5PeOOzoST9LGtCKqDjvxq0vW X-Received: by 2002:a05:6402:10d2:: with SMTP id p18mr39883945edu.161.1635761391849; Mon, 01 Nov 2021 03:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635761391; cv=none; d=google.com; s=arc-20160816; b=LcY9vbrnV6bi/0GJ34/KY2RZMivHndXWzdg53vli9C8GvrZFjKCdkxj79qQUUxI+Kj fI5mTbgfxWqwZH0w0TF+K7qqxIiaSdXNqH3ZfvJIc3QkQppPPtRXfiDOi2soulVvsKts 4ZnkI4G8+uuBIxkMkCCpSuf+z0s6bRErNeZPzEdSqO+cQjkZNPUwKnbpNJbD1OcB53yr HryGYbTl6YGnAPDzXhQMvpy1vMfvUAbsRAzxYQdxyqfjQ9JSs0wFTeqY85XSsuA3Gnbx 2noFkf6eJ6QPgoe42zzUm7jB2IrwDYlL7bJgg1RPA2HlbRM/tiJ5PoU4qPeGBi0aFmzB cFLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WH7VChrDI+e9Uk1fqS2sz7sqWyDarVDdnxdnYZmqXAk=; b=nXl6u2pP86lzDrbHmA6oqkFMJuqJb5MF2ITQ6IWXAabRAgK50zTh8fOGWoxUe0OCjY nrST7Y1cxaD31MBOg7x/huq4QLtgWPPatSVUN9VNemzNMuIz5n99UVvYB/A8gTCo+1Re pYZ5/f8FcnjiHHZnGSOZ3jV6vRUQh7aC4/EJ0TrS4DXixbZWqtl1XsppgvxYMhSpU/HO 2T8FKzSMt2ygLIqR1HwCMDu1PI62EaKICNZLOIbnatj54nuHJtLKqv/8f/t2KeLHww++ A8SdMkmnVBp2erECShoNRkBAfHAlHz4YamJwQqp/8KRQSJBXeAxHvTyTfC1kNqMLwTem OVSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="vHTq/U3I"; 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=QUARANTINE 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 hr26si15584554ejc.417.2021.11.01.03.09.28; Mon, 01 Nov 2021 03:09:51 -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="vHTq/U3I"; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232161AbhKAKJL (ORCPT + 99 others); Mon, 1 Nov 2021 06:09:11 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:39852 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231958AbhKAKI6 (ORCPT ); Mon, 1 Nov 2021 06:08:58 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4C6491FD29; Mon, 1 Nov 2021 10:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1635761184; 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=WH7VChrDI+e9Uk1fqS2sz7sqWyDarVDdnxdnYZmqXAk=; b=vHTq/U3Id6FrBhLsYrLNIAncwMSC+Auwky48/YfxU80iYDZ/NpKm4Q5X+AK+Mku2Vplu4z 62bOyc4rgBXHnlCEvBRRueCkPtt8DAJJX1x5BBP0bCkaH52L6AjLNpzblJdaKjUfUfLWYW JB1ABBbVTMLdFBEMsLncLOHaQxmQKw0= Received: from suse.cz (unknown [10.100.224.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C5293A3B83; Mon, 1 Nov 2021 10:06:23 +0000 (UTC) Date: Mon, 1 Nov 2021 11:06:23 +0100 From: Petr Mladek To: John Ogness Cc: "chunlei.wang" , Sergey Senozhatsky , Steven Rostedt , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] printk: ringbuffer: Improve prb_next_seq() performance Message-ID: References: <875ytih3j9.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <875ytih3j9.fsf@jogness.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2021-10-27 17:54:42, John Ogness wrote: > On 2021-10-27, Petr Mladek wrote: > > diff --git a/kernel/printk/printk_ringbuffer.c b/kernel/printk/printk_ringbuffer.c > > index 8a7b7362c0dd..24f47fbefbb5 100644 > > --- a/kernel/printk/printk_ringbuffer.c > > +++ b/kernel/printk/printk_ringbuffer.c > > @@ -474,8 +474,10 @@ static enum desc_state desc_read(struct prb_desc_ring *desc_ring, > > * state has been re-checked. A memcpy() for all of @desc > > * cannot be used because of the atomic_t @state_var field. > > */ > > - memcpy(&desc_out->text_blk_lpos, &desc->text_blk_lpos, > > - sizeof(desc_out->text_blk_lpos)); /* LMM(desc_read:C) */ > > + if (desc_out) { > > + memcpy(&desc_out->text_blk_lpos, &desc->text_blk_lpos, > > + sizeof(desc_out->text_blk_lpos)); /* LMM(desc_read:C) */ > > + } > > if (seq_out) > > *seq_out = info->seq; /* also part of desc_read:C */ > > if (caller_id_out) > > You also need this hunk: > > @@ -530,7 +530,8 @@ static enum desc_state desc_read(struct prb_desc_ring *desc_ring, > state_val = atomic_long_read(state_var); /* LMM(desc_read:E) */ > d_state = get_desc_state(id, state_val); > out: > - atomic_long_set(&desc_out->state_var, state_val); > + if (desc_out) > + atomic_long_set(&desc_out->state_var, state_val); > return d_state; > } > > Sorry, I missed it in my last review. This time I build+boot tested the patch. Urgh. Great catch! It seems that my testing was not good enough. Or that I was just lucky. > With this hunk added: > > Reviewed-by: John Ogness I am going to queue it for 5.17 after the pull request for 5.16 is accepted. I do not feel comfortable to rush this into 5.16, especially after finding the bug. The merge window has just started... Anyway, thanks a lot for review and catching the mistake. Best Regards, Petr