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 F1C01ECAAD3 for ; Fri, 9 Sep 2022 20:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232149AbiIIUbK (ORCPT ); Fri, 9 Sep 2022 16:31:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232154AbiIIUaT (ORCPT ); Fri, 9 Sep 2022 16:30:19 -0400 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7CC33CBC1; Fri, 9 Sep 2022 13:30:14 -0700 (PDT) Received: by mail-ed1-f46.google.com with SMTP id b16so4231735edd.4; Fri, 09 Sep 2022 13:30:14 -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=kpEcg4wYbPXSLUksqLgqfaDecUEI9K/L7cnxAiNm308=; b=0KvHL1XTK8Ip/MxFjGAxHWC5hwgC29eTgOwGiAP8ZoieD04DAeYCJ73Y7fJqZV8VIE pPSPP1Sze1JQx3uElCXNbJKipGq1eaP4J00z8GeM2bh8PlVRKFJ5CR+XJyKvtv1w2vfo yL/eaCqbwpVwbLPDEuvmIHyR9uqzyG4iE3x2d1k2r+p07xQqBF8P1f92izbbq3oUJe8q hERJcaRfeNKlrBo3A/ZM4vK9gfK0P4vwTHSNWyETk52MLZqNrx5UgWhs2way4TM+B8Km CCmNlf3kX6Itt6e1/IsSxqqTYIkTQBmMO4YN846nxUey6DyDLC4PqfJgelc/SHjkKWke 9zqQ== X-Gm-Message-State: ACgBeo3Y5PMaJ9jsedplmrukGj0wzV0WlyCVOTvZMdkeT0obcVWHAR1k E+t1/t/RQiliDS3+DJfM64CGnKgKF2RIFHm7GE14Nzu7 X-Google-Smtp-Source: AA6agR5k1e7Sf8b0Ne7PPtH0lpIFZpZ2n0V3pRe0lMeNNgLcoX3mjLwQkMGyX1uOFkhEXiiwavJRe6aSzpqWaIE+El4= X-Received: by 2002:a05:6402:f07:b0:450:bf95:59e9 with SMTP id i7-20020a0564020f0700b00450bf9559e9mr7941898eda.46.1662755413210; Fri, 09 Sep 2022 13:30:13 -0700 (PDT) MIME-Version: 1.0 References: <20220901184709.2179309-1-robh@kernel.org> In-Reply-To: From: Namhyung Kim Date: Fri, 9 Sep 2022 13:30:01 -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 9, 2022 at 1:11 PM Rob Herring wrote: > > 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. Right, I think we need to change this behavior. > 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. Yeah, we should not warn at parsing, do when it's actually used. Thanks, Namhyung