Message ID | 20221116233854.1596378-6-namhyung@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp118626wrr; Wed, 16 Nov 2022 15:43:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf7dqS9h95S7KOxlT1iNxdlxXslSNYZTn3KVK7SAvHGMLsIRtCuwrHm/RIKVtcEc51gblhsi X-Received: by 2002:a17:907:208d:b0:7ad:d662:f568 with SMTP id pv13-20020a170907208d00b007add662f568mr72352ejb.616.1668642189172; Wed, 16 Nov 2022 15:43:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668642189; cv=none; d=google.com; s=arc-20160816; b=rBeNbsnuYNMWmzuOMONB0K0eq6DfrunqKXKvSWzb6nr55ts+Z9fKN02mOFRNEMLHPK oxilRLhoZ0+3R0ZuMUb+t8qWw+gtwzH6cta0X0UY7KpBkY5+U4UBwEj/FakvgQI2cN7t u1i2h04+iFuYhSHZs5RvpoaAaO5jqkMnwXfgrU/pevBZeb387Nh3KQjPImBeFgNRGjX0 tgsMrljIhbONO6I1k0+g83Nesnh//1sxu5Su+r5e+6g3INjuGv2jL61u+I3jz/0PBTqL j1rlP/w28iRgmrhvKydO7fI7m+M2SVg+DfTgOJ//w+FYF3DABq9K8LkGRAJyxC7/DGI4 rYMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=P97FeOGLA96wHsbLefL56s9RPadISI4phF1+HGdaCPc=; b=eK+zHreYmvGMmouGrm0kIt2Wu1207DJrqVrfveml4irCmVpFcGj7AcZrYNGj6MxCLq zN/KZZVVt7RSoqTvVTY6kzYpp68qvK3kBtYnLgyWqyV9AET9ta6J0TLq9jXKk98KRLB4 Xl71HlA0HYl00uC+7OqtS1ttVgHxaIVYtXNq6oqq5ffcUXExfbVWc2+In0NHWPoWn7P4 x1WgyTRDO54GNl7T+XbO3gxmtL97E783QKDNqiNUsKdTNKxtkDEoiwfHmSFnCuqtCHNG HKEm7f9FjK/oVjsuh1Ih/ppf1Y06grKF9XJrzN45e8Gf+yelCH9P777pzKWm74DpFiSk SCmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RwHw2BwE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o13-20020a170906974d00b0073d8e4e8c77si15892119ejy.1005.2022.11.16.15.42.45; Wed, 16 Nov 2022 15:43:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RwHw2BwE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234554AbiKPXjW (ORCPT <rfc822;just.gull.subs@gmail.com> + 99 others); Wed, 16 Nov 2022 18:39:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233862AbiKPXjH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 16 Nov 2022 18:39:07 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60CFC68299; Wed, 16 Nov 2022 15:39:05 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id o7so124904pjj.1; Wed, 16 Nov 2022 15:39:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=P97FeOGLA96wHsbLefL56s9RPadISI4phF1+HGdaCPc=; b=RwHw2BwEHSGoTMuF7srFdB0iTSrzA5Co9VTFtPfLOesT5GtJEK+x1MBkPa+CtMTuvJ OwP4Js8lrEhxWpT3SZD8xoGEHrwrDyTB8ST+vgtBEqKzHk9qGGsOQm7LedjCysHf46dn BXhHddbyamCHzJoLz4TV28pufnBQGWda7k+jKuIP5Uk4VfHg9iHzONJSHg6N7bCOWAAZ h8euoDw7pWXt7hL2j8HlGCjS/u6zFlU2ipGfe37X7Cn6wcvYthXASQ3LFOaUJQfbJxTU CSZIRER9R8jqrCIWrSPPSialTSA64JgvczLcBYfh+C5AGr0ACEh1wYsgSSwNh9XKPr1O 4aRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=P97FeOGLA96wHsbLefL56s9RPadISI4phF1+HGdaCPc=; b=dA9EXCOF/ypPqEMt1Baj3bVwx0HTHWB44uorK+0d8bvXvq3rDc49czIffWwmEqDoWP 6VxFeAnwiFyaETG4SyOqU3m4s1BysySluE6Vd8zHXPBdnFdExEM4JsLA4sSZ1VvHTPpb GW6WQWlVnd1VETgjZla0ktIHXblyAr6vxYRvKJFVISERfb+4moNzybEYYIxiWKQTLUQg JFn5GRsYDHmrPsRtNqFXRX2zmCVDA/MXfgAiMx90AxaVfS9BMCO5UERlrm/r2LDdO/hm km58UutlAJXj/tq68mvfxFwiK17H8EZdtNBeAkkJEDoZ2gcCxAOcFd2rdWKf0VTXquCK 7TTw== X-Gm-Message-State: ANoB5pkhqwWaNiMULtCwRmg4LKwqcLBUdc5skjvHu77W141Jh/+jXynI nJDrTFk3wtR8VDqDSOmrtPpp9rsn3GU= X-Received: by 2002:a17:903:25d1:b0:176:71be:cc64 with SMTP id jc17-20020a17090325d100b0017671becc64mr53625plb.141.1668641944771; Wed, 16 Nov 2022 15:39:04 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5b40:ce8c:1f7c:9acc]) by smtp.gmail.com with ESMTPSA id bc10-20020a170902930a00b00188ef3ea2b6sm95929plb.262.2022.11.16.15.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 15:39:04 -0800 (PST) Sender: Namhyung Kim <namhyung@gmail.com> From: Namhyung Kim <namhyung@kernel.org> To: Arnaldo Carvalho de Melo <acme@kernel.org>, Jiri Olsa <jolsa@kernel.org> Cc: Ingo Molnar <mingo@kernel.org>, Peter Zijlstra <peterz@infradead.org>, LKML <linux-kernel@vger.kernel.org>, Ian Rogers <irogers@google.com>, Adrian Hunter <adrian.hunter@intel.com>, linux-perf-users@vger.kernel.org, Leo Yan <leo.yan@linaro.org>, German Gomez <german.gomez@arm.com>, Zhengjun Xing <zhengjun.xing@linux.intel.com>, James Clark <james.clark@arm.com>, Athira Jajeev <atrajeev@linux.vnet.ibm.com> Subject: [PATCH 05/12] perf test: Add 'leafloop' test workload Date: Wed, 16 Nov 2022 15:38:47 -0800 Message-Id: <20221116233854.1596378-6-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221116233854.1596378-1-namhyung@kernel.org> References: <20221116233854.1596378-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749698152277572951?= X-GMAIL-MSGID: =?utf-8?q?1749698152277572951?= |
Series |
perf test: Add test workloads (v3)
|
|
Commit Message
Namhyung Kim
Nov. 16, 2022, 11:38 p.m. UTC
The leafloop workload is to run an infinite loop in the test_leaf
function. This is needed for the ARM fp callgraph test to verify if it
gets the correct callchains.
$ perf test -w leafloop
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/builtin-test.c | 1 +
tools/perf/tests/tests.h | 1 +
tools/perf/tests/workloads/Build | 3 +++
tools/perf/tests/workloads/leafloop.c | 34 +++++++++++++++++++++++++++
4 files changed, 39 insertions(+)
create mode 100644 tools/perf/tests/workloads/leafloop.c
Comments
Em Wed, Nov 16, 2022 at 03:38:47PM -0800, Namhyung Kim escreveu: > The leafloop workload is to run an infinite loop in the test_leaf > function. This is needed for the ARM fp callgraph test to verify if it > gets the correct callchains. > > $ perf test -w leafloop On fedora:36 In file included from /usr/include/bits/libc-header-start.h:33, from /usr/include/stdlib.h:26, from tests/workloads/leafloop.c:2: /usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] 412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) | ^~~~~~~ cc1: all warnings being treated as errors make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/tests/workloads/leafloop.o] Error 1 make[5]: *** Waiting for unfinished jobs.... I'll try removing the _FORTIFY_SOURCE > Signed-off-by: Namhyung Kim <namhyung@kernel.org> > --- > tools/perf/tests/builtin-test.c | 1 + > tools/perf/tests/tests.h | 1 + > tools/perf/tests/workloads/Build | 3 +++ > tools/perf/tests/workloads/leafloop.c | 34 +++++++++++++++++++++++++++ > 4 files changed, 39 insertions(+) > create mode 100644 tools/perf/tests/workloads/leafloop.c > > diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c > index 161f38476e77..0ed5ac452f6e 100644 > --- a/tools/perf/tests/builtin-test.c > +++ b/tools/perf/tests/builtin-test.c > @@ -121,6 +121,7 @@ static struct test_suite **tests[] = { > static struct test_workload *workloads[] = { > &workload__noploop, > &workload__thloop, > + &workload__leafloop, > }; > > static int num_subtests(const struct test_suite *t) > diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h > index e6edfeeadaeb..86804dd6452b 100644 > --- a/tools/perf/tests/tests.h > +++ b/tools/perf/tests/tests.h > @@ -202,5 +202,6 @@ struct test_workload workload__##work = { \ > /* The list of test workloads */ > DECLARE_WORKLOAD(noploop); > DECLARE_WORKLOAD(thloop); > +DECLARE_WORKLOAD(leafloop); > > #endif /* TESTS_H */ > diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build > index b8964b1099c0..631596bdb2b3 100644 > --- a/tools/perf/tests/workloads/Build > +++ b/tools/perf/tests/workloads/Build > @@ -2,3 +2,6 @@ > > perf-y += noploop.o > perf-y += thloop.o > +perf-y += leafloop.o > + > +CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer > diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c > new file mode 100644 > index 000000000000..1bf5cc97649b > --- /dev/null > +++ b/tools/perf/tests/workloads/leafloop.c > @@ -0,0 +1,34 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#include <stdlib.h> > +#include <linux/compiler.h> > +#include "../tests.h" > + > +/* We want to check these symbols in perf script */ > +noinline void leaf(volatile int b); > +noinline void parent(volatile int b); > + > +static volatile int a; > + > +noinline void leaf(volatile int b) > +{ > + for (;;) > + a += b; > +} > + > +noinline void parent(volatile int b) > +{ > + leaf(b); > +} > + > +static int leafloop(int argc, const char **argv) > +{ > + int c = 1; > + > + if (argc > 0) > + c = atoi(argv[0]); > + > + parent(c); > + return 0; > +} > + > +DEFINE_WORKLOAD(leafloop); > -- > 2.38.1.584.g0f3c55d4c2-goog
Em Thu, Nov 17, 2022 at 01:06:16PM -0300, Arnaldo Carvalho de Melo escreveu: > Em Wed, Nov 16, 2022 at 03:38:47PM -0800, Namhyung Kim escreveu: > > The leafloop workload is to run an infinite loop in the test_leaf > > function. This is needed for the ARM fp callgraph test to verify if it > > gets the correct callchains. > > > > $ perf test -w leafloop > > On fedora:36 > > In file included from /usr/include/bits/libc-header-start.h:33, > from /usr/include/stdlib.h:26, > from tests/workloads/leafloop.c:2: > /usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] > 412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) > | ^~~~~~~ > cc1: all warnings being treated as errors > make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/tests/workloads/leafloop.o] Error 1 > make[5]: *** Waiting for unfinished jobs.... > > I'll try removing the _FORTIFY_SOURCE Works after I added this to datasym.c, leafloop.c and brstack.c: diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c index 1bf5cc97649b0e23..5d72c001320e3013 100644 --- a/tools/perf/tests/workloads/leafloop.c +++ b/tools/perf/tests/workloads/leafloop.c @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 */ +#undef _FORTIFY_SOURCE #include <stdlib.h> #include <linux/compiler.h> #include "../tests.h"
On Thu, Nov 17, 2022 at 8:15 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > Em Thu, Nov 17, 2022 at 01:06:16PM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Wed, Nov 16, 2022 at 03:38:47PM -0800, Namhyung Kim escreveu: > > > The leafloop workload is to run an infinite loop in the test_leaf > > > function. This is needed for the ARM fp callgraph test to verify if it > > > gets the correct callchains. > > > > > > $ perf test -w leafloop > > > > On fedora:36 > > > > In file included from /usr/include/bits/libc-header-start.h:33, > > from /usr/include/stdlib.h:26, > > from tests/workloads/leafloop.c:2: > > /usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] > > 412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) > > | ^~~~~~~ > > cc1: all warnings being treated as errors > > make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/tests/workloads/leafloop.o] Error 1 > > make[5]: *** Waiting for unfinished jobs.... > > > > I'll try removing the _FORTIFY_SOURCE > > Works after I added this to datasym.c, leafloop.c and brstack.c: Is there a reason we are compiling without -O ? Perhaps we can filter setting _FORTIFY_SOURCE so that it depends on -O being enabled. Thanks, Ian > diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c > index 1bf5cc97649b0e23..5d72c001320e3013 100644 > --- a/tools/perf/tests/workloads/leafloop.c > +++ b/tools/perf/tests/workloads/leafloop.c > @@ -1,4 +1,5 @@ > /* SPDX-License-Identifier: GPL-2.0 */ > +#undef _FORTIFY_SOURCE > #include <stdlib.h> > #include <linux/compiler.h> > #include "../tests.h"
Em Thu, Nov 17, 2022 at 09:16:58AM -0800, Ian Rogers escreveu: > On Thu, Nov 17, 2022 at 8:15 AM Arnaldo Carvalho de Melo > <acme@kernel.org> wrote: > > > > Em Thu, Nov 17, 2022 at 01:06:16PM -0300, Arnaldo Carvalho de Melo escreveu: > > > Em Wed, Nov 16, 2022 at 03:38:47PM -0800, Namhyung Kim escreveu: > > > > The leafloop workload is to run an infinite loop in the test_leaf > > > > function. This is needed for the ARM fp callgraph test to verify if it > > > > gets the correct callchains. > > > > > > > > $ perf test -w leafloop > > > > > > On fedora:36 > > > > > > In file included from /usr/include/bits/libc-header-start.h:33, > > > from /usr/include/stdlib.h:26, > > > from tests/workloads/leafloop.c:2: > > > /usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] > > > 412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) > > > | ^~~~~~~ > > > cc1: all warnings being treated as errors > > > make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/tests/workloads/leafloop.o] Error 1 > > > make[5]: *** Waiting for unfinished jobs.... > > > > > > I'll try removing the _FORTIFY_SOURCE > > > > Works after I added this to datasym.c, leafloop.c and brstack.c: > > Is there a reason we are compiling without -O ? Perhaps we can filter I assumed so as Namhyung added it, perhaps he is just carrying it from the pre-existing shell tests? I wonder its to have a predictable binary output that the test expects when doing things like hardware tracing? As it come from the coresight tests, IIRC. - Arnaldo > setting _FORTIFY_SOURCE so that it depends on -O being enabled. > Thanks, > Ian > > > diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c > > index 1bf5cc97649b0e23..5d72c001320e3013 100644 > > --- a/tools/perf/tests/workloads/leafloop.c > > +++ b/tools/perf/tests/workloads/leafloop.c > > @@ -1,4 +1,5 @@ > > /* SPDX-License-Identifier: GPL-2.0 */ > > +#undef _FORTIFY_SOURCE > > #include <stdlib.h> > > #include <linux/compiler.h> > > #include "../tests.h"
On Thu, Nov 17, 2022 at 9:24 AM Arnaldo Carvalho de Melo <acme@kernel.org> wrote: > > Em Thu, Nov 17, 2022 at 09:16:58AM -0800, Ian Rogers escreveu: > > On Thu, Nov 17, 2022 at 8:15 AM Arnaldo Carvalho de Melo > > <acme@kernel.org> wrote: > > > > > > Em Thu, Nov 17, 2022 at 01:06:16PM -0300, Arnaldo Carvalho de Melo escreveu: > > > > Em Wed, Nov 16, 2022 at 03:38:47PM -0800, Namhyung Kim escreveu: > > > > > The leafloop workload is to run an infinite loop in the test_leaf > > > > > function. This is needed for the ARM fp callgraph test to verify if it > > > > > gets the correct callchains. > > > > > > > > > > $ perf test -w leafloop > > > > > > > > On fedora:36 > > > > > > > > In file included from /usr/include/bits/libc-header-start.h:33, > > > > from /usr/include/stdlib.h:26, > > > > from tests/workloads/leafloop.c:2: > > > > /usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] > > > > 412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) > > > > | ^~~~~~~ > > > > cc1: all warnings being treated as errors > > > > make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/tests/workloads/leafloop.o] Error 1 > > > > make[5]: *** Waiting for unfinished jobs.... > > > > > > > > I'll try removing the _FORTIFY_SOURCE > > > > > > Works after I added this to datasym.c, leafloop.c and brstack.c: > > > > Is there a reason we are compiling without -O ? Perhaps we can filter > > I assumed so as Namhyung added it, perhaps he is just carrying it from > the pre-existing shell tests? > > I wonder its to have a predictable binary output that the test expects > when doing things like hardware tracing? As it come from the coresight > tests, IIRC. Would the following in the Build be better: ``` # Undefine _FORTIFY_SOURCE as it doesn't work with -O0 CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer -U_FORTIFY_SOURCE ``` We could also use make's `filter-out`. If we are disabling inlining then there is also `-fno-optimize-sibling-calls` otherwise we can still lose stack frames. Thanks, Ian > - Arnaldo > > > setting _FORTIFY_SOURCE so that it depends on -O being enabled. > > > Thanks, > > Ian > > > > > diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c > > > index 1bf5cc97649b0e23..5d72c001320e3013 100644 > > > --- a/tools/perf/tests/workloads/leafloop.c > > > +++ b/tools/perf/tests/workloads/leafloop.c > > > @@ -1,4 +1,5 @@ > > > /* SPDX-License-Identifier: GPL-2.0 */ > > > +#undef _FORTIFY_SOURCE > > > #include <stdlib.h> > > > #include <linux/compiler.h> > > > #include "../tests.h" > > -- > > - Arnaldo
Hi, On Thu, Nov 17, 2022 at 9:42 AM Ian Rogers <irogers@google.com> wrote: > > On Thu, Nov 17, 2022 at 9:24 AM Arnaldo Carvalho de Melo > <acme@kernel.org> wrote: > > > > Em Thu, Nov 17, 2022 at 09:16:58AM -0800, Ian Rogers escreveu: > > > On Thu, Nov 17, 2022 at 8:15 AM Arnaldo Carvalho de Melo > > > <acme@kernel.org> wrote: > > > > > > > > Em Thu, Nov 17, 2022 at 01:06:16PM -0300, Arnaldo Carvalho de Melo escreveu: > > > > > Em Wed, Nov 16, 2022 at 03:38:47PM -0800, Namhyung Kim escreveu: > > > > > > The leafloop workload is to run an infinite loop in the test_leaf > > > > > > function. This is needed for the ARM fp callgraph test to verify if it > > > > > > gets the correct callchains. > > > > > > > > > > > > $ perf test -w leafloop > > > > > > > > > > On fedora:36 > > > > > > > > > > In file included from /usr/include/bits/libc-header-start.h:33, > > > > > from /usr/include/stdlib.h:26, > > > > > from tests/workloads/leafloop.c:2: > > > > > /usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] > > > > > 412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) > > > > > | ^~~~~~~ > > > > > cc1: all warnings being treated as errors > > > > > make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/tests/workloads/leafloop.o] Error 1 > > > > > make[5]: *** Waiting for unfinished jobs.... > > > > > > > > > > I'll try removing the _FORTIFY_SOURCE > > > > > > > > Works after I added this to datasym.c, leafloop.c and brstack.c: > > > > > > Is there a reason we are compiling without -O ? Perhaps we can filter > > > > I assumed so as Namhyung added it, perhaps he is just carrying it from > > the pre-existing shell tests? Exactly :) > > > > I wonder its to have a predictable binary output that the test expects > > when doing things like hardware tracing? As it come from the coresight > > tests, IIRC. I think it just checks frame-pointer based callstacks on ARM to have the precise results for leaves and their parents. > > Would the following in the Build be better: > > ``` > # Undefine _FORTIFY_SOURCE as it doesn't work with -O0 > CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer > -U_FORTIFY_SOURCE > ``` > > We could also use make's `filter-out`. If we are disabling inlining > then there is also `-fno-optimize-sibling-calls` otherwise we can > still lose stack frames. I wonder if it's enough to use -O0 as it's enabled from -O2. Maybe we can get rid of -fno-inline as well. German, did you have any concerns for those options? Thanks, Namhyung
On 17/11/2022 18:11, Namhyung Kim wrote: > Hi, > > On Thu, Nov 17, 2022 at 9:42 AM Ian Rogers <irogers@google.com> wrote: >> >> On Thu, Nov 17, 2022 at 9:24 AM Arnaldo Carvalho de Melo >> <acme@kernel.org> wrote: >>> >>> Em Thu, Nov 17, 2022 at 09:16:58AM -0800, Ian Rogers escreveu: >>>> On Thu, Nov 17, 2022 at 8:15 AM Arnaldo Carvalho de Melo >>>> <acme@kernel.org> wrote: >>>>> >>>>> Em Thu, Nov 17, 2022 at 01:06:16PM -0300, Arnaldo Carvalho de Melo escreveu: >>>>>> Em Wed, Nov 16, 2022 at 03:38:47PM -0800, Namhyung Kim escreveu: >>>>>>> The leafloop workload is to run an infinite loop in the test_leaf >>>>>>> function. This is needed for the ARM fp callgraph test to verify if it >>>>>>> gets the correct callchains. >>>>>>> >>>>>>> $ perf test -w leafloop >>>>>> >>>>>> On fedora:36 >>>>>> >>>>>> In file included from /usr/include/bits/libc-header-start.h:33, >>>>>> from /usr/include/stdlib.h:26, >>>>>> from tests/workloads/leafloop.c:2: >>>>>> /usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] >>>>>> 412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) >>>>>> | ^~~~~~~ >>>>>> cc1: all warnings being treated as errors >>>>>> make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/tests/workloads/leafloop.o] Error 1 >>>>>> make[5]: *** Waiting for unfinished jobs.... >>>>>> >>>>>> I'll try removing the _FORTIFY_SOURCE >>>>> >>>>> Works after I added this to datasym.c, leafloop.c and brstack.c: >>>> >>>> Is there a reason we are compiling without -O ? Perhaps we can filter >>> >>> I assumed so as Namhyung added it, perhaps he is just carrying it from >>> the pre-existing shell tests? > > Exactly :) > >>> >>> I wonder its to have a predictable binary output that the test expects >>> when doing things like hardware tracing? As it come from the coresight >>> tests, IIRC. > > I think it just checks frame-pointer based callstacks on ARM to have the > precise results for leaves and their parents. > > >> >> Would the following in the Build be better: >> >> ``` >> # Undefine _FORTIFY_SOURCE as it doesn't work with -O0 >> CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer >> -U_FORTIFY_SOURCE >> ``` >> >> We could also use make's `filter-out`. If we are disabling inlining >> then there is also `-fno-optimize-sibling-calls` otherwise we can >> still lose stack frames. > > I wonder if it's enough to use -O0 as it's enabled from -O2. > Maybe we can get rid of -fno-inline as well. > > German, did you have any concerns for those options? > Is it possible to go with the -U_FORTIFY_SOURCE option? From looking at the disassembly, changing -O and the other -f options makes quite a bit of difference. It's fairly important to that test because it's testing that the combination of both frame pointer unwinding and dwarf unwinding result in the complete stack. If we change the options I'd have to go back and double check with different compiler versions that it's still doing the right thing. For example if a frame pointer is included for the last frame, then the dwarf bit doesn't get tested. > Thanks, > Namhyung
Em Fri, Nov 18, 2022 at 11:32:43AM +0000, James Clark escreveu: > > > On 17/11/2022 18:11, Namhyung Kim wrote: > > Hi, > > > > On Thu, Nov 17, 2022 at 9:42 AM Ian Rogers <irogers@google.com> wrote: > >> > >> On Thu, Nov 17, 2022 at 9:24 AM Arnaldo Carvalho de Melo > >> <acme@kernel.org> wrote: > >>> > >>> Em Thu, Nov 17, 2022 at 09:16:58AM -0800, Ian Rogers escreveu: > >>>> On Thu, Nov 17, 2022 at 8:15 AM Arnaldo Carvalho de Melo > >>>> <acme@kernel.org> wrote: > >>>>> > >>>>> Em Thu, Nov 17, 2022 at 01:06:16PM -0300, Arnaldo Carvalho de Melo escreveu: > >>>>>> Em Wed, Nov 16, 2022 at 03:38:47PM -0800, Namhyung Kim escreveu: > >>>>>>> The leafloop workload is to run an infinite loop in the test_leaf > >>>>>>> function. This is needed for the ARM fp callgraph test to verify if it > >>>>>>> gets the correct callchains. > >>>>>>> > >>>>>>> $ perf test -w leafloop > >>>>>> > >>>>>> On fedora:36 > >>>>>> > >>>>>> In file included from /usr/include/bits/libc-header-start.h:33, > >>>>>> from /usr/include/stdlib.h:26, > >>>>>> from tests/workloads/leafloop.c:2: > >>>>>> /usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] > >>>>>> 412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) > >>>>>> | ^~~~~~~ > >>>>>> cc1: all warnings being treated as errors > >>>>>> make[5]: *** [/home/acme/git/perf/tools/build/Makefile.build:96: /tmp/build/perf/tests/workloads/leafloop.o] Error 1 > >>>>>> make[5]: *** Waiting for unfinished jobs.... > >>>>>> > >>>>>> I'll try removing the _FORTIFY_SOURCE > >>>>> > >>>>> Works after I added this to datasym.c, leafloop.c and brstack.c: > >>>> > >>>> Is there a reason we are compiling without -O ? Perhaps we can filter > >>> > >>> I assumed so as Namhyung added it, perhaps he is just carrying it from > >>> the pre-existing shell tests? > > > > Exactly :) > > > >>> > >>> I wonder its to have a predictable binary output that the test expects > >>> when doing things like hardware tracing? As it come from the coresight > >>> tests, IIRC. > > > > I think it just checks frame-pointer based callstacks on ARM to have the > > precise results for leaves and their parents. > > > > > >> > >> Would the following in the Build be better: > >> > >> ``` > >> # Undefine _FORTIFY_SOURCE as it doesn't work with -O0 > >> CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer > >> -U_FORTIFY_SOURCE > >> ``` > >> > >> We could also use make's `filter-out`. If we are disabling inlining > >> then there is also `-fno-optimize-sibling-calls` otherwise we can > >> still lose stack frames. > > > > I wonder if it's enough to use -O0 as it's enabled from -O2. > > Maybe we can get rid of -fno-inline as well. > > > > German, did you have any concerns for those options? > > > > Is it possible to go with the -U_FORTIFY_SOURCE option? From looking at > the disassembly, changing -O and the other -f options makes quite a bit > of difference. I thought about doing it as a -U_FORTIFY_SOURCE but ended up doing it in each test as I thought that way to be more robust, i.e. the way the makefiles get that per-object CFLAGS and add to the global one could flip and then this would break again. But if people prefer it in the per-object file Build rule, np. - Arnaldo > It's fairly important to that test because it's testing that the > combination of both frame pointer unwinding and dwarf unwinding result > in the complete stack. > > If we change the options I'd have to go back and double check with > different compiler versions that it's still doing the right thing. For > example if a frame pointer is included for the last frame, then the > dwarf bit doesn't get tested. > > > > Thanks, > > Namhyung
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 161f38476e77..0ed5ac452f6e 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -121,6 +121,7 @@ static struct test_suite **tests[] = { static struct test_workload *workloads[] = { &workload__noploop, &workload__thloop, + &workload__leafloop, }; static int num_subtests(const struct test_suite *t) diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index e6edfeeadaeb..86804dd6452b 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -202,5 +202,6 @@ struct test_workload workload__##work = { \ /* The list of test workloads */ DECLARE_WORKLOAD(noploop); DECLARE_WORKLOAD(thloop); +DECLARE_WORKLOAD(leafloop); #endif /* TESTS_H */ diff --git a/tools/perf/tests/workloads/Build b/tools/perf/tests/workloads/Build index b8964b1099c0..631596bdb2b3 100644 --- a/tools/perf/tests/workloads/Build +++ b/tools/perf/tests/workloads/Build @@ -2,3 +2,6 @@ perf-y += noploop.o perf-y += thloop.o +perf-y += leafloop.o + +CFLAGS_leafloop.o = -g -O0 -fno-inline -fno-omit-frame-pointer diff --git a/tools/perf/tests/workloads/leafloop.c b/tools/perf/tests/workloads/leafloop.c new file mode 100644 index 000000000000..1bf5cc97649b --- /dev/null +++ b/tools/perf/tests/workloads/leafloop.c @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include <stdlib.h> +#include <linux/compiler.h> +#include "../tests.h" + +/* We want to check these symbols in perf script */ +noinline void leaf(volatile int b); +noinline void parent(volatile int b); + +static volatile int a; + +noinline void leaf(volatile int b) +{ + for (;;) + a += b; +} + +noinline void parent(volatile int b) +{ + leaf(b); +} + +static int leafloop(int argc, const char **argv) +{ + int c = 1; + + if (argc > 0) + c = atoi(argv[0]); + + parent(c); + return 0; +} + +DEFINE_WORKLOAD(leafloop);