Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1487rwn; Wed, 7 Sep 2022 11:27:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR7xfCvI/M+uCO5/oLGyI1kk/NuwQwpsAUWD9QXDpJ1oLU5L+WHpQ+vtebcEvrZ9KZzO39uz X-Received: by 2002:a17:907:1dc8:b0:741:61eb:9fba with SMTP id og8-20020a1709071dc800b0074161eb9fbamr3361071ejc.665.1662575248088; Wed, 07 Sep 2022 11:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662575248; cv=none; d=google.com; s=arc-20160816; b=cV+U2r4sb32R0DuRdLvxAUnG3e2x3nvyBzk/MPWb45XyMPl+wYMeJjQvu1AGDBvOw9 9uDQm8/16dVFiE0NTfvJaF/oyIBNZQbsgoDxm+8nZYdMEO+/V+8aINJLj6sl3yGDnU0q PjBTi8EoLCxhTg2r710EOIHXQvWCQKMA73Zc6zKltCOcKd59879wro4AkgldTZbXcug1 ef/5wWYI4jJFo78MLKMf1DFZVvhTwEZWxehV1cR+ouN72e9FWxs1U8rLntwqYGWEZBA1 Wrd864gWFND3rPoBlQeuE1WRjAhWIAVJ/j6JQeqbxStx6YV0Ge1RzC8GCfiyr2PYkhaO BDBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=cwQcMikn8PY/begH6mMZDx9ENCQa5sG31sOsvQOo7/o=; b=hwEpJX7mkt3F0+hwcxqbXMk5Ohz21a2k84cR8vD4w/JVSOX9huMdzV0kcgaSxD5fZR JsU/+GkAW5NqT7UR1kI/cAFMsjyPUOBSGSdGo04WgAXEuh6sn12XMHFqDc00E+SbesLk xAaXPgZd/xIjLu6pivLAGBYFYexQ2Z1pKtn7GD5xXA98lDJID6y3XLzdtoi0GFlD0lgt EkBPsjyYGDRqs0yxvdmh9+o5OCbQRtR8kFNrN+YVvwVhTXvJjYBQ6qi6SAwqK+fgB+bv 91pKOP1wJGrVwryVVp5DGfR5vVz6JLU0Xs5f+Z1Xo4codnhA1YkjjWIBaostQVTwKmUO nZJw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lf26-20020a170907175a00b0073d9b010074si54863ejc.824.2022.09.07.11.27.02; Wed, 07 Sep 2022 11:27:28 -0700 (PDT) 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; 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 S230382AbiIGSG0 (ORCPT + 99 others); Wed, 7 Sep 2022 14:06:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbiIGSGM (ORCPT ); Wed, 7 Sep 2022 14:06:12 -0400 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AB0E77EBD; Wed, 7 Sep 2022 11:06:10 -0700 (PDT) Received: by mail-ot1-f41.google.com with SMTP id 6-20020a9d0106000000b0063963134d04so10807149otu.3; Wed, 07 Sep 2022 11:06:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=cwQcMikn8PY/begH6mMZDx9ENCQa5sG31sOsvQOo7/o=; b=WqQnu6PIEW7n1nUgrcWf63mnUg9vk4d9mU7tffbJbMJb6iLHf+aFoKSxkO2AupGHLQ qkDcxsUkMFAynW7Vbt2xEtMRsk5uGgnxJEsGUPdt1bFmLiVqdW6szF8fdiFDx8r7kJcs 3jrYbtbsBjQg+xkXgW2hw9tBb7iCNJeiubHjLZrXpe5be9mM3F2gKLEZ7buRXdMZ0iBB xTVATKUW1JBBDhHbm6lIhQ65d7C5aYYZ4QyAYid8GqyWyjgW1c+okiJ703A3v1B1xR+P Nt6Fv06HxXsSuxgdvykMsmgo/V4IXHLjbCL2LYiQQ+sLA8fi+50tofpqa1M1hteNFejm HDcw== X-Gm-Message-State: ACgBeo2HyVItHEix/dC8Hc5fmWC/Ql/DV7JHwmfkvN2HxPvo36zStYcV WViJM5xj1/PCOO7qjQXvn5jrDkq62tKarZ1pWhY= X-Received: by 2002:a9d:6f18:0:b0:638:b4aa:a546 with SMTP id n24-20020a9d6f18000000b00638b4aaa546mr1910734otq.124.1662573969481; Wed, 07 Sep 2022 11:06:09 -0700 (PDT) MIME-Version: 1.0 References: <20220907050407.2711513-1-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Wed, 7 Sep 2022 11:05:58 -0700 Message-ID: Subject: Re: [PATCH v2] perf test: Skip sigtrap test on old kernels To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , linux-perf-users , bpf , Marco Elver , Song Liu Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 7, 2022 at 10:50 AM Namhyung Kim wrote: > > On Wed, Sep 7, 2022 at 1:32 AM Jiri Olsa wrote: > > > > On Tue, Sep 06, 2022 at 10:04:07PM -0700, Namhyung Kim wrote: > > > If it runs on an old kernel, perf_event_open would fail because of the > > > new fields sigtrap and sig_data. Just skipping the test could miss an > > > actual bug in the kernel. > > > > > > Let's check BTF if it has the perf_event_attr.sigtrap field. > > > > > > Cc: Marco Elver > > > Cc: Song Liu > > > Signed-off-by: Namhyung Kim > > > --- > > > tools/perf/tests/sigtrap.c | 46 +++++++++++++++++++++++++++++++++++++- > > > 1 file changed, 45 insertions(+), 1 deletion(-) > > > > > > diff --git a/tools/perf/tests/sigtrap.c b/tools/perf/tests/sigtrap.c > > > index e32ece90e164..32f08ce0f2b0 100644 > > > --- a/tools/perf/tests/sigtrap.c > > > +++ b/tools/perf/tests/sigtrap.c > > > @@ -16,6 +16,8 @@ > > > #include > > > #include > > > > > > +#include > > > + > > > #include "cloexec.h" > > > #include "debug.h" > > > #include "event.h" > > > @@ -54,6 +56,42 @@ static struct perf_event_attr make_event_attr(void) > > > return attr; > > > } > > > > > > +static bool attr_has_sigtrap(void) > > > +{ > > > + bool ret = false; > > > + > > > +#ifdef HAVE_BPF_SKEL > > > + > > > + struct btf *btf; > > > + const struct btf_type *t; > > > + const struct btf_member *m; > > > + const char *name; > > > + int i, id; > > > + > > > + /* just assume it doesn't have the field */ > > > + btf = btf__load_vmlinux_btf(); > > > + if (btf == NULL) > > > + return false; > > > + > > > + id = btf__find_by_name_kind(btf, "perf_event_attr", BTF_KIND_STRUCT); > > > + if (id < 0) > > > + goto out; > > > + > > > + t = btf__type_by_id(btf, id); > > > + for (i = 0, m = btf_members(t); i < btf_vlen(t); i++, m++) { > > > + name = btf__name_by_offset(btf, m->name_off); > > > + if (!strcmp(name, "sigtrap")) { > > > + ret = true; > > > + break; > > > + } > > > + } > > > +out: > > > + btf__free(btf); > > > +#endif > > > > would it be easier to call perf_event_open for simple event with > > sigtrap set (and perhaps remove_on_exec) ? perf_copy_attr checks > > on reserved fields > > Hmm.. right. we could do that too. But it might still fail if there's a > bug in the path handling in sigtrap even for the simple case. I'm not > sure if it's a realistic concern though. :) I think we can do that when libbpf is not available. Thanks, Namhyung