From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E7E1ECAAA1 for ; Tue, 6 Sep 2022 18:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbiIFSQB (ORCPT ); Tue, 6 Sep 2022 14:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiIFSQA (ORCPT ); Tue, 6 Sep 2022 14:16:00 -0400 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A3D6175B6; Tue, 6 Sep 2022 11:15:59 -0700 (PDT) Received: by mail-ot1-f48.google.com with SMTP id l5-20020a05683004a500b0063707ff8244so8591875otd.12; Tue, 06 Sep 2022 11:15:59 -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=hBUXfmibKdlSbtIrqsYrNBA32p96PcJy+wSALtFh9OU=; b=Z85negoeWIHJovp9PFLXTYVUweNb9ZWtfe+nROqa6aATaJGZzYyoxm9eSl0UfuGxPl 0JTGNGI+uw61ilhPlQ7YkEQ8FRlHkKkvqEisrgnI+uK5HJXn1Gq5exImDdyI+FvzmAbK 0hdqoGieJOsBKb/0+NqATV5bjvBEaRwYFyy26cMESCpkbtiO3E6R4qRGUl7BgzvDWu50 7ek+Mt7a8H3uk6hFqdRVqOtWNPnuDYUB3Yh8WB0+f6mrBQfmAVMqH7u7Tra8e8/f5yQ6 wQPUVugrvoRYXYrDuYyFYxnhRY0+zXIOAGSuC+Mf3GJ6sggFx+kHDahYclFqwjMIFASL yC1w== X-Gm-Message-State: ACgBeo23f/K6fkRaI2lD0vQPGY2FjtXpWq1HEPDpjQjlqqCsDZ6lOHtj LnYfK/gKm5Pe6agvvPlafjYeH+Z9XEZSn0w4DOU= X-Google-Smtp-Source: AA6agR6MdKws1lzVrLIGA+Aqnumnskn2/NeYygL21WuU70r6lfB7AcklD4hFIuqPBtNw86wuQfsjvUIKmtvxiTqi7ZA= X-Received: by 2002:a9d:6f18:0:b0:638:b4aa:a546 with SMTP id n24-20020a9d6f18000000b00638b4aaa546mr21367162otq.124.1662488158396; Tue, 06 Sep 2022 11:15:58 -0700 (PDT) MIME-Version: 1.0 References: <20220901184709.2179309-1-robh@kernel.org> In-Reply-To: From: Namhyung Kim Date: Tue, 6 Sep 2022 11:15:47 -0700 Message-ID: Subject: Re: [PATCH] perf: Ignore format attributes with an unknown perf_event_attr field To: Rob Herring Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , James Clark , linux-perf-users , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org On Fri, Sep 2, 2022 at 8:25 AM Rob Herring wrote: > > On Fri, Sep 2, 2022 at 1:53 AM Namhyung Kim wrote: > > > > Hello, > > > > On Thu, Sep 1, 2022 at 11:55 AM Rob Herring wrote: > > > > > > If the kernel exposes a new perf_event_attr field in a format attr, perf > > > will return an error stating the specified PMU can't be found. For > > > example, a format attr with 'config3:0-63' causes an error if config3 is > > > unknown to perf. This causes a compatibility issue between a newer > > > kernel and an older perf tool. > > > > > > The addition here makes any attr string up to the ':' ignored, but > > > still checks the 'bits' portion. > > > > > > Signed-off-by: Rob Herring > > > --- > > > This is the YACC mud I threw and seems to stick. Maybe there's a better > > > way to handle this. It doesn't seem like there's a way to do wildcards > > > (i.e. config.*) in YACC. > > > > > > This is needed for this series[1]. Unfortunately the best we do to avoid > > > the issue is applying this to stable. I think there's some time before > > > v8.7 h/w is deployed, too. > > > > Maybe you could change the format_term rule to take an identifier instead > > of PP_CONFIG* directly and pass it to perf_pmu__new_format(). Then > > it could check the string and create an appropriate PERF_PMU_FORMAT_VALUE_* > > or ignore it according to the PERF_ATTR_SIZE_VER*. > > That only moves parsing of configN from YACC to strcmp in C. In doing > so, we'd be left with just the 'error' token case which seems a bit > odd (if there's another way to do it, I don't know. yacc is not my > thing). Is that really better? I thought we could do more flexible handling and detailed error reporting in the C code. But it could be done in the lex/yacc as well.. I think the general idea is that we want to run a more recent version of perf tools than the kernel. So if it detects the tool is older, it can show a warning message like: "config3 is not in the perf_event_attr.. skipping. Maybe you're running on a newer kernel. Please upgrade the perf tool." > Unless there is some way to retrieve > the PERF_ATTR_SIZE_VER* from the kernel at runtime? Even if it can retrieve the info at runtime, perf tool might not know how to use the new config term. Thanks, Namhyung