Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp7853291ybc; Fri, 29 Nov 2019 02:06:39 -0800 (PST) X-Google-Smtp-Source: APXvYqzc+Bxs/Ypig9d8EJy/wBAcviwTju5OMtkj34uV+7ZNY8FD8u9APVvLjGqNt1nQsXydSmF6 X-Received: by 2002:a17:907:104a:: with SMTP id oy10mr230104ejb.324.1575021999772; Fri, 29 Nov 2019 02:06:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575021999; cv=none; d=google.com; s=arc-20160816; b=iAQD90cZKvpOl7FdJ7/RfSHUh1ut50yxVxjNPV1bPnPXSYG/ei+6TgJ2O8UJfSseky g9q8Oa3DvfXHhsirEFIkV+ILLy7ARMtclGaf5FPf6w34uNr6AK+q96c65VbqWjUwxBxR ACkRc1xQPwQrnahi4C0gDHOXFq948YFmBBHEf0JT6YcQ+Qrz6EQmNso1H+UWCW+HeiWA /ZlVDAmP+bPf8gQOvP4sgQmWEJpNZWX2J4NI222y35jtA+gU9nISqMkmFOYk/SZwNxfN 3kN/givp2GcGlnK5KF2KSqCd/VbqOCWVNl/aCwTSFAYRi0AGS1K/bQKtsZtJDgAc1OCR mLEQ== 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=5jj8WKN+dobz9JHqNWKLqK8tY0Km6sQZT1OwfvL1q8k=; b=RdDJMFDx4IOWLi8iExfaH0Rna+hsreknjZKKEd0aqNtt7QNeAbJv7kKO7ja56W/H+I m+EUcs8jg25uwJSF8ZuIiX1rSHXCi1ZzKXV1F+pj+PcgatQQ8uohuLpevzh0C38rIna+ f5hmlnA9U9zilRx5ep0YVSwTv5cFQSAUX/5Iyh9HQriYyNT3M/06DCE7mlrWu0S8Coej WeTO4zHK+p6+LL1XoQWvs5/KAl2Yt38/Z3p/8+UynfiGqXvq3qAJfYeil7I7lWLYBPWV pmb/266qEtmOm58Qf6uuJdQ2xtc3VpEA48mMX2sggan6h35i1SxRESYvWHmkXMJVp68/ 8rtA== 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 f4si4907375ejd.306.2019.11.29.02.06.14; Fri, 29 Nov 2019 02:06:39 -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 S1726926AbfK2KEr (ORCPT + 99 others); Fri, 29 Nov 2019 05:04:47 -0500 Received: from mga04.intel.com ([192.55.52.120]:54513 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726822AbfK2KEr (ORCPT ); Fri, 29 Nov 2019 05:04:47 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Nov 2019 02:04:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,257,1571727600"; d="scan'208";a="240995372" Received: from linux.intel.com ([10.54.29.200]) by fmsmga002.fm.intel.com with ESMTP; 29 Nov 2019 02:04:41 -0800 Received: from [10.125.252.110] (abudanko-mobl.ccr.corp.intel.com [10.125.252.110]) by linux.intel.com (Postfix) with ESMTP id 1EA5E5802B9; Fri, 29 Nov 2019 02:04:38 -0800 (PST) Subject: [PATCH v3 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: <908dbe98-7d8d-0ec1-d4ae-242f3e104979@linux.intel.com> Organization: Intel Corp. Message-ID: <446c4345-cb20-d0ad-3b3d-b34683b1c1e0@linux.intel.com> Date: Fri, 29 Nov 2019 13:04:37 +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: <908dbe98-7d8d-0ec1-d4ae-242f3e104979@linux.intel.com> 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. perf_mmap__print_cpu_mask() 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..30ff7aef06f2 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 perf_mmap__print_cpu_mask(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..598e2def8a48 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 perf_mmap__print_cpu_mask(struct mmap_cpu_mask *mask, const char *tag); + #endif /*__PERF_MMAP_H */ -- 2.20.1