From patchwork Tue Jun 13 03:39:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 107060 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp282848vqr; Mon, 12 Jun 2023 20:44:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78x89XM/8PerjMCfIZL7guK6DuS7dG2GEpDZ4ICvzkGhG7kKmJxMzFboKax/KqyYTW+JMs X-Received: by 2002:a05:6402:b05:b0:514:8df2:b6e6 with SMTP id bm5-20020a0564020b0500b005148df2b6e6mr6020550edb.15.1686627863224; Mon, 12 Jun 2023 20:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686627863; cv=none; d=google.com; s=arc-20160816; b=bSRE1XToJ+wqDy3JiqIKGL3oeMB39sde0fvp4y0o0/hdEyIwWQAmj2XN3HqUevzh+W X8l1X8shz2Icy7xzxf77YnjrBUAQWMhHqM1h9y0OGulGF080xUvWgKKEvdHeTB8Mbk/b smccjXsH1i1dIgsFcFWC534g5XuVmmu4tQJmqug9576XMvE1mSOqPRsvVG1kcadUY/AB 13jLy/TuUCOo/XND3YTSixQbGXcP+21cdo/k6D9dRmVkGP4jDIu5rlXi3Mx5wApSUcAW 64+hvws4CUXe1I5qUYWOzpzMx9HKHad+RPbC6HQgXMuW9IerlAIdKPDenIHlkeMaSKCF 7jOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=O0LrhnLRbqEUEharnSmOiq1vO/mF0p2PfHnPfcQ/YQg=; b=hMAIGRqajobMz4HV2WNQXsyCB/WCHS/DhgOz5NY4zKRWo8jTHLkQgsQwSoWuJ1EBBj cXrOL9QXUvasOFPhW7ExxaqCGejXevIHgtnrgX6sksbS6Grysr7qYxD7RT1pivWuwuqX st056kzdKsMTKKRnHXJMyjA4OILOTSOhlGEXsdvyIkN1obRsEEI3D0KvwV24+yThiuxR zHJrcSEbZuGPI2+hI3EI66I3mIAetd+W9+bIXZCNcXWP21ML9CbjCJf/jWY9uoByIkwE QrW/r0nvUb+A6aZv8HYIVfcccG6hIfFi8z6Ujoduk7GzdbmVNIn3YvuHquF0kT4BqjM2 FLVA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020aa7ccc6000000b0051497c87452si6366334edt.627.2023.06.12.20.43.59; Mon, 12 Jun 2023 20:44:23 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238931AbjFMDln (ORCPT + 99 others); Mon, 12 Jun 2023 23:41:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235134AbjFMDlc (ORCPT ); Mon, 12 Jun 2023 23:41:32 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1AA2E4A; Mon, 12 Jun 2023 20:41:30 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QgDn04fYYztQSs; Tue, 13 Jun 2023 11:39:00 +0800 (CST) Received: from localhost.localdomain (10.67.174.95) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 13 Jun 2023 11:41:28 +0800 From: Yang Jihong To: , , , , , , , , , , , , CC: Subject: [PATCH RESEND v4 2/4] perf tools: Extend PRINT_ATTRf to support printing of members with a value of 0 Date: Tue, 13 Jun 2023 03:39:44 +0000 Message-ID: <20230613033946.103515-3-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230613033946.103515-1-yangjihong1@huawei.com> References: <20230613033946.103515-1-yangjihong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.95] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768557498402638813?= X-GMAIL-MSGID: =?utf-8?q?1768557498402638813?= When printing attr, members whose value is 0 will not be printed, we want to print the case where attr->type is 0(PERF_TYPE_HARDWARE), add `_a` param to PRINT_ATTRf macro to always print member when it is true No functional change. Signed-off-by: Yang Jihong Acked-by: Adrian Hunter --- tools/perf/util/perf_event_attr_fprintf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/perf_event_attr_fprintf.c b/tools/perf/util/perf_event_attr_fprintf.c index 7e5e7b30510d..433029c6afc5 100644 --- a/tools/perf/util/perf_event_attr_fprintf.c +++ b/tools/perf/util/perf_event_attr_fprintf.c @@ -80,15 +80,15 @@ static void __p_read_format(char *buf, size_t size, u64 value) #define p_branch_sample_type(val) __p_branch_sample_type(buf, BUF_SIZE, val) #define p_read_format(val) __p_read_format(buf, BUF_SIZE, val) -#define PRINT_ATTRn(_n, _f, _p) \ +#define PRINT_ATTRn(_n, _f, _p, _a) \ do { \ - if (attr->_f) { \ + if (_a || attr->_f) { \ _p(attr->_f); \ ret += attr__fprintf(fp, _n, buf, priv);\ } \ } while (0) -#define PRINT_ATTRf(_f, _p) PRINT_ATTRn(#_f, _f, _p) +#define PRINT_ATTRf(_f, _p) PRINT_ATTRn(#_f, _f, _p, false) int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr, attr__fprintf_f attr__fprintf, void *priv) @@ -99,7 +99,7 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr, PRINT_ATTRf(type, p_unsigned); PRINT_ATTRf(size, p_unsigned); PRINT_ATTRf(config, p_hex); - PRINT_ATTRn("{ sample_period, sample_freq }", sample_period, p_unsigned); + PRINT_ATTRn("{ sample_period, sample_freq }", sample_period, p_unsigned, false); PRINT_ATTRf(sample_type, p_sample_type); PRINT_ATTRf(read_format, p_read_format); @@ -141,10 +141,10 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr, PRINT_ATTRf(remove_on_exec, p_unsigned); PRINT_ATTRf(sigtrap, p_unsigned); - PRINT_ATTRn("{ wakeup_events, wakeup_watermark }", wakeup_events, p_unsigned); + PRINT_ATTRn("{ wakeup_events, wakeup_watermark }", wakeup_events, p_unsigned, false); PRINT_ATTRf(bp_type, p_unsigned); - PRINT_ATTRn("{ bp_addr, config1 }", bp_addr, p_hex); - PRINT_ATTRn("{ bp_len, config2 }", bp_len, p_hex); + PRINT_ATTRn("{ bp_addr, config1 }", bp_addr, p_hex, false); + PRINT_ATTRn("{ bp_len, config2 }", bp_len, p_hex, false); PRINT_ATTRf(branch_sample_type, p_branch_sample_type); PRINT_ATTRf(sample_regs_user, p_hex); PRINT_ATTRf(sample_stack_user, p_unsigned);