From patchwork Fri Jun 23 05:44:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Jihong X-Patchwork-Id: 111932 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5553067vqr; Thu, 22 Jun 2023 22:52:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4DnJ026aDq2nPIvvZZGmXlx0LPuOZWRelCVoeZ1nZPXcv3SrMr23G/HASDZ0whOAHTP/n9 X-Received: by 2002:a17:90b:118a:b0:258:c89e:b137 with SMTP id gk10-20020a17090b118a00b00258c89eb137mr19652535pjb.14.1687499564077; Thu, 22 Jun 2023 22:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687499564; cv=none; d=google.com; s=arc-20160816; b=iKXln+55ZbLc9j8bMvC6MyVBU0XQYB6Ch5W7WuDGy849vQ7Je0WWYTNwD8d/Fpxdug nxednSkUtcT0I6rbJQ75SvcYG/Y/EV3XXqfACWWfkzr8RspEcEzY9u8SiIpOP8xBQE7A yL/0ctIsCKO3oSOTV0oMkUE2snysD1PGqL9eWtSCmsKWNjBEka8YeNCziGVRFElsyMa0 8M16A3HrbEFQb+bciaDCUI3whk4LPset/mbACM1gtmdodWWuFIhblXIM1uNWhIGe3YBn klNGy2btareXcf+KMRnYLPrDMT7JuUxfbhlKqkdZ+QGJKT6x7Uh/qanrUVrQ5ey2CH8b KCKQ== 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=isIhR1LJxiygwfBASM1AtHwTGAqqU86EN/1CTrS8KpfoWf/o5ebWZGJM1X727Q8Sof AeIoW9n9Qx8O+RylufWYbMbyXyDCVzI2bvUvxad7O5KDmJ5Gyqkc8l9UK8KFE1uXKHGl oGWokS92l/PzNT414+5dzsPbKERwXopxKP6RG2HVrIu9pdQk9W8U8Vw+Yz5VVMUm6249 iizFY3D4EeTE/aINvOmrnix/25/A7k0UdeDWJMtRPVUBZufePWG4sVm6uzeR+V2wZtwe 2sK7GZF5N5CR1BpDvnKplLQIN7v/maN0NHo2aBKrKaFksMM7s8FRB3IgCM5XkpMve+2E jA5Q== 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 mv13-20020a17090b198d00b00260a7aee61asi1188833pjb.155.2023.06.22.22.52.30; Thu, 22 Jun 2023 22:52:44 -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 S231477AbjFWFqy (ORCPT + 99 others); Fri, 23 Jun 2023 01:46:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230010AbjFWFqw (ORCPT ); Fri, 23 Jun 2023 01:46:52 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F15AA26B7; Thu, 22 Jun 2023 22:46:16 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QnR425MhLztQnS; Fri, 23 Jun 2023 13:43:30 +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.27; Fri, 23 Jun 2023 13:46:09 +0800 From: Yang Jihong To: , , , , , , , , , , , , CC: Subject: [PATCH v5 2/4] perf tools: Extend PRINT_ATTRf to support printing of members with a value of 0 Date: Fri, 23 Jun 2023 05:44:14 +0000 Message-ID: <20230623054416.160858-3-yangjihong1@huawei.com> X-Mailer: git-send-email 2.30.GIT In-Reply-To: <20230623054416.160858-1-yangjihong1@huawei.com> References: <20230623054416.160858-1-yangjihong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.95] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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?1769471542930659076?= X-GMAIL-MSGID: =?utf-8?q?1769471542930659076?= 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);