Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1219559ybl; Tue, 3 Dec 2019 03:46:20 -0800 (PST) X-Google-Smtp-Source: APXvYqz6k0YzBd40EW5BClkdG6l1AHvKQ3kX5sg4iQhFh3y5Bq14BaD0lpNte3UIM+2ZIOplYH7X X-Received: by 2002:a9d:6d10:: with SMTP id o16mr2904156otp.28.1575373580622; Tue, 03 Dec 2019 03:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575373580; cv=none; d=google.com; s=arc-20160816; b=tb253dKhpHDEM1sewrfqHb0JUMQWO2A5I6hbLRZa7FFa2fHA0/MWlvCSmkTr8o4tsW jejTA7Xq7FMCZ0e/OvTUH1HLm6Yg+1MEnr8egrnPMceGvvifYg4S6gDp8O9G7R2/foYQ WCBzy7sL2jwSDKamUrY34zVHToUu0levEqBMrN0bpwFSn7JCxEJLOrQyY7oSJgPBXgPE pc1pXW5nBFyO8SzSBWeaY9hbP9CNi7g7INr/p1b7+Hzwf8+4yNJGSgd8FUJKCXnQWk+y rZbXMjhZ/zwpaFBhT7QykLd/gIU2JIZXGvXKVqDnoXU3gsqaj0cJWJ8Q1eKlssY+2S/L kHrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:cc:to:from:subject; bh=29JwMqIOPMhAKuIlXgpmdRPQuz7bNwmwaFJX0A9A6Rc=; b=HD/96Z1suB4J9xS30CnCtP7W4XUD8l6sNxKymN6yh43WXCGbcZJfOATxRcXIk7WWBc NQVXWb2qXJGA3Qd90pplVQRWlQfNndUQA6X/nxxu3h36O+Xj396XdVsRxZUmrYiYDx6w v/7KCEojf0klT06DF8nM76IS1I6vd2KDakmE69RwwNDPROWXbS7ZsrlhFP/dbsaxFQ4H iohBSfQkfn/44R7mTn+7J78JoSktdA45NNv5XUTXBLRxeMsiOmANOlsDpf8C2oYZ3Tf5 nXFPW8KBHT9DHZAvqADTqTn91Tog0GMyg6InrYPkwfpkJ5Z3KrB7dkX7y7CkrKpyYJkb U95A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f60si1108546otf.119.2019.12.03.03.46.07; Tue, 03 Dec 2019 03:46:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726114AbfLCLoX (ORCPT + 99 others); Tue, 3 Dec 2019 06:44:23 -0500 Received: from mga18.intel.com ([134.134.136.126]:26897 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbfLCLoX (ORCPT ); Tue, 3 Dec 2019 06:44:23 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Dec 2019 03:44:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,273,1571727600"; d="scan'208";a="213382483" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 03 Dec 2019 03:44:22 -0800 Received: from [10.125.253.16] (abudanko-mobl.ccr.corp.intel.com [10.125.253.16]) by linux.intel.com (Postfix) with ESMTP id 5738358049B; Tue, 3 Dec 2019 03:44:19 -0800 (PST) Subject: [PATCH v5 2/3] perf mmap: declare type for cpu mask of arbitrary length From: Alexey Budankov To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: Organization: Intel Corp. Message-ID: <0fd2454f-477f-d15a-f4ee-79bcbd2585ff@linux.intel.com> Date: Tue, 3 Dec 2019 14:44:18 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Declare a dedicated struct map_cpu_mask type for cpu masks of arbitrary length. Mask is available thru bits pointer and the mask length is kept in nbits field. MMAP_CPU_MASK_BYTES() macro returns mask storage size in bytes. mmap_cpu_mask__scnprintf() function can be used to log text representation of the mask. Signed-off-by: Alexey Budankov --- tools/perf/util/mmap.c | 12 ++++++++++++ tools/perf/util/mmap.h | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index 063d1b93c53d..43c12b4a3e17 100644 --- a/tools/perf/util/mmap.c +++ b/tools/perf/util/mmap.c @@ -23,6 +23,18 @@ #include "mmap.h" #include "../perf.h" #include /* page_size */ +#include + +#define MASK_SIZE 1023 +void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag) +{ + char buf[MASK_SIZE + 1]; + size_t len; + + len = bitmap_scnprintf(mask->bits, mask->nbits, buf, MASK_SIZE); + buf[len] = '\0'; + pr_debug("%p: %s mask[%ld]: %s\n", mask, tag, mask->nbits, buf); +} size_t mmap__mmap_len(struct mmap *map) { diff --git a/tools/perf/util/mmap.h b/tools/perf/util/mmap.h index bee4e83f7109..ef51667fabcb 100644 --- a/tools/perf/util/mmap.h +++ b/tools/perf/util/mmap.h @@ -15,6 +15,15 @@ #include "event.h" struct aiocb; + +struct mmap_cpu_mask { + unsigned long *bits; + size_t nbits; +}; + +#define MMAP_CPU_MASK_BYTES(m) \ + (BITS_TO_LONGS(((struct mmap_cpu_mask *)m)->nbits) * sizeof(unsigned long)) + /** * struct mmap - perf's ring buffer mmap details * @@ -52,4 +61,6 @@ int perf_mmap__push(struct mmap *md, void *to, size_t mmap__mmap_len(struct mmap *map); +void mmap_cpu_mask__scnprintf(struct mmap_cpu_mask *mask, const char *tag); + #endif /*__PERF_MMAP_H */ -- 2.20.1