Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp775378pxb; Mon, 25 Oct 2021 18:42:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW0MZMm+1UhJwIO48Anb6ThFhinnnRooAQuyHKNFyvLeB8uRRv9Eaja0adcXm0LbqF31Zt X-Received: by 2002:a17:906:6089:: with SMTP id t9mr2538013ejj.323.1635212561269; Mon, 25 Oct 2021 18:42:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635212561; cv=none; d=google.com; s=arc-20160816; b=1JCjkUCmFaoBi5mpkMlHZsQPZv8dppXSP059VofFRM8GIuARZAspLdtZFx6dyxOdyB Tyjk1XfBLNDgXwqcgIDXJ59dq6J2RYdNpEiHj0V/KxKX+pIfCK5Pudy8AXO++pnqpSMS e1p+HZY+J+w8GsgwYsGm2zsIHMziqwQx4BkNeBW9/UkMzJ9m77PmYk7uwVJwjUr12aqc GW77JBL6TKzDU6pST25WRyCfIVsYPNEuQ6tI5KCw509l2+n+UMM+/igyXOvCSN/DhII2 VLWBWnH7v7Vy2/x8y5eUr4j26zSfRgeLl6zTJy4lWuyTzOM7ubKIzeP36gMKVzDjUgLR PveQ== 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=2fNJb298Duxoc3HaUlc7Nf67pHRtdIDXApm1+Pxj1CY=; b=W7gakTtTeFXDVj5oUzwj9KXYZZ34YXIOzPL7WURH2xIl71cNm7yaHN+j0gg57oanXe aJKt7Xrq2dx7hypIadbBtkKCU3W8OoMM/+XJ4N1Pqi7cgkNdpLrDh1U5Qi6ubRU0VnHm a4mv779n7LjMFn8fThYkNZDfkPmS9t7DzMTAQWzFNFCPU4bzLMKsuKQVTVrvO9CFbJg1 sum5wrzOg0H7m1pySC7/vWkOR6vuiMqTsPZnM6jnTzpES71FboD784Bi3iBNqeknuA5y N7e3XPII88Wq6tEikb/iFPgRYte3H+N60LibzzjeBWwe73j4A18khJFO7misxukA+xBG EmPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TRqNlEXz; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sh16si31744780ejc.308.2021.10.25.18.42.17; Mon, 25 Oct 2021 18:42:41 -0700 (PDT) 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=@chromium.org header.s=google header.b=TRqNlEXz; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233491AbhJYV3D (ORCPT + 99 others); Mon, 25 Oct 2021 17:29:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233629AbhJYV26 (ORCPT ); Mon, 25 Oct 2021 17:28:58 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E709C061233 for ; Mon, 25 Oct 2021 14:26:26 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id v193so5514424pfc.4 for ; Mon, 25 Oct 2021 14:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2fNJb298Duxoc3HaUlc7Nf67pHRtdIDXApm1+Pxj1CY=; b=TRqNlEXzHsdKTmPnnwk8ZuzVAreo87ING3F8W9WSUyNo4p77FsHs+6hAFCTFjYtSxQ T5FA6kieCvJOBGjblwVzlSD0BBLfceotvpOTPjKgajGY0lOcLq9nAdK0v4y9JmxZ9pEY 5P6Vede0VGDZnBZ3bin+D6Nttc084+XGmRXho= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2fNJb298Duxoc3HaUlc7Nf67pHRtdIDXApm1+Pxj1CY=; b=H7NgAdFap0lf3bHxhSmdUWRPviwjC9OT/CTnOi5UDCTzqZxXRNXEJ6caDqep5AiGEZ G/u5aoxZKBSQaY5SlVDr3yx7Ex+8L276/g9P52eN9AUUZhz5RTKMJBR0sZT+ZkXOLzSw Mz/XFf9Y+plQd/ANMmRaT5IW1qKECoT45Wm/f6cL1vrsyguzdhKZ3ncZ6cTNykUeaBUQ D6jz7fEkxZRPrTpuQMa88VE1zTiFgTEZZg+xfPZMzGUO8BFsfQIfkH7Ew2VdP26ver0W ty9HgRYiiG/dQWqPPKHesi24JFDzBVLqefNOzlLrklk14A8OGvmS9/grjp6IsoiZ+M8v Ez1g== X-Gm-Message-State: AOAM532i+9195E/nCO4Zif3uZjA11l0Hz6wHdTEKS/rweHe0FzOsBvGx DYjff6btwu1yYIlac4AgW/VjDQ== X-Received: by 2002:a62:5ec2:0:b0:44d:47e2:4b3b with SMTP id s185-20020a625ec2000000b0044d47e24b3bmr21508392pfb.38.1635197185593; Mon, 25 Oct 2021 14:26:25 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s2sm25055172pjs.56.2021.10.25.14.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 14:26:25 -0700 (PDT) Date: Mon, 25 Oct 2021 14:26:24 -0700 From: Kees Cook To: Yafang Shao Cc: akpm@linux-foundation.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, pmladek@suse.com, peterz@infradead.org, viro@zeniv.linux.org.uk, valentin.schneider@arm.com, qiang.zhang@windriver.com, robdclark@chromium.org, christian@brauner.io, dietmar.eggemann@arm.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, davem@davemloft.net, kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, dennis.dalessandro@cornelisnetworks.com, mike.marciniszyn@cornelisnetworks.com, dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, oliver.sang@intel.com, lkp@intel.com, Andrii Nakryiko Subject: Re: [PATCH v6 09/12] tools/perf/test: make perf test adopt to task comm size change Message-ID: <202110251426.2921B7BDD7@keescook> References: <20211025083315.4752-1-laoar.shao@gmail.com> <20211025083315.4752-10-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211025083315.4752-10-laoar.shao@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 25, 2021 at 08:33:12AM +0000, Yafang Shao wrote: > kernel test robot reported a perf-test failure after I extended task comm > size from 16 to 24. The failure as follows, > > 2021-10-13 18:00:46 sudo /usr/src/perf_selftests-x86_64-rhel-8.3-317419b91ef4eff4e2f046088201e4dc4065caa0/tools/perf/perf test 15 > 15: Parse sched tracepoints fields : FAILED! > > The reason is perf-test requires a fixed-size task comm. If we extend > task comm size to 24, it will not equil with the required size 16 in perf > test. > > After some analyzation, I found perf itself can adopt to the size > change, for example, below is the output of perf-sched after I extend > comm size to 24 - > > task 614 ( kthreadd: 84), nr_events: 1 > task 615 ( systemd: 843), nr_events: 1 > task 616 ( networkd-dispat: 1026), nr_events: 1 > task 617 ( systemd: 846), nr_events: 1 > > $ cat /proc/843/comm > networkd-dispatcher > > The task comm can be displayed correctly as expected. > > Replace old hard-coded 16 with the new one can fix the warning, but we'd > better make the test accept both old and new sizes, then it can be > backward compatibility. > > After this patch, the perf-test succeeds no matter task comm is 16 or > 24 - > > 15: Parse sched tracepoints fields : Ok > > This patch is a preparation for the followup patch. > > Reported-by: kernel test robot > Suggested-by: Arnaldo Carvalho de Melo > Signed-off-by: Yafang Shao > Cc: Mathieu Desnoyers > Cc: Arnaldo Carvalho de Melo > Cc: Andrii Nakryiko > Cc: Peter Zijlstra > Cc: Steven Rostedt > Cc: Al Viro > Cc: Kees Cook > Cc: Petr Mladek I'll let the perf folks comment on this one. :) -Kees > --- > tools/include/linux/sched.h | 11 +++++++++++ > tools/perf/tests/evsel-tp-sched.c | 26 ++++++++++++++++++++------ > 2 files changed, 31 insertions(+), 6 deletions(-) > create mode 100644 tools/include/linux/sched.h > > diff --git a/tools/include/linux/sched.h b/tools/include/linux/sched.h > new file mode 100644 > index 000000000000..0d575afd7f43 > --- /dev/null > +++ b/tools/include/linux/sched.h > @@ -0,0 +1,11 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _TOOLS_LINUX_SCHED_H > +#define _TOOLS_LINUX_SCHED_H > + > +/* Keep both length for backward compatibility */ > +enum { > + TASK_COMM_LEN_16 = 16, > + TASK_COMM_LEN = 24, > +}; > + > +#endif /* _TOOLS_LINUX_SCHED_H */ > diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c > index f9e34bd26cf3..029f2a8c8e51 100644 > --- a/tools/perf/tests/evsel-tp-sched.c > +++ b/tools/perf/tests/evsel-tp-sched.c > @@ -1,11 +1,13 @@ > // SPDX-License-Identifier: GPL-2.0 > #include > +#include > #include > #include "evsel.h" > #include "tests.h" > #include "debug.h" > > -static int evsel__test_field(struct evsel *evsel, const char *name, int size, bool should_be_signed) > +static int evsel__test_field_alt(struct evsel *evsel, const char *name, > + int size, int alternate_size, bool should_be_signed) > { > struct tep_format_field *field = evsel__field(evsel, name); > int is_signed; > @@ -23,15 +25,24 @@ static int evsel__test_field(struct evsel *evsel, const char *name, int size, bo > ret = -1; > } > > - if (field->size != size) { > - pr_debug("%s: \"%s\" size (%d) should be %d!\n", > + if (field->size != size && field->size != alternate_size) { > + pr_debug("%s: \"%s\" size (%d) should be %d", > evsel->name, name, field->size, size); > + if (alternate_size > 0) > + pr_debug(" or %d", alternate_size); > + pr_debug("!\n"); > ret = -1; > } > > return ret; > } > > +static int evsel__test_field(struct evsel *evsel, const char *name, > + int size, bool should_be_signed) > +{ > + return evsel__test_field_alt(evsel, name, size, -1, should_be_signed); > +} > + > int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtest __maybe_unused) > { > struct evsel *evsel = evsel__newtp("sched", "sched_switch"); > @@ -42,7 +53,8 @@ int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtes > return -1; > } > > - if (evsel__test_field(evsel, "prev_comm", 16, false)) > + if (evsel__test_field_alt(evsel, "prev_comm", TASK_COMM_LEN_16, > + TASK_COMM_LEN, false)) > ret = -1; > > if (evsel__test_field(evsel, "prev_pid", 4, true)) > @@ -54,7 +66,8 @@ int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtes > if (evsel__test_field(evsel, "prev_state", sizeof(long), true)) > ret = -1; > > - if (evsel__test_field(evsel, "next_comm", 16, false)) > + if (evsel__test_field_alt(evsel, "next_comm", TASK_COMM_LEN_16, > + TASK_COMM_LEN, false)) > ret = -1; > > if (evsel__test_field(evsel, "next_pid", 4, true)) > @@ -72,7 +85,8 @@ int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtes > return -1; > } > > - if (evsel__test_field(evsel, "comm", 16, false)) > + if (evsel__test_field_alt(evsel, "comm", TASK_COMM_LEN_16, > + TASK_COMM_LEN, false)) > ret = -1; > > if (evsel__test_field(evsel, "pid", 4, true)) > -- > 2.17.1 > -- Kees Cook