Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B779C433F5 for ; Mon, 20 Dec 2021 10:38:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231308AbhLTKiD (ORCPT ); Mon, 20 Dec 2021 05:38:03 -0500 Received: from mga05.intel.com ([192.55.52.43]:32231 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbhLTKiC (ORCPT ); Mon, 20 Dec 2021 05:38:02 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10203"; a="326437569" X-IronPort-AV: E=Sophos;i="5.88,220,1635231600"; d="scan'208";a="326437569" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2021 02:37:57 -0800 X-IronPort-AV: E=Sophos;i="5.88,220,1635231600"; d="scan'208";a="520750014" Received: from abaydur-mobl1.ccr.corp.intel.com (HELO [10.249.226.24]) ([10.249.226.24]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2021 02:37:51 -0800 Message-ID: <90352f48-86a8-f8d9-2b74-b884b32d013d@linux.intel.com> Date: Mon, 20 Dec 2021 13:37:48 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v12 01/16] perf record: Introduce thread affinity and mmap masks Content-Language: en-GB To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexei Budankov , Riccardo Mancini References: <22ee51ee5430b51eee5f03301fb498d5d3e33d1e.1637675515.git.alexey.v.bayduraev@linux.intel.com> From: "Bayduraev, Alexey V" Organization: Intel Corporation In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.12.2021 18:13, Jiri Olsa wrote: > On Tue, Nov 23, 2021 at 05:07:57PM +0300, Alexey Bayduraev wrote: > > SNIP > >> +static void record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct perf_cpu_map *cpus) >> +{ >> + int c; >> + >> + for (c = 0; c < cpus->nr; c++) >> + set_bit(cpus->map[c], mask->bits); >> +} >> + >> +static void record__free_thread_masks(struct record *rec, int nr_threads) >> +{ >> + int t; >> + >> + if (rec->thread_masks) >> + for (t = 0; t < nr_threads; t++) >> + record__thread_mask_free(&rec->thread_masks[t]); >> + >> + zfree(&rec->thread_masks); >> +} >> + >> +static int record__alloc_thread_masks(struct record *rec, int nr_threads, int nr_bits) >> +{ >> + int t, ret; >> + >> + rec->thread_masks = zalloc(nr_threads * sizeof(*(rec->thread_masks))); >> + if (!rec->thread_masks) { >> + pr_err("Failed to allocate thread masks\n"); >> + return -ENOMEM; >> + } >> + >> + for (t = 0; t < nr_threads; t++) { >> + ret = record__thread_mask_alloc(&rec->thread_masks[t], nr_bits); >> + if (ret) >> + goto out_free; >> + record__thread_mask_clear(&rec->thread_masks[t]); > > nit, is this clear needed? Hi, You are right, since all elements of mask->bits is set to zero after bitmap_zalloc in record__thread_mask_alloc, calling record__thread_mask_clear after record__thread_mask_alloc is redundant. I will remove it here and in [PATCH v12 13/16]. Thanks, Alexey > > jirka > >> + } >> + >> + return 0; >> + >> +out_free: >> + record__free_thread_masks(rec, nr_threads); >> + >> + return ret; >> +} >> + > > SNIP >