Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp144110pxb; Thu, 17 Feb 2022 00:20:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUx8YUxBwjzJOS9D7/iI1qbOdi184SDiPQWAEk21T8rai8CwUJE2IuqpAl6EgU5PSg2Ze/ X-Received: by 2002:a63:c051:0:b0:372:d4a5:7033 with SMTP id z17-20020a63c051000000b00372d4a57033mr1551709pgi.303.1645086020020; Thu, 17 Feb 2022 00:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645086020; cv=none; d=google.com; s=arc-20160816; b=oOeH4Lx4t8IXTji5Sq8SQOc0y6jxU+WkvNk+MEH3lY0nKjqi4LiDWyYTW5GRMiEHtK Un9tQ+VBP1m8sxNp5tcI+vjB0iCxZGve6G6SFxWxjCWlKJRlqvEQlIx6/1GOEcZhjgYs 2DgQk9XbdwPDhSNIm35Xptr8Mrp1Mkp+83y8xVecaw3qzl29og2Dvh4qBUvbKZTISz/0 xlTVc6sXcWpHw6MDjMhQQCmku5u9ILfCl3jCkmIXVhWOymSyAKKlR+POKcsmqazosAZn zazFPuKtuZ8nvTaDkXu1r1BTHwds7sLwdYSv7Q2AK4vW1oYEQzQVvdBINWdGaSCTTdQY +Rxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=2kY8KfuzZVr0RHlJqdH/WDN5OAPeOUaSYYelNBHdMdA=; b=vdA0lX59y1T2X2QwDMR35KSt3kJyJqpkhncrhOOwW27OLvG59ZJqVOvccSN4GJ/2/X 7AmBv7RkRBVHfPqWXtFRE0mz0+2DK2jLW3zEVWyqfUfpf36y7w/RshFQ4TjBIe4bmzi9 sPQLzHH/Phep6g8dhFDZLIIYxxk7VGzvGnWEZZLckApJlqCpnyynQmKY5XRzHZXbNkX9 PNvhtq1nC+8P6n/cnAtyYSW7RqRgDnahbvpxrrbJHeMR+kdQ9Fjsg7tkxv0WAW1aRKMy 8P3rqdwmqRVSzY2XRbghEjVNID4nFNSmCqBb6AEqy6iamYaijCcA8JpwxeeZdd/i85gs v9nA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17si39188045pfh.111.2022.02.17.00.20.05; Thu, 17 Feb 2022 00:20:19 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230389AbiBQB2C (ORCPT + 99 others); Wed, 16 Feb 2022 20:28:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:37726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230312AbiBQB2B (ORCPT ); Wed, 16 Feb 2022 20:28:01 -0500 Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78769C3C0A for ; Wed, 16 Feb 2022 17:27:47 -0800 (PST) X-QQ-mid: bizesmtp76t1645061254tfsrxxo5 Received: from localhost.localdomain (unknown [58.240.82.166]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 17 Feb 2022 09:27:28 +0800 (CST) X-QQ-SSF: 01400000002000B0E000B00A0000000 X-QQ-FEAT: F3yR32iATbg1yTWtYZrkwc0LvGRXLpKq+G+hKFTKMOMUCscU9D8H9mHRfpnx7 5hWHQqTrCCtrt/DnDGqeqpcC8P0ms+D1H3lSo9P/x05r/8uf+GbE0zIWTUaSjVDdmwV2OMx CkF63pHCkoUnhhnd3TLRssQAF4u3+/k/69I0CnPyCr4bDJOaS2fUpyhO7Qco146itjwdY5x YMifdlTSwZL1nELqEeF2496M/yVydrV/evNa3FIUWF/WjZP/Qe6XsBxJ0Rqg/9Exy8YC0m2 CaKJaQ/DyP5YoFEMuXjpoa+VakimcqYkU2I7OJlfYfS3EHpiLTL4AyXyo4JhcOxAPU8jEF3 byyOY8L X-QQ-GoodBg: 2 From: tangmeng To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org Cc: linux-kernel@vger.kernel.org, tangmeng Subject: [PATCH] perf cpumap: Migrate to libperf cpumap api Date: Thu, 17 Feb 2022 09:27:26 +0800 Message-Id: <20220217012726.27858-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,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 Switch from directly accessing the perf_cpu_map__cpu to using the appropriate libperf API when possible. Using the API simplifies the job of refactoring use of perf_cpu_map__cpu. Signed-off-by: tangmeng --- tools/perf/util/cpumap.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c index 12b2243222b0..986d580d8984 100644 --- a/tools/perf/util/cpumap.c +++ b/tools/perf/util/cpumap.c @@ -508,17 +508,18 @@ size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size) "%s%d", COMMA, map->map[i].cpu); } - } else if (((i - start) != (cpu.cpu - map->map[start].cpu)) || last) { + } else if (((i - start) != (cpu.cpu - perf_cpu_map__cpu(map, start).cpu)) || last) { int end = i - 1; if (start == end) { ret += snprintf(buf + ret, size - ret, "%s%d", COMMA, - map->map[start].cpu); + perf_cpu_map__cpu(map, start).cpu); } else { ret += snprintf(buf + ret, size - ret, "%s%d-%d", COMMA, - map->map[start].cpu, map->map[end].cpu); + perf_cpu_map__cpu(map, start).cpu, + perf_cpu_map__cpu(map, end).cpu); } first = false; start = i; -- 2.20.1