Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp103874imn; Fri, 29 Jul 2022 00:46:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uiM2dB4u6yRSAfTdEdDuPQGZ0e9CPXk40ACoETBH9WDhW65NlcRDXKJTLd5UCtl2/BIzYg X-Received: by 2002:a17:906:8456:b0:72b:88c6:a374 with SMTP id e22-20020a170906845600b0072b88c6a374mr1996963ejy.615.1659080778647; Fri, 29 Jul 2022 00:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659080778; cv=none; d=google.com; s=arc-20160816; b=b1SEJ5+b/IMoYD/cFqNn58PC1fTnz8tJMRh2dV/9tP/qPLPNEICdZW16y0RCclEkBW oWzcbzV7ozd96kgcEHsSGs516hCqHff2zet/ATZfbhrUPhN4nO0I9bewP3YgwtHjJt6d XxZ9e7YbsZ0NtcEBLHRLH1M+CdeC/ETN+mbp6b6PiwB3NjATGRbmJcqeMuvosjkpnb1o SRPNpWEoncXc+EwgnZIQCUY9dcyGSRUikgzq7jmbx9NJiFgOllXPSx8Di2a+gcKeS9zP NSVaQxwfi5o3SOU+SZ3UiaFspAVLphgqIceEYhNb+uy2sNfk3KJl9ZDzyGOdh/1F/f2q mkfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=envuPbzzq2H54VKr3RstW6kg8N0kUvXDq8KS/IJYJi4=; b=yBgsPOi+F9QFYgVcmx3aFf07XAP6SmQq1P4HnJz0g/l36FR3iN571rl9wbSjWUYoXc eRIQ04n0FGhNnJyRrzmkdmDybXRijj0JwQppk7cW+khMNeul5f+P1Whj/t86QX2GkFUz dRDpq5AzOA/aW9+KKuNJtb5neJWUaJAf2+88thkgsOkGqSErwsEmtlgPwQSvWC0U3aVd oHz/bCbGCxJyncDo502uSv2XPatv7quLGhZeMK/SASSs16Dkv/l2yt6Y4F5xspkzyGMu fI2ccG3U3A5lxeTEfotKpnR38fskPBWda0qeFgP4zlYS0MAEfv7/lsFkw+4rFA1Xauf9 7hRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=oRwQiy17; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a056402280700b0043c58863a54si3228274ede.461.2022.07.29.00.45.53; Fri, 29 Jul 2022 00:46:18 -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; dkim=pass header.i=@google.com header.s=20210112 header.b=oRwQiy17; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234973AbiG2HoM (ORCPT + 99 others); Fri, 29 Jul 2022 03:44:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234946AbiG2HoI (ORCPT ); Fri, 29 Jul 2022 03:44:08 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD1D37B37E for ; Fri, 29 Jul 2022 00:44:07 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id j4-20020a5b0304000000b00676ba2ed7e9so323155ybp.23 for ; Fri, 29 Jul 2022 00:44:07 -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=envuPbzzq2H54VKr3RstW6kg8N0kUvXDq8KS/IJYJi4=; b=oRwQiy17hOjBg79amu8cXv0HG3YS23fNp9hgX4XS6A3pX3ZvRQVEU3+98y70aFyWbQ 3knxj5i78Ot4CR/NK5LytuHU6ia5SqlDgp4WKLsoyqk2HV3YMNCadVKE0aGhmW9Klgsz WT7Ozg6cYj4AAr5pD4BASrxxeA36XGonvNb4Hq6IA7XLE2uhUtQ3xprXG+MOXXRn+uon wlxC8z6+D640QlNVWRHrAlCeZA0aw3W5TGUUL199sGO8Rg0Ew4PyTFReek2ogfesAZ0f /9zKy6CsSJDOe7vqxxRNl7IBxDDYepJJkVmm77pUlaYFiPC/hDLDPoT5Ub0jRQvocfZg uakA== 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=envuPbzzq2H54VKr3RstW6kg8N0kUvXDq8KS/IJYJi4=; b=rR23rwr9rlE0uNcyNjw7k0ry+9MG54LsgrVqcOD8crcQm5UQsTHmpSzNgbDzNZZIUr 2WBdT+5gcof/Sv98CqhySpE+mCYyQcW5vfgLgYG+pHfrtten5jppzL5gZRQhmljkc8wD AyQnHf9sT5Yqzo0a3Cbbdxhgd8dSdXI2gTJD6cl6l5ZJKKgOkWzOF00W8kUwhGd76xIh m0UNZ0cUCtikHjdMSbmaI/c3ycOrO9iGu/FvIMNyGtJtJzVw3anEjUXQWaKisD3V5KIy N/hqViMAbQzuYCx/C3pS1tM3DZ7az8lIezsXNhY+R2StZslcMTCLR9qlgNzVAncv38VN mwgA== X-Gm-Message-State: ACgBeo3pjd/yKwVEyEDUnuOkTJrcS5qTYah+YIqJcgA3VfcMPZKVb0Q2 8GqEC2HDYM8R7FneePiepbzjpNTYFCCa X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:524b:47b4:2aeb:1b49]) (user=irogers job=sendgmr) by 2002:a25:c1c6:0:b0:66f:5acc:7fb8 with SMTP id r189-20020a25c1c6000000b0066f5acc7fb8mr1570670ybf.634.1659080647103; Fri, 29 Jul 2022 00:44:07 -0700 (PDT) Date: Fri, 29 Jul 2022 00:43:36 -0700 In-Reply-To: <20220729074351.138260-1-irogers@google.com> Message-Id: <20220729074351.138260-3-irogers@google.com> Mime-Version: 1.0 References: <20220729074351.138260-1-irogers@google.com> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog Subject: [PATCH v3 02/17] 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham 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 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 5b72048d50da..cdfa4e0e7557 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -203,7 +203,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): @@ -211,17 +211,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' -- 2.37.1.455.g008518b4e5-goog