Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp8069145ybc; Fri, 29 Nov 2019 05:12:54 -0800 (PST) X-Google-Smtp-Source: APXvYqx3QKI29bPUjoC11VNUD+vCNZ34iSa7K7cFnfsF6nVGdLzOb3n7oEnCtetIHjcsv1jGf6Xb X-Received: by 2002:a17:906:a2d0:: with SMTP id by16mr12554755ejb.322.1575033173822; Fri, 29 Nov 2019 05:12:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575033173; cv=none; d=google.com; s=arc-20160816; b=swKr1v26GpTJvf5UFY3/ghhguV/KeZYyWJx5I9Nw0ZzOU7RP6CI3vpDx9qyR3qKYlj yGm+knz2DcOXiUIJSo1B7BEKko25PJKbOjnor7jI3Qv+GoeCw4r9aZJ6i8VvWOGqb1W0 NB3uf7GdPn4vMkgPJAQYIqUX/C5mLaBAoWQl3rs7loz+1XP/w64jUKiIuAb6UllNegl3 siUcofCnNlVQaiDsdj9M//uPh8NpovvPOhdRwH/FbQ6e69eB8rbtTXYXcpTD8MQIG1lX 4LJPwoCJLSAZQ5f3jBmsqjEBTSf/EryKWb4/OWo+2qDbFzuZQHMTBFLADZJH55tqKTfB 4qQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:user-agent:in-reply-to:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EXQRsFdfLYOm/MUUyIhSeoAXYv2SBvvANDEs00Y3qns=; b=apSMyPlosIyTjooPr1oa+fLYeaJSJSyfbriIYfhcPRiG2ounTOrQjrqIvgvM50W90o /VvcVojcLr6DQjRYaFZtI/W8TkkloWuP1kJURYVSaNldtc2x8ybh4R/+m1yfjtl2pihe lrgt+6SFchhDujeAFKXLSKw92uXCWna6zG8LTMHvE96gwRlCDR+HHuK99rkeI5eOgAxT h6/02PF5aMgCXe2Fy86KQx5TlbCziDLOZqFpm06u/nF5bRDDjLKa/QkgIEdbQsg0Vccq jzvJPwSmCt16Q4uNudr4+OdmEyX9y0v6qLZSSU1zvi4OeD0VC3CumVzqCWKx1hx69biW xGeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZADPzVbX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d23si13812766ejd.165.2019.11.29.05.12.28; Fri, 29 Nov 2019 05:12:53 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZADPzVbX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726806AbfK2NJz (ORCPT + 99 others); Fri, 29 Nov 2019 08:09:55 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:31305 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726360AbfK2NJz (ORCPT ); Fri, 29 Nov 2019 08:09:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575032993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EXQRsFdfLYOm/MUUyIhSeoAXYv2SBvvANDEs00Y3qns=; b=ZADPzVbXMRB47SUG6iCE5OQK3JWCNqkYzkV/QeTfDvfUI+u9qyppBY1GY7R+rjAhl44LXJ 63TY7nSxoe+ytn2hGewKcfHMDjRiuQzdf2pXTnL8rWM3K2n21c4Q1263yLvplNtSImpGfO nsCyn6kwRwVSmC9/pYxjAO2XLam9sGk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-200-dmcG5Go5PVmnxMR5lf7-tw-1; Fri, 29 Nov 2019 08:09:49 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DAA2911A4; Fri, 29 Nov 2019 13:09:48 +0000 (UTC) Received: from krava (unknown [10.43.17.48]) by smtp.corp.redhat.com (Postfix) with SMTP id EA7B85D9E1; Fri, 29 Nov 2019 13:09:46 +0000 (UTC) Date: Fri, 29 Nov 2019 14:09:46 +0100 From: Jiri Olsa To: Alexey Budankov Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel Subject: Re: [PATCH v3 2/3] perf mmap: declare type for cpu mask of arbitrary length Message-ID: <20191129130946.GC14169@krava> References: <908dbe98-7d8d-0ec1-d4ae-242f3e104979@linux.intel.com> <446c4345-cb20-d0ad-3b3d-b34683b1c1e0@linux.intel.com> MIME-Version: 1.0 In-Reply-To: <446c4345-cb20-d0ad-3b3d-b34683b1c1e0@linux.intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: dmcG5Go5PVmnxMR5lf7-tw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 29, 2019 at 01:04:37PM +0300, Alexey Budankov wrote: >=20 > 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. >=20 > Signed-off-by: Alexey Budankov > --- > tools/perf/util/mmap.c | 12 ++++++++++++ > tools/perf/util/mmap.h | 11 +++++++++++ > 2 files changed, 23 insertions(+) >=20 > 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 *t= ag) 'mmap_cpu_mask__scnprintf' name follows the name logic we try to use jirka > +{ > +=09char buf[MASK_SIZE + 1]; > +=09size_t len; > + > +=09len =3D bitmap_scnprintf(mask->bits, mask->nbits, buf, MASK_SIZE); > +=09buf[len] =3D '\0'; > +=09pr_debug("%p: %s mask[%ld]: %s\n", mask, tag, mask->nbits, buf); > +} > =20 > 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" > =20 > struct aiocb; > + > +struct mmap_cpu_mask { > +=09unsigned long *bits; > +=09size_t nbits; > +}; > + > +#define MMAP_CPU_MASK_BYTES(m) \ > +=09(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, > =20 > size_t mmap__mmap_len(struct mmap *map); > =20 > +void perf_mmap__print_cpu_mask(struct mmap_cpu_mask *mask, const char *t= ag); > + > #endif /*__PERF_MMAP_H */ > --=20 > 2.20.1 >=20