Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2226091pxb; Tue, 23 Feb 2021 01:31:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHTWpdMN8huFlCeFvEWMrqg+AyCViT77uBWDZl4sVUWofRI0PNDp1J9rIBhrVJYZ0y6niM X-Received: by 2002:a50:cd8c:: with SMTP id p12mr27217677edi.114.1614072680884; Tue, 23 Feb 2021 01:31:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614072680; cv=none; d=google.com; s=arc-20160816; b=xqPea1n6R/hHnvRKDoAMIWuafTrGw77ZAwXMvuMkaTdLG+YnV1g0vrMujI8UmoFhna 7IiuYcOLmFBeJAxTaL7ZeWUpdZQEcbeKgD2B/ScrY1j3QaA47LyIIJNDiPocZxKLE3+P /jceSIWDFmZv3Ekj5MBwHcd4yCgtQAqN4G9nJPRpaxzit9i4grT8wyL4PTVF4MdR5+0m t9q8ibPT1Qp+QzGsfvm8cfcDHUbWD73gIKTnaeqpRnsMWlvnlWN9VlI4bj8orPNnVvHx z1ccOU4Jao0BP/8T5zHJtUX9eJ+tYcCFAYVn+xqU0XzL9jfNwekISXCHqUL0jAOdCfhr ZDIg== 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=5koVez20mNgf7BKjuFfJWAK0N/ZrPb1QkrYfLF638OI=; b=AEeHgILgynRlFqkcVS3U7SYot4E4McKFXHcNS192X4UcfE4Xl1wnjjgwzF4B7g3KO3 bJsSWgerPnNE46/97qDPJP8CaMq5B1/r4OH2je4G+KZieXLnkrMC3z5fbC5B6w5eZJ0y uNy0oPDBx+IdpGi7yHNOrr9vY55a/aZ87mToJ0lMBjQavRiIsrHTsQM5eJ5w54ArW5kH aztyvXg05GGviDPKKVbISKAeL6NCWg6A+N1oCkoopbjf/6WPge2nqMGQYcMH0ODGz8i2 Dg+FzckR8yx9clzWF8I7pM6YJpoa5vTJ3jBG2ir6Gv9ypZ7lUxQc1z/3GfBm/FocyR6y Komw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="idECt/f5"; 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 o15si8699583ejr.527.2021.02.23.01.30.51; Tue, 23 Feb 2021 01:31:20 -0800 (PST) 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="idECt/f5"; 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 S230014AbhBWJDs (ORCPT + 99 others); Tue, 23 Feb 2021 04:03:48 -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