Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp8258014ybc; Fri, 29 Nov 2019 07:45:25 -0800 (PST) X-Google-Smtp-Source: APXvYqzOyA54rfVny4zsHoMrKo5oS5vCkidlpWmT9H4LwmRbaHsHxcRHERsFV0+iPIR1UpbPs0G2 X-Received: by 2002:a17:906:138d:: with SMTP id f13mr7117399ejc.252.1575042325133; Fri, 29 Nov 2019 07:45:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575042325; cv=none; d=google.com; s=arc-20160816; b=mlY5yYQwSfGM5XM+5UKlwkUBieIxJxZRLBOi8ekiqfUyQA3/spXVRmfw3W3jWIwCFH 3S8z9iNWAC+mO4twhqQk0FuwEloHZu0yaJEKWE2kVq9aAxRbR8IKmbNyBEW5qfjNhqRn HXzneD/L5/Y0S/K0JI80DYAKkq5vELEwg9WmhW9fOLjwnye2ethq/GpMw8lUAuz8cppn 9M2d+ZWjM0KsMRsngy2w+Xaj3s9LIU+Q5l9XPs71eK4ej7Lf5xfQAaNQpTKhZ/g6/91v smNJjDkX3zjgkYj+ufPBvWWtNP2UsTEnG4J2x7/Pj3OvQ2sXwAWEoZ686e2Sl9tzsjAC SCIg== 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:from:references:cc:to:subject; bh=20MKVffnv5ZJ3TfMk6/Utdk/vpOxfykWDCvsVk8wJwE=; b=B+dDZnRoNCjBhB/7UEFXKee0hPHdG6Z/nMrmHVwsH1XoWBuwCb/7M9CUUvhfJ5p9uN 8KgCMbWPtxJDVpTbDgWnaFFgMlxXSjtJIvygAM+3ChCqr2J13BneasB5lC2Yaplfr+JF dNdgkPwcVy/qM+wDGeYd91BldHU7CKQSo6cPettywG73w+VxkjbguS7k818mhN4nIlVV wskv18Df7YIqgxipd5BOqKNaK00YcivQUZ7E4f4zQglOaZzmc7NzO4FPeR0Cn/JXVpDT 6dy96m/agESOF9iu5SQ3gNbol3CJHXKsmEbP6h0mOBwbfSxPkowu91YggbWQZqGLsfBX vUlg== 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 qw23si14122495ejb.1.2019.11.29.07.45.00; Fri, 29 Nov 2019 07:45:25 -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 S1726950AbfK2Pnl (ORCPT + 99 others); Fri, 29 Nov 2019 10:43:41 -0500 Received: from mga04.intel.com ([192.55.52.120]:9295 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726917AbfK2Pnl (ORCPT ); Fri, 29 Nov 2019 10:43:41 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Nov 2019 07:43:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,257,1571727600"; d="scan'208";a="234741289" Received: from linux.intel.com ([10.54.29.200]) by fmsmga004.fm.intel.com with ESMTP; 29 Nov 2019 07:43:40 -0800 Received: from [10.252.8.148] (abudanko-mobl.ccr.corp.intel.com [10.252.8.148]) by linux.intel.com (Postfix) with ESMTP id 64FD85802B9; Fri, 29 Nov 2019 07:43:37 -0800 (PST) Subject: Re: [PATCH v3 2/3] perf mmap: declare type for cpu mask of arbitrary length To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <908dbe98-7d8d-0ec1-d4ae-242f3e104979@linux.intel.com> <446c4345-cb20-d0ad-3b3d-b34683b1c1e0@linux.intel.com> <20191129130946.GC14169@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: <6dfdfba5-88b7-067b-855b-8f5f7bbc8043@linux.intel.com> Date: Fri, 29 Nov 2019 18:43:35 +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: <20191129130946.GC14169@krava> 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 On 29.11.2019 16:09, Jiri Olsa wrote: > On Fri, Nov 29, 2019 at 01:04:37PM +0300, Alexey Budankov wrote: >> >> 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) > > 'mmap_cpu_mask__scnprintf' name follows the name logic we try to use Renamed in v4. Thanks, Alexey > > jirka > >> +{ >> + 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 >> > >