Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4148135ybc; Tue, 26 Nov 2019 04:40:50 -0800 (PST) X-Google-Smtp-Source: APXvYqx0mtSfCTE6gMAQLBhosw76StzUk66Qa5l0RFjlfx6D3ShgUo3bnUoNKjj3fybmVJWvIkU7 X-Received: by 2002:a17:906:bfe3:: with SMTP id vr3mr42616222ejb.273.1574772050766; Tue, 26 Nov 2019 04:40:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574772050; cv=none; d=google.com; s=arc-20160816; b=vZPWante1O3y8/7GVn67j4IUlicKJhhAySEwCZFGPiOX00eLKRTjkXF31N2qSYUXRx z8rsy+pKM3rB2b5uBbbslgKU3SPAPQx+dLYZYj5np3w46IQatKRROLYbw+f/Kj9Xl2Mq /ruz8N2FJe96QoR4+z+7g7DbRhlaAjP+SXvfRJV7xY3jXiWmRc1CExmT7kbfeL2rMkam ErrZFfKRWKRJ6Fkd0iOiYMzWQk8GhlOiEFCIKBIFlKraCOPWmjHzVVs7ge4iOFk+UDlZ MkeYh0zI7Q2sXIS2C6WgBDPqvFHxisxIoJqbfcQaXtgseZvRWdPYO/ZodWs/mriuhKwF 3ezA== 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=pTnosggzlLEzQlk7XJCGa1/gKHWOvHYRvRrtWYZ7fnk=; b=VZJUvPiX31BiLX9ir8X3MdZtsQmuwIdeL1pO1mlTDBkYDv/b2VbpITDIfkYx9tLeW3 uXnw6hfSM6A3rT7+w7lVy09fKSaouvfAOw4irEOK0U2MVjMN1l0J2/mJzrCuoeWRAUeQ ug3c9KdAdUgoewsLCAz4KORQLvLztcJSSovStdtJau0gYKoZXrC+o0I5gHpPjTbaJo0E 6haD4j1s+dWZVS1Zaz3iuEicfBKw2KB1AnBAvL5iPW912mUk/LYaaZxgA0OAL5IiBfBC yweY0vZ46Fk5mThyvbNKO0xGAKHvYN7+0h4UcRCEvsTrZXxBSRD4a8MSvy3lZ2Ln7YS2 L9mA== 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 u14si613253edy.375.2019.11.26.04.40.26; Tue, 26 Nov 2019 04:40:50 -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 S1728080AbfKZLVq (ORCPT + 99 others); Tue, 26 Nov 2019 06:21:46 -0500 Received: from mga09.intel.com ([134.134.136.24]:25466 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727218AbfKZLVq (ORCPT ); Tue, 26 Nov 2019 06:21:46 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2019 03:21:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,245,1571727600"; d="scan'208";a="211322433" Received: from linux.intel.com ([10.54.29.200]) by orsmga003.jf.intel.com with ESMTP; 26 Nov 2019 03:21:45 -0800 Received: from [10.125.252.207] (abudanko-mobl.ccr.corp.intel.com [10.125.252.207]) by linux.intel.com (Postfix) with ESMTP id B5117580332; Tue, 26 Nov 2019 03:21:43 -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: <6b2be869-28c1-ae9b-92e8-5ababf143308@linux.intel.com> Organization: Intel Corp. Message-ID: <6f564c52-ffaf-0492-076b-10b752813313@linux.intel.com> Date: Tue, 26 Nov 2019 14:21:42 +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: <6b2be869-28c1-ae9b-92e8-5ababf143308@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 --- Changes in v3: - implemented perf_mmap__print_cpu_mask() function Changes in v2: - capitalized MMAP_CPU_MASK_BYTES() macro --- 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