From patchwork Mon Oct 25 08:33:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12581045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6298C433EF for ; Mon, 25 Oct 2021 08:34:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6B0F960F46 for ; Mon, 25 Oct 2021 08:34:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6B0F960F46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0E51894000D; Mon, 25 Oct 2021 04:34:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 01F1E940007; Mon, 25 Oct 2021 04:34:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8B3594000D; Mon, 25 Oct 2021 04:34:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id C044F940007 for ; Mon, 25 Oct 2021 04:34:04 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 85BA32BA8E for ; Mon, 25 Oct 2021 08:34:04 +0000 (UTC) X-FDA: 78734297208.23.3257138 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf18.hostedemail.com (Postfix) with ESMTP id 2BB564002091 for ; Mon, 25 Oct 2021 08:34:04 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id u6-20020a17090a3fc600b001a00250584aso10823826pjm.4 for ; Mon, 25 Oct 2021 01:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1md3Mevkn+CBLiLByux/J8bl1HeiftdQPKT0KXDTr4s=; b=ippqS7oyy/Xxu6ZxvpuafUWSvpsfvfwE/3J3JNAouce3xXBt5wOOlT/RiZpgQ0gzj8 PKadBOKIY75j0iZuHaUbBgBpNPw5ZbxNYHrf5n2Tsn9IYbPusgJzNUZTTGkGSwjkBp6n oK9EKcykGE6fGX+zqXz9NTA+gFaqMFBkTthGhqY2C0RpW4E8fnrfZGLFHgh2pQRJewxw 2FLLyudFZ5ofXs9aNR1UXn5m5pgHHAflMUH3uYxlOfVxySeAykoWnZCRjhUNXEj0A8Ce 2/4PFZ/n097pvj+lPKb+n1HLjmSbAFa4LCwkEIn8vMqH689VQmoKK20lbaOX2cjARGm2 i99w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1md3Mevkn+CBLiLByux/J8bl1HeiftdQPKT0KXDTr4s=; b=UI7PGdgJacem0lHnpXzUd6vd+Ncnb2XzZiXO9TQTsePETX6mDGA94Z0z9ZEMkQn0M1 +9yPb0od0xGt0jEtI0UZD8aCaRKI+lVcF47LxFZQNzk4tZPquYLbk7ZBdX2kHwka+bpd CoyZj2wOhL/nRyIYZkJ/uFcVzNxXqu7uGFmqPAW8ENiatyRXMXN2GsKQNUP2ynjxJ1zG 67u9O/RvXppshVA+T+Fjza7Co4a6KqhJVIyuAb7tYH3xzumTdIKeImD9tZzmWV96Soif wXTdhbozYpT89WDMgHqVwBvq3wL0Mhkzl9GhCSEupItQWERegj0U07ZkMxRyrSZu9KO0 hiOA== X-Gm-Message-State: AOAM531nkTmPFnIc7vryLY9eeFu1z9iV9q4WGvcqgSOFUxIxSvy3nDRl Hku33CXyqxK4Qtg8A1Xk35A= X-Google-Smtp-Source: ABdhPJwx3ky7vXb/J2lUahfhiiyc2nfJn2hGx6yFG/luHydF3goGPz/vPzvSnaj5EdOe4N7u8ko/aQ== X-Received: by 2002:a17:90a:284c:: with SMTP id p12mr12363516pjf.95.1635150843340; Mon, 25 Oct 2021 01:34:03 -0700 (PDT) Received: from localhost.localdomain ([140.82.17.67]) by smtp.gmail.com with ESMTPSA id p13sm2495694pfo.102.2021.10.25.01.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 01:34:02 -0700 (PDT) From: Yafang Shao To: akpm@linux-foundation.org, keescook@chromium.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 Cc: 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, Yafang Shao , Andrii Nakryiko Subject: [PATCH v6 09/12] tools/perf/test: make perf test adopt to task comm size change Date: Mon, 25 Oct 2021 08:33:12 +0000 Message-Id: <20211025083315.4752-10-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211025083315.4752-1-laoar.shao@gmail.com> References: <20211025083315.4752-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Stat-Signature: mn58e5otgudt3cnuebxipyi8opwkg474 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ippqS7oy; spf=pass (imf18.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2BB564002091 X-HE-Tag: 1635150844-394916 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- 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))