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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65232C433F5 for ; Mon, 1 Nov 2021 10:07:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 23AD260E9B for ; Mon, 1 Nov 2021 10:07:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 23AD260E9B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zwcVuCUkFZxGOZeUt6vpF7Mz4FPlXDwp3igBetOU8ig=; b=UT8xYp0egXpGs4 PgokYzfRcd1/DRhoPb8VPa9FUChRihpLCizVSqa7JjF4yJ/wLZ3dSzJwJVsJ43HA76z/DpgNx9bYH AaDh8/8NHrWbVXYRbvSOUMByFohCDWcHrLPcDw7x/eXmFtCoC/iKtOG3X4ow5bCllONhuDTOhsNe+ pgxjX6Ej6vXL3xbH2iZ7TWFKjajgNDCRXwVxep1ARkNViaJ+rKLrmyc0/xs43RKAQMXQ57x6ZNHar hJqDJujNm4Q5srXU2iWIrBF+q2jASItOphFdcHDPHAZFEN74CCOCnpAirh1lAdvqz6C8TEVz+NwZ+ mAiitRfSlVcunM8EcKXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhUD8-00FuOb-IE; Mon, 01 Nov 2021 10:06:38 +0000 Received: from smtp-out2.suse.de ([195.135.220.29]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhUD4-00FuNB-Ay; Mon, 01 Nov 2021 10:06:35 +0000 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-Disposition: inline In-Reply-To: <875ytih3j9.fsf@jogness.linutronix.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211101_030634_574134_6E75383A X-CRM114-Status: GOOD ( 20.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel