Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2784861ybc; Mon, 25 Nov 2019 04:13:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxqZ9nqBeaf8AtVz/g/2tv74Ss4em9r73LXSYjcNQQY9WASbb0joR1F5X5nux8Kvf79wGrf X-Received: by 2002:a17:906:f18a:: with SMTP id gs10mr36263421ejb.107.1574684006532; Mon, 25 Nov 2019 04:13:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574684006; cv=none; d=google.com; s=arc-20160816; b=HxDKA1/tlCLC2bAqPNsrhG+RemC6F5/hKOF8jmTtwQEvdDGAT+M3044TrYvFEqPpgq vv1VYD1Pjl5mGdfn7vFlvQjDzkjNFxAE04lB7DveR22G0qPDQDWb+ekq3Lyb4HeUmtKW omOIKZV0oFLojdn7HbuhHoN0NJGBjBQiDZz9+FpRXhoxcp/5ecB7Mq7le1hOUQXcYS7y wbCOChzcRY9+E4aTL+h1pwUuSfjwR8FgN1SfavB/WNHI3YkDccDA0ZOqp/Dp09bVU9gn MqG+SppVMrBte35mU41l3ZvYVxxW11BKLzErLJLc0F7XSTBzEgwX8kXE9CO4vTnHnB2t 3gPw== 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=p8bsP7aNAm1LXeAzhI/dBKirYEWQYP2A7Os64dIDqSc=; b=0z0+6+PnkcmgkjB8qicfC7OfiTbuwFn2qWmsA1vkx8HFdTsyS7ewxUzYfCRvUHuG51 dzq5HLG6YNxF7RggqlDMo7GtQjdCvqSjUFph36N/cxBvdTN4ZSwQJ1dJ7hCyM9WKwmNn LiIfxWIuXvbFnBBJdl/5Gu13SAB6JraVs6jlGN8KWAEnKx8Gww8MSltIrN2CGVfsspYa JI242NScvKrTPpKOI/Y6h7q5Qg7k2PH21+Nx7m8CgThry421kcLNy/w119DQe64oZjrX 73Hyic4BODLQm8MT0jBLko9tSBLTqaVlmdu60otzL3mayNvU8njkKiBNtvPAtzuDg6iz sIrQ== 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 gx4si4462953ejb.182.2019.11.25.04.13.02; Mon, 25 Nov 2019 04:13:26 -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 S1727655AbfKYLNZ (ORCPT + 99 others); Mon, 25 Nov 2019 06:13:25 -0500 Received: from mga06.intel.com ([134.134.136.31]:46010 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727395AbfKYLNZ (ORCPT ); Mon, 25 Nov 2019 06:13:25 -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 orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Nov 2019 03:13:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,241,1571727600"; d="scan'208";a="239494659" Received: from linux.intel.com ([10.54.29.200]) by fmsmga002.fm.intel.com with ESMTP; 25 Nov 2019 03:13:24 -0800 Received: from [10.125.252.215] (abudanko-mobl.ccr.corp.intel.com [10.125.252.215]) by linux.intel.com (Postfix) with ESMTP id 132935802E4; Mon, 25 Nov 2019 03:13:21 -0800 (PST) Subject: Re: [PATCH v2 3/3] perf record: adapt affinity to machines with #CPUs > 1K To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <69bd0062-0f9e-889b-b7ef-0d97d257569b@linux.intel.com> <20191125094220.GC4675@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: <9b9209ce-ba61-824f-9443-3909991ff222@linux.intel.com> Date: Mon, 25 Nov 2019 14:13:20 +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: <20191125094220.GC4675@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 25.11.2019 12:42, Jiri Olsa wrote: > On Mon, Nov 25, 2019 at 09:08:57AM +0300, Alexey Budankov wrote: > > SNIP > >> -static void perf_mmap__setup_affinity_mask(struct mmap *map, struct mmap_params *mp) >> +static int perf_mmap__setup_affinity_mask(struct mmap *map, struct mmap_params *mp) >> { >> - CPU_ZERO(&map->affinity_mask); >> + map->affinity_mask.nbits = cpu__max_cpu(); >> + map->affinity_mask.bits = bitmap_alloc(map->affinity_mask.nbits); >> + if (!map->affinity_mask.bits) >> + return -1; >> + >> if (mp->affinity == PERF_AFFINITY_NODE && cpu__max_node() > 1) >> build_node_mask(cpu__get_node(map->core.cpu), &map->affinity_mask); >> else if (mp->affinity == PERF_AFFINITY_CPU) >> - CPU_SET(map->core.cpu, &map->affinity_mask); >> + set_bit(map->core.cpu, map->affinity_mask.bits); >> + >> + return 0; >> } >> >> +#define MASK_SIZE 1023 >> int mmap__mmap(struct mmap *map, struct mmap_params *mp, int fd, int cpu) >> { >> + char mask[MASK_SIZE + 1] = {0}; > > does this need to be initialized? This is to make sure the message is zero terminated for vfprintf call() > >> + >> if (perf_mmap__mmap(&map->core, &mp->core, fd, cpu)) { >> pr_debug2("failed to mmap perf event ring buffer, error %d\n", >> errno); >> return -1; >> } >> >> - perf_mmap__setup_affinity_mask(map, mp); >> + if (perf_mmap__setup_affinity_mask(map, mp)) { >> + pr_debug2("failed to alloc mmap affinity mask, error %d\n", >> + errno); >> + return -1; >> + } >> + bitmap_scnprintf(map->affinity_mask.bits, map->affinity_mask.nbits, mask, MASK_SIZE); >> + pr_debug2("%p: mmap mask[%ld]: %s\n", map, map->affinity_mask.nbits, mask); > > the bitmap_scnprintf could be called only for debug case, right? Right. It is required to prepare debug message. > > if (version >= 2) { > bitmap_scnprintf(map->affinity_mask.bits, map->affinity_mask.nbits, mask, MASK_SIZE); > pr_debug2("%p: mmap mask[%ld]: %s\n", map, map->affinity_mask.nbits, mask); > } > > ditto int the record__adjust_affinity function > > jirka > > ~Alexey