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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 DC5CAC433DB for ; Tue, 23 Feb 2021 09:04:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACD0864E4B for ; Tue, 23 Feb 2021 09:04:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232153AbhBWJD4 (ORCPT ); Tue, 23 Feb 2021 04:03:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:53216 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231946AbhBWJDC (ORCPT ); Tue, 23 Feb 2021 04:03:02 -0500 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=1614070935; 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=5koVez20mNgf7BKjuFfJWAK0N/ZrPb1QkrYfLF638OI=; b=idECt/f50Pzp1dJg3qe1CDyJcsxiP34a4MxtFMt91nk8m1JoRj50h+t6DkF5xWuzQZ3Uo3 wk9DmvgVLgDxH+Tl6wCFaGTo4Jn4fBHOp5zHZ7YWXlv8mhY9Dnk/qYwhIEvX5n1bDpHjIx /hDr/2CoCxxZCigEu6Fo+2QiSxyWXtk= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 83408AC6E; Tue, 23 Feb 2021 09:02:15 +0000 (UTC) Date: Tue, 23 Feb 2021 10:02:14 +0100 From: Petr Mladek To: stable@vger.kernel.org Cc: John Ogness , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , "J. Avila" , kernel test robot , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] printk: avoid prb_first_valid_seq() where possible Message-ID: References: <20210211173152.1629-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210211173152.1629-1-john.ogness@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2021-02-11 18:37:52, John Ogness wrote: > If message sizes average larger than expected (more than 32 > characters), the data_ring will wrap before the desc_ring. Once the > data_ring wraps, it will start invalidating descriptors. These > invalid descriptors hang around until they are eventually recycled > when the desc_ring wraps. Readers do not care about invalid > descriptors, but they still need to iterate past them. If the > average message size is much larger than 32 characters, then there > will be many invalid descriptors preceding the valid descriptors. > > The function prb_first_valid_seq() always begins at the oldest > descriptor and searches for the first valid descriptor. This can > be rather expensive for the above scenario. And, in fact, because > of its heavy usage in /dev/kmsg, there have been reports of long > delays and even RCU stalls. > > For code that does not need to search from the oldest record, > replace prb_first_valid_seq() usage with prb_read_valid_*() > functions, which provide a start sequence number to search from. > > Fixes: 896fbe20b4e2333fb55 ("printk: use the lockless ringbuffer") > Reported-by: kernel test robot > Reported-by: J. Avila > Signed-off-by: John Ogness Could you please push this fix into the stable releases based on 5.10 and 5.11, please? The patch fixes a visible performance regression. It has landed in the mainline as the commit 13791c80b0cdf54d92fc542 ("printk: avoid prb_first_valid_seq() where possible"). It should apply cleanly. Best Regards, Petr