Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2814097pxb; Fri, 12 Feb 2021 01:51:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyECJyGkLVEXCWQlYfFb75zyCMJTMcqJW69Fn4HX7Q7UDSkPKlNmXm7uye6blWC1gopjPiI X-Received: by 2002:a17:906:2755:: with SMTP id a21mr2217132ejd.374.1613123490523; Fri, 12 Feb 2021 01:51:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613123490; cv=none; d=google.com; s=arc-20160816; b=DV6juYexeCOFoK9w6qU0PbPfCtvbPPQaVd6lIbRlniSGA7qhbhpkFNtF66r9+veiGv UBw8AQRrKyC9k3UUtcHzU6Mu3GttPz3j+pXwV+hpOPer26piCGJaJo5p3uw7R1Xl2mx8 gtCsrltJVozbnZOf1qNxO5Mh9KaHNe2cvI4f+wtYBSjfPDZNYaEISgHgdnjO26SZNo2o x0WCj9e7saeUIruMzstINqpRPcjuQYyX6WLkpNpbsvLmVGBJMwn/JxDSFPTip+e06Ll1 QFg6niNuZWQB7Ipany6wVnCOayr4m72OmDW4Vf4+yoYEsACt+W6vqp+oo+jKbrUh1cXQ jh6g== 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=MRHvqshruqvs3aOgQUWLKWvnflNOmOtBfIlkGvC280w=; b=bMrO5fyEB1dHYVJHyXcd1wpXbx6hDtcW+cflrvL9grZ//Aqq07uGaEvHPjyEkTcLH2 xPPeujO08D6LRSBxyKoIbrg2drfvm+Zy4TvAvEI3ry/4zOb/KN35UEyLcKzDHOZ31f19 8QMfrPAAJuJvm199ARi3VLUgA8WAcI+0uPmJjO2LgLAx81+B+zvDuswIV0JfywAxLQMm uqrhezGvM5iRhUt4AGJvQgK1TnzWFQJATkxVUV+qBZUx8Qi2bVn/GjDOBgw2RIQ6MTSG KUV7/BPtiHEC+7fbzbJkhLyV5KJ0nLSKYHltX2CJpXjWCNFNlgOsF7RrtW/MIoWdaF7q TxHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=JoS4EFB8; 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 e6si3302689ejs.366.2021.02.12.01.51.07; Fri, 12 Feb 2021 01:51:30 -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=JoS4EFB8; 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 S230039AbhBLJsO (ORCPT + 99 others); Fri, 12 Feb 2021 04:48:14 -0500 Received: from mx2.suse.de ([195.135.220.15]:50284 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbhBLJrx (ORCPT ); Fri, 12 Feb 2021 04:47:53 -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=1613123226; 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=MRHvqshruqvs3aOgQUWLKWvnflNOmOtBfIlkGvC280w=; b=JoS4EFB8kxyJDBNuOH8c7mCafhgaAwHMyt3Q9WWEi3p2biR2Nlw0CAWMTOG8x2KDqzVnZ3 UYZvA5HUxVT9yDKHjla4OxbbYL36LszQ9vg+O25hlOV+gnuDtgr98M7REk6tN7v6LMDtxE ZoMD2sfCd4U8UEbsE+0/myALBQuq+jM= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 36B87B176; Fri, 12 Feb 2021 09:47:06 +0000 (UTC) Date: Fri, 12 Feb 2021 10:47:05 +0100 From: Petr Mladek To: John Ogness Cc: 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 Reviewed-by: Petr Mladek I am going to push the patch later today. I would prefer to do it later and give a chance others to react. But the merge window will likely start the following week and Sergey was fine with this approach. Best Regard, Petr