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 F0A03ECAAD3 for ; Fri, 9 Sep 2022 20:11:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbiIIULr (ORCPT ); Fri, 9 Sep 2022 16:11:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231376AbiIIULp (ORCPT ); Fri, 9 Sep 2022 16:11:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48C52FA6B0; Fri, 9 Sep 2022 13:11:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BF6C6620D0; Fri, 9 Sep 2022 20:11:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B96CC43143; Fri, 9 Sep 2022 20:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662754293; bh=ZyQHJST4ZVIaWfwjlZdDoC0RmIGVsAQzzbsyYCsIjzY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NEYXGoAYq21lDKwDdvGnTwFocggaCXRncKksiBW0ElR+445tBAuHbCnFkys96WBgb n5g5mgyEX1MAe0RGuhsyhF9yJhyOSQP8tELw3ZFxzUgQg3Je6FQa4sJRQuAAfep6KO 1yXtvXbjkYRtmIlO8I5XxyZVkkmkFZI0cE9e23klaHchrsmMBDlA+1MqaP8YhgEI/C /w0+c87iyajvS9Ktm1ic+uFyj70FLDGlXXax+zFF0TN2mojlx+2QLn+0ANjjyrzb/k cHZdlw2OO2xP5VTgG4xii4Py5cVVzD5Xh0yWWLWjCuTlbMSq4PLF6GHB5V8H/TwOKz 3aaHgwUIO7GDQ== Received: by mail-ua1-f52.google.com with SMTP id e3so1037240uax.4; Fri, 09 Sep 2022 13:11:33 -0700 (PDT) X-Gm-Message-State: ACgBeo232zhG8yVkUs9UvliDwul/NKwD+8+an/HVyTrP3xYK2lkjtVDQ YoCvMvmDmDcuW80SFyOvFIuMAxug9RCSCo5Gtw== X-Google-Smtp-Source: AA6agR7L8BM4EqH0EFc6zhZyM8oNIMUSoBkdc9sv4+SucH0wffHiTzgWrqGNnHw0j7SWKRWe8l8KG5ubScvJYzwjCs8= X-Received: by 2002:ab0:4467:0:b0:39f:52ec:46d7 with SMTP id m94-20020ab04467000000b0039f52ec46d7mr5492127uam.77.1662754292043; Fri, 09 Sep 2022 13:11:32 -0700 (PDT) MIME-Version: 1.0 References: <20220901184709.2179309-1-robh@kernel.org> In-Reply-To: From: Rob Herring Date: Fri, 9 Sep 2022 15:11:20 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] perf: Ignore format attributes with an unknown perf_event_attr field To: Namhyung Kim 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 Tue, Sep 6, 2022 at 1:16 PM Namhyung Kim wrote: > > 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." I figured out how to simplify the yacc code and add a warning. However, one thing to note is that we'll always get the warning if any PMU has an unsupported format attr because all the PMUs are scanned. For example, just this gives a warning even though the SPE PMU is not used: perf record -e cycles -- true So the warning might be misleading. On the flip side, new additions are rare. Rob