Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp260128rwd; Tue, 16 May 2023 00:12:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/DszuEF/c0UToq3tP47F+Gkl532Rb7NBJG1DlfG/JvTEBkfglewjaaxqMWjNSgTmHCWNp X-Received: by 2002:a17:90b:30ca:b0:24e:3c23:9654 with SMTP id hi10-20020a17090b30ca00b0024e3c239654mr36450891pjb.44.1684221170874; Tue, 16 May 2023 00:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684221170; cv=none; d=google.com; s=arc-20160816; b=VfbvsIB36ISgYBCwmjY+4vUYMsRbJUq5Z93iC7uTD24wfiSmYgxznKYbFOqFSl1l2y gZ39bjoEcheyong2tIceE7jlonivDW0CMlxDZDyI2QBEw1rJTnTnUv9WU8A9RfPC3/TK D7weifssDTrZ1atdnIbpsfQgvPt9dUADOEjR9qvKyzH1//kEL94mL8dqX9od4sB7Pgos NCGyaMpTjqT7UPgEVGjJZCx6Rcx3qWdWUYfjobAT5MoYZjyP7ZuokZgLSOKZvguDjlEc 0FvqqJs1QrR95OfAa+65p3OAUhZEW5bTnAEGDOAtGsneJY6JE74WjGMs5hq1K074KBaX CPmQ== 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=uciQYfZPjlhf35CvTHiwd7Z3cqHbuPLaLSw9CnhyLqo=; b=uER+pXAjE8zvTNZdYKuTr+KgS2nef2bZGEaXFmaL1T7xA1HWxHMNNO3PcQ9rKCK4VD FR23rs8HNTZaOHNAOG9B3+qX20shYAWmQA2BWVdRxN6MDtsnd8oDk6FXhDHyTk1x1mst vzq5L9QKzgomNNTeSfuVNTanfGH528AcON129zBLzdf08F+wNs3rUKkbH9a+RExwgljR crD+pO498B397xx8EgHX32egH9JJUAHpdekJO8pGmu2AKEwkWgELWl2YOUh0w4/Sbx7C xRk9CkLLhOVm0S/c5Cpy2TRiJ0ekuSmjv/R142AeIxjWH4KEDGbtoxi7uAJHr5j2WNSj QGHw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c15-20020a17090a4d0f00b0024e39c638d1si1135652pjg.77.2023.05.16.00.12.36; Tue, 16 May 2023 00:12:50 -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 S230385AbjEPG5m (ORCPT + 99 others); Tue, 16 May 2023 02:57:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230263AbjEPG5e (ORCPT ); Tue, 16 May 2023 02:57:34 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5066E469E; Mon, 15 May 2023 23:57:17 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QL6RL2yRjzLpq3; Tue, 16 May 2023 14:54:22 +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, 16 May 2023 14:57:14 +0800 From: Yang Jihong To: , , , , , , , , , , , , CC: Subject: [PATCH v4 2/4] perf tools: Extend PRINT_ATTRf to support printing of members with a value of 0 Date: Tue, 16 May 2023 06:55:36 +0000 Message-ID: <20230516065538.83021-3-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230516065538.83021-1-yangjihong1@huawei.com> References: <20230516065538.83021-1-yangjihong1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.95] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 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 --- 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); -- 2.30.GIT