From patchwork Thu Jul 28 22:28:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 12931770 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E93DFC3F6B0 for ; Thu, 28 Jul 2022 22:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3a+4imVmSc9a1LXj3guu26ugigg+g0YVMfB6rM0yvhs=; b=a1Rc6RHzMPQqnRKoRF5/Q1I01D Z0JIrSgGRklOj3f9BeUl8w+ZMjwrN5N4eLncuajY+I3k64xoo+cSO8H6JTlbW40pFRRg/AMHgPsyu pQb1dkWx+VAgtUFXHfsi2UuGIVXhq6QHrZCiO8fw5Gv/APCHahTgn+dZ2BTDND5hrcIrKBlFBCPXQ kO6LUEe2oNByNxrtSRIXILr2HKdaxxWaGi/hNUkL88+1RV5bMi+Nb8PgID7KfTs8MK3Zx9HBtuQ8D 6NdnnsSPp4HYzpGeh/LCrkXO4nVS1S/abqyD1DjpJBHYSmDdFaMqYV7pwwFJl5sk9ZIaxqaWW9/X5 RTDFo26A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHC05-00FXqe-6J; Thu, 28 Jul 2022 22:29:01 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHBzt-00FXjw-3Z for linux-arm-kernel@lists.infradead.org; Thu, 28 Jul 2022 22:28:50 +0000 Received: by mail-yb1-xb49.google.com with SMTP id m123-20020a253f81000000b0066ff6484995so2526027yba.22 for ; Thu, 28 Jul 2022 15:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=4CGZU2uXLK2PaSFFyA3tf8AhfXerOJKdJKDdzQ2mdzo=; b=rt9iHBCL7xMr3W3MRZIdaADzrku9O2jgBaSOcgOi/UTMnhZwax0EHSOb3oPQb8gbJQ Ii3vgw5sKkAvuMKgZ/WAShLFNn47fgl4EX7x5+bqLUDVOUUKewDd20tSAbatPnufhtz/ 828fNy5tRx8m06i/LCli1UI8z4lsOhzavOgzlBdRfHDY45+MCSXGTfOYnnPzZvKYu2R1 ML6O7ihLQTVwmqqADtcNkpOkyapfSTOlniyV35y2L2+RkJwP3D7AmBF1PiM/ZusaJTpR 0nn+uoX3hqKrL6xbBnYuchWF1KcHcpcSwS1Rg0nhzuQxqt7Lp3TkFlYl/sTB8997eces xNAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=4CGZU2uXLK2PaSFFyA3tf8AhfXerOJKdJKDdzQ2mdzo=; b=wpIPO4iJbTyHpLJAfCq213fvPorf2rDCv3HBdOdAip4kwDH5O+dvK5qM/nOKJTP/Yp DeAfRdI3gcJlBLn2OhFBS+FRaoQnC/HjHUYbLJBW9WYQztgJzT6snw8+QJK+z69nc/Mr 5E4ebBrceiWU3MLnHUG0e1ZMS3OFTQD97A6hZ+eUxef/y96Ce3QpkybE42Fm5vJIFGWb PKBekjE0EAZGncvDI5x+JUfVHMnGyYsI6A9YSv1aZln1Vbpf0h5aA9PpJva6+Tx47OEg rN4TQYnfqfRPuoWd9TSKZr1Aii1nnspPz6pY9UoOgrrgF9zxfwxRX/l1oC3iI/HIgviO e0LA== X-Gm-Message-State: ACgBeo1BzU5w/O+tUTlvT4vJq9yzDTZQIQCOq/vQJ2Ki4OlXb8e39i+D y9lSQj+nf23nHfLEfqedaWgnVuG4CCZA X-Google-Smtp-Source: AA6agR4pWuBlW9OnSQ4efp0vs53qzV+bMc5K6Weiu7sE8G5p1bG9y2QvXnG2YyKhxfRMmVG2Lv0ZP2IYOUon X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:fd09:96c3:28af:b08f]) (user=irogers job=sendgmr) by 2002:a05:6902:124c:b0:66e:d96f:2661 with SMTP id t12-20020a056902124c00b0066ed96f2661mr625180ybu.499.1659047322277; Thu, 28 Jul 2022 15:28:42 -0700 (PDT) Date: Thu, 28 Jul 2022 15:28:20 -0700 In-Reply-To: <20220728222835.3254224-1-irogers@google.com> Message-Id: <20220728222835.3254224-2-irogers@google.com> Mime-Version: 1.0 References: <20220728222835.3254224-1-irogers@google.com> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog Subject: [PATCH v2 01/16] perf jevents: Simplify generation of C-string From: Ian Rogers To: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andi Kleen , Zhengjun Xing , Ravi Bangoria , Kan Liang , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org Cc: Stephane Eranian , Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220728_152849_176886_36E2A18A X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Previous implementation wanted variable order and '(null)' string output to match the C implementation. The '(null)' string output was a quirk/bug and so there is no need to carry it forward. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/jevents.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 83e0dcbeac9a..4a170f23bd67 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -204,7 +204,7 @@ class JsonEvent: """Representation of the event as a C struct initializer.""" def attr_string(attr: str, value: str) -> str: - return '\t.%s = \"%s\",\n' % (attr, value) + return f'\t.{attr} = \"{value}\",\n' def str_if_present(self, attr: str) -> str: if not getattr(self, attr): @@ -212,17 +212,11 @@ class JsonEvent: return attr_string(attr, getattr(self, attr)) s = '{\n' - for attr in ['name', 'event']: - s += str_if_present(self, attr) - if self.desc is not None: - s += attr_string('desc', self.desc) - else: - s += attr_string('desc', '(null)') - s += str_if_present(self, 'compat') s += f'\t.topic = "{topic_local}",\n' for attr in [ - 'long_desc', 'pmu', 'unit', 'perpkg', 'aggr_mode', 'metric_expr', - 'metric_name', 'metric_group', 'deprecated', 'metric_constraint' + 'aggr_mode', 'compat', 'deprecated', 'desc', 'event', 'long_desc', + 'metric_constraint', 'metric_expr', 'metric_group', 'metric_name', + 'name', 'perpkg', 'pmu', 'unit' ]: s += str_if_present(self, attr) s += '},\n'