Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1203179ybl; Sun, 1 Dec 2019 23:01:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxaJUih58ti1+94yQTm6TrGlpWlMO5HJefG1OzDmAknAbL3h0DQ2ntVcDrYjOgrYYaXR1G2 X-Received: by 2002:a17:906:da1d:: with SMTP id fi29mr20941387ejb.205.1575270118432; Sun, 01 Dec 2019 23:01:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575270118; cv=none; d=google.com; s=arc-20160816; b=q/x33jpaDAaKnHRGfJW3PU/xY/qpM9/uTZa2J3dvd5dLAxYAoJUSSP8vY0tfegwS6M u4xefgAWOHHM/pzXOdHHQEFwpKpnHtM0ejFiJW/+xYCRoXBWfV7v5XhldGDlS+672Nk+ 7fYaYhh6nlbwO1pFnCRdxGz39qwMLgzAURKT5Qf+gAc1GPj5kGHFsFkTMhMDKHaott0h AdtGCiG4gF3y+7+xBKYdAzh+DdCFf6Bgi79u9axzQ0KXjRwHTNnqs+wFyhIK1vBXFAcO wj0j26hdr/HyQMjIIC86fH4mzVoG46IunUR80ISch17J5UbtHLZrsbZQHlmGkacKTCpq 038A== 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=DNMGlGvUFxJa1DaZW390+gCWDxOf3Dfa3nsAQBeUmZpA4PQfO4yLYjrT4+SCVA/F+I pClVc+YjhP0j1VtJyKdydh0PLR16J9u/8ujjrC+sYZdH6cbsCJfsP9TDaQAmrbf5Oo5b RXsHAerU5iiVxMJt29lhl0PHJZzRQhbibZjwmIC20S7/kapnte2UUmEY589PqRuaIfQf J/2S/V+ZhD7eemfzyv9JzXEyibMXhTaCad9dU+K3CHiB0QwVDt1/epUd5tpSivUWcxN6 6qeH+eeU+6LEw056MZXOcosCI/pqfwMtYJltlCI9FzaQUDdeu8clrCbXMQ+AkPAtHzQl o9tQ== 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 m33si21655521edc.126.2019.12.01.23.01.34; Sun, 01 Dec 2019 23:01:58 -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 S1726557AbfLBG6K (ORCPT + 99 others); Mon, 2 Dec 2019 01:58:10 -0500 Received: from mga05.intel.com ([192.55.52.43]:37396 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbfLBG6K (ORCPT ); Mon, 2 Dec 2019 01:58:10 -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 fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Dec 2019 22:58:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,268,1571727600"; d="scan'208";a="241825632" Received: from linux.intel.com ([10.54.29.200]) by fmsmga002.fm.intel.com with ESMTP; 01 Dec 2019 22:58:10 -0800 Received: from [10.252.19.98] (abudanko-mobl.ccr.corp.intel.com [10.252.19.98]) by linux.intel.com (Postfix) with ESMTP id 2E4CC580127; Sun, 1 Dec 2019 22:58:06 -0800 (PST) Subject: [PATCH v4 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: <4fbe64e4-0607-e4ad-5309-b54114eb438b@linux.intel.com> Date: Mon, 2 Dec 2019 09:58:05 +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