Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp693851pxm; Fri, 25 Feb 2022 17:27:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6GFtHXctIOQXbdbLbcsML8qTmw9ebSNX9QBXfIxA8eySsomtxxgPB9J0/+LBWIAeAeW4/ X-Received: by 2002:a17:902:b597:b0:14f:3396:a7a5 with SMTP id a23-20020a170902b59700b0014f3396a7a5mr10304004pls.29.1645838877811; Fri, 25 Feb 2022 17:27:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645838877; cv=none; d=google.com; s=arc-20160816; b=XZ2X5G2zyOg2Oy9RlzI1hpyvDktA4peXE+zW+Otq2wrO3Erg9L/ycoq3sjLWqm/9qX GZ2Xq9In3E+sI2ScR1/6ZK/eqBBKZGoWLAjyS40WucejuRrj8CUAizmt5wcBzr0IrVFv 7qx0tMyQA+wV9lC//FkF5XarOqwdXrnaML8zX5pxkx7wdd7jAwVsJU8lU6us2JUpwBca Y7nKd8tygM4FPRzlX0mG+TDNvSMkZWwRUCj84axr9XZiRIy3Sb2+cEDw1D6gcvol1JRe yeYK30iGtjWVaSnisoNbBfdBIOC0Z0Tso/JQdSFpHR4FhR33+Ho8Azp2yjLIrUaRpLYA QL3g== 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-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=S8A1a91yiBowucBAVXo3Ww3nb6oyEmaUq1pMC/jTSRk=; b=fferVmJEiVOlup1PXXIkv2HjDBqDcZSyBdo6mGM47gN9zBMWRMUXc684adafsaXj89 wuBuDwuyx/svXkaLUrkeUlsDYhYuAFxbtwpMvoF8WGs143EzRd+nvSApScyQipK2yJXy +H7VbVVBFYOXtwv0ZlrQmvZS5rKztQ6HTofnrszNvRwzcLZfQ5aea696HpJ6wa9uK7ls bsrrXlyQlYbJ1lBc3UC0LqiEQ7sH/5sSMiVx7D/to4OKfCe59L950+iNQF/5njSrPIkc 6H6/+VaCF0m4ekJMmzjG8Xe1e/2YJt0T7K1MtfhXvQDlE8iledNlh/6D81emF0LcQWpo SFyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DeWKLKC1; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g20-20020a056a0023d400b004f3c2acaa24si3133052pfc.222.2022.02.25.17.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 17:27:57 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DeWKLKC1; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8F7AB211EF0; Fri, 25 Feb 2022 17:26:20 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237268AbiBYUqC (ORCPT + 99 others); Fri, 25 Feb 2022 15:46:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237248AbiBYUp7 (ORCPT ); Fri, 25 Feb 2022 15:45:59 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B626A21CD29; Fri, 25 Feb 2022 12:45:26 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5040A61A2D; Fri, 25 Feb 2022 20:45:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B094EC340E7; Fri, 25 Feb 2022 20:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645821925; bh=vld9XorWUfjGbFW2+iZOPGxq8V89Q6Px0LoIq9ABYE8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=DeWKLKC1mLoR+BXhFALLNEEiJ87s9TqKY9q/yv2NMKUQNjUuJZ2kNBVoYGtse4v0U tFmmHFUvl2eS0fQ8fvPuBT9Vo4YJ6J13/4TDRk0jwGi1A/TKHcKZ4d/TtodcPPW8xk K6KShJ+Ilgbmkhk93dzR+mpYpP0IFyrQNcJnk7ZVq9KvhRxXOeRsNWBRvCc3/3SI4g JyQXctb9Ih1Yxpx+RUx2UrlIeLXv5AOTZn5E5SNy6ZQhOKXAQkRqTz/I83yK6YQRyd C7mPr7yBnLpA46t8dWQ3qsA5vBwoep9tQtRGdEix3kmJbhGkXXe8GJbBkfnhRGrVNZ njx8FconVCvOg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 5808F5C0144; Fri, 25 Feb 2022 12:45:25 -0800 (PST) Date: Fri, 25 Feb 2022 12:45:25 -0800 From: "Paul E. McKenney" To: Paul Menzel Cc: Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Shuah Khan , Zhouyi Zhou , rcu@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] torture: Make thread detection more robust by using lspcu Message-ID: <20220225204525.GK4285@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20220222120718.17141-1-pmenzel@molgen.mpg.de> <20220222120718.17141-2-pmenzel@molgen.mpg.de> <20220222174328.GL4285@paulmck-ThinkPad-P17-Gen-1> <1084da08-f67d-b5d7-add4-580e9246b7b7@molgen.mpg.de> <20220224205617.GY4285@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 25, 2022 at 06:49:32AM +0100, Paul Menzel wrote: > Dear Paul, > > > Am 24.02.22 um 21:56 schrieb Paul E. McKenney: > > On Thu, Feb 24, 2022 at 09:24:11AM +0100, Paul Menzel wrote: > > > > Am 22.02.22 um 18:43 schrieb Paul E. McKenney: > > > > On Tue, Feb 22, 2022 at 01:07:17PM +0100, Paul Menzel wrote: > > > > > For consecutive numbers *lscpu* collapses the output and just shows the > > > > > range with start and end. The processors are numbered that way on POWER8. > > > > > > > > > > $ sudo ppc64_cpu --smt=8 > > > > > $ lscpu | grep '^NUMA node' > > > > > NUMA node(s): 2 > > > > > NUMA node0 CPU(s): 0-79 > > > > > NUMA node8 CPU(s): 80-159 > > > > > > > > > > This causes the heuristic to detect the number threads per core, looking > > > > > for the number after the first comma, to fail, and QEMU aborts because of > > > > > invalid arguments. > > > > > > > > > > $ lscpu | sed -n -e '/^NUMA node0/s/^[^,]*,\([0-9]*\),.*$/\1/p' > > > > > $ > > > > > > > > > > (Before the last patch, the whole line was returned.) > > > > > > > > > > $ lscpu | grep '^NUMA node0' | sed -e 's/^[^,-]*(,|\-)\([0-9]*\),.*$/\1/' > > > > > NUMA node0 CPU(s): 0-79 > > > > > > > > > > *lscpu* shows the number of threads per core, so use that value directly. > > > > > > > > > > $ sudo ppc64_cpu --smt=8 > > > > > $ lscpu | grep 'Thread(s) per core' > > > > > Thread(s) per core: 8 > > > > > $ sudo ppc64_cpu --smt=off > > > > > $ lscpu | grep 'Thread(s) per core' > > > > > Thread(s) per core: 1 > > > > > > > > > > Note, the replaced heuristic is also incorrect for that case, where the > > > > > threads per core are disabled. > > > > > > > > > > $ lscpu | sed -n -e '/^NUMA node0/s/^[^,]*,\([0-9]*\),.*$/\1/p' > > > > > 8 > > > > > > > > > > Signed-off-by: Paul Menzel > > > > > > > > Makes sense, and thank you for chasing this down and for the fix! > > > > > > > > But should this patch and 1/2 be merged? Or am I confused and they > > > > are somehow affecting two different lines of scripting? > > > > > > You are right. I guess with 1/2 I just wanted to document clearly, what I > > > learned in #sed@irc.libera.chat, that means, how to avoid using grep, when > > > sed is used. > > > > Nothing wrong with that! > > > > I have merged the two patches as shown below. Does this work for you? > > > > Thanx, Paul > > > > ------------------------------------------------------------------------ > > > > commit 9f0daba62e958c31326c7a9eae33651e3a3cc6b4 > > Author: Paul Menzel > > Date: Tue Feb 22 13:07:16 2022 +0100 > > > > torture: Make thread detection more robust by using lspcu > > For consecutive numbers the lscpu command collapses the output and just > > shows the range with start and end. The processors are numbered that > > way on POWER8. > > $ sudo ppc64_cpu --smt=8 > > $ lscpu | grep '^NUMA node' > > NUMA node(s): 2 > > NUMA node0 CPU(s): 0-79 > > NUMA node8 CPU(s): 80-159 > > This causes the heuristic to detect the number threads per core, looking > > for the number after the first comma, to fail, and QEMU aborts because of > > invalid arguments. > > $ lscpu | grep '^NUMA node0' | sed -e 's/^[^,-]*(,|\-)\([0-9]*\),.*$/\1/' > > NUMA node0 CPU(s): 0-79 > > But the lscpu command shows the number of threads per core: > > $ sudo ppc64_cpu --smt=8 > > $ lscpu | grep 'Thread(s) per core' > > Thread(s) per core: 8 > > $ sudo ppc64_cpu --smt=off > > $ lscpu | grep 'Thread(s) per core' > > Thread(s) per core: 1 > > This commit therefore directly uses that value. > > Maybe extend: …, and replaces `grep` by using using sed’s switch `-n` and > the command p. Ah, good point -- I will update this on the next rebase. > > Signed-off-by: Paul Menzel > > Signed-off-by: Paul E. McKenney > > > > diff --git a/tools/testing/selftests/rcutorture/bin/functions.sh b/tools/testing/selftests/rcutorture/bin/functions.sh > > index c35ba24f994c3..66d0414d8e4bc 100644 > > --- a/tools/testing/selftests/rcutorture/bin/functions.sh > > +++ b/tools/testing/selftests/rcutorture/bin/functions.sh > > @@ -301,7 +301,7 @@ specify_qemu_cpus () { > > echo $2 -smp $3 > > ;; > > qemu-system-ppc64) > > - nt="`lscpu | grep '^NUMA node0' | sed -e 's/^[^,]*,\([0-9]*\),.*$/\1/'`" > > + nt="`lscpu | sed -n 's/^Thread(s) per core:\s*//p'`" > > echo $2 -smp cores=`expr \( $3 + $nt - 1 \) / $nt`,threads=$nt > > ;; > > esac > > Thank you for doing that, and sorry for the extra work. No complaints! You are after all testing on powerpc, and getting that working better is a good thing. Thanx, Paul