Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp57274lfe; Fri, 15 Apr 2022 19:19:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXJaMIR0EKrG3tDxmJzlu6zAtZm5DmDUsqwc5kWqTY26onjKzQedj9sygSfKYqKr4HkJE3 X-Received: by 2002:a17:902:7e0d:b0:158:cedb:3683 with SMTP id b13-20020a1709027e0d00b00158cedb3683mr1502382plm.108.1650075598003; Fri, 15 Apr 2022 19:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650075597; cv=none; d=google.com; s=arc-20160816; b=RVDAvtk7oq9+AvvHw7wmcx/xfbMTpVdUbR3AplE4U0QjKBB7gyDuEgGDG2FdK47HYs VgPjalum0fifaFcy1jVBLWxH7z53iac7WANU8C38PWnV9nAJD4QTguLb6GQ6CkSsw4vb 6B5F8tIckK5gHQ1VA3t2BUmE0ZGcb4NIOYAdUvTLwc7qeL5roMAoiVlqk/WiWaGcQe/F 55fwleFMMuUM4IU6FgRFgEBI+aBm1pFViNc364e4q6RAwcZ+hyj+f44zEtP7Nt/CDJ0+ nSnnwKps9S0Gt/4e9ManBThQ+L0sL/EVammy5O+GHKLNsnaqPBCexl8r06js48jB+qWR ty6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uGq5mQSHzXbKhfozAnAbELgxgo4xrrpfhNXtWbmHct4=; b=hBIGKLgBHGUL4aFi3BsnpA8xIHuKccg6z7OOQGD6CwlgyCw6W7wnVxPxg3t50/SyAd LjWTZeiP9t9J7BK5VKwFhA0GuFJjUIMI/sIbFAHMSd/fyV8VlYsjvilOyD+gfp0IBpof vMTxeKyuVRGlq4PMa3iqfQol3hPpGUZDle73y65fMPa803RPJC/mtxlSgkvW567+MEUq M9KAIoLYfj0gZSmHm9OOhHLo83kXnb6+UCfIzIeOntVYwaYnJwpvg/Pjw83hqtHGR4ER dkdfyqq/sna2PCshPFO+ZeKFdCRMxqQMCbR7DqmhdmXqrolgVGR7CwsQSiWY2263vRgY 6DfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u++qsKMz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b5-20020a63d305000000b00386123c9f67si2896416pgg.148.2022.04.15.19.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:19:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u++qsKMz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6B6AC157557; Fri, 15 Apr 2022 18:34:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239446AbiDNBdn (ORCPT + 99 others); Wed, 13 Apr 2022 21:33:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbiDNBdl (ORCPT ); Wed, 13 Apr 2022 21:33:41 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C400522F1; Wed, 13 Apr 2022 18:31:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 8077CCE27EB; Thu, 14 Apr 2022 01:31:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 849B7C385A3; Thu, 14 Apr 2022 01:31:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649899874; bh=pXA3UcvmQhe78Hg2wD2xtbuY0R4lUU4THOixPj3r68Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u++qsKMzV6jk9yB2AqTiqhYcOboL2TMX1glvdTxM+ZZuV40ix3zj7Z5NVRbaKq8oh zO/LkfW63vSukVKzS2riw8V7/JSh24VvjQxi9EcS7zPtgEek91WxBC22N1+zFeaBns hrArs1zAeWWpSbsljO2jibI8NDTzgT/UuQEX6AWxV852n6cVOlW9MsSC9l+da0BCp8 fj7xqjt/YCg9oQMPMbxGrBVkquwG9uwLVev3WBIx+Ws6ouvY0RGPMhl47TaVEYp5nw Z6g4vaEFXPAQR7irwQJDL0d2Z9F00FXNQGGzgVaJsrQHn867iNXgabYjhf25rdiinH DLx1ZtsJKeSOw== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id E76A740407; Wed, 13 Apr 2022 22:31:11 -0300 (-03) Date: Wed, 13 Apr 2022 22:31:11 -0300 From: Arnaldo Carvalho de Melo To: Alexey Bayduraev Cc: Ian Rogers , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexey Bayduraev , Andi Kleen , Riccardo Mancini , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH 1/3] perf record: Fix per-thread option. Message-ID: References: <20220412062133.2546080-1-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Apr 13, 2022 at 04:42:07AM +0300, Alexey Bayduraev escreveu: > On 12.04.2022 09:21, Ian Rogers wrote: > > > From: Alexey Bayduraev > > Thanks, > > The tag > Signed-off-by: Alexey Bayduraev > can be added to this patch. Thanks, will add that to the cset, Best regards, - Arnaldo > Regards, > Alexey > > > > > Per-thread mode doesn't have specific CPUs for events, add checks for > > this case. > > > > Minor fix to a pr_debug by Ian Rogers to avoid an > > out of bound array access. > > > > Reported-by: Ian Rogers > > Fixes: 7954f71689f9 ("perf record: Introduce thread affinity and mmap masks") > > Signed-off-by: Ian Rogers > > --- > > tools/perf/builtin-record.c | 22 +++++++++++++++++----- > > 1 file changed, 17 insertions(+), 5 deletions(-) > > > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > > index ba74fab02e62..069825c48d40 100644 > > --- a/tools/perf/builtin-record.c > > +++ b/tools/perf/builtin-record.c > > @@ -989,8 +989,11 @@ static int record__thread_data_init_maps(struct record_thread *thread_data, stru > > struct mmap *overwrite_mmap = evlist->overwrite_mmap; > > struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; > > > > - thread_data->nr_mmaps = bitmap_weight(thread_data->mask->maps.bits, > > - thread_data->mask->maps.nbits); > > + if (cpu_map__is_dummy(cpus)) > > + thread_data->nr_mmaps = nr_mmaps; > > + else > > + thread_data->nr_mmaps = bitmap_weight(thread_data->mask->maps.bits, > > + thread_data->mask->maps.nbits); > > if (mmap) { > > thread_data->maps = zalloc(thread_data->nr_mmaps * sizeof(struct mmap *)); > > if (!thread_data->maps) > > @@ -1007,16 +1010,17 @@ static int record__thread_data_init_maps(struct record_thread *thread_data, stru > > thread_data->nr_mmaps, thread_data->maps, thread_data->overwrite_maps); > > > > for (m = 0, tm = 0; m < nr_mmaps && tm < thread_data->nr_mmaps; m++) { > > - if (test_bit(cpus->map[m].cpu, thread_data->mask->maps.bits)) { > > + if (cpu_map__is_dummy(cpus) || > > + test_bit(cpus->map[m].cpu, thread_data->mask->maps.bits)) { > > if (thread_data->maps) { > > thread_data->maps[tm] = &mmap[m]; > > pr_debug2("thread_data[%p]: cpu%d: maps[%d] -> mmap[%d]\n", > > - thread_data, cpus->map[m].cpu, tm, m); > > + thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m); > > } > > if (thread_data->overwrite_maps) { > > thread_data->overwrite_maps[tm] = &overwrite_mmap[m]; > > pr_debug2("thread_data[%p]: cpu%d: ow_maps[%d] -> ow_mmap[%d]\n", > > - thread_data, cpus->map[m].cpu, tm, m); > > + thread_data, perf_cpu_map__cpu(cpus, m).cpu, tm, m); > > } > > tm++; > > } > > @@ -3329,6 +3333,9 @@ static void record__mmap_cpu_mask_init(struct mmap_cpu_mask *mask, struct perf_c > > { > > int c; > > > > + if (cpu_map__is_dummy(cpus)) > > + return; > > + > > for (c = 0; c < cpus->nr; c++) > > set_bit(cpus->map[c].cpu, mask->bits); > > } > > @@ -3680,6 +3687,11 @@ static int record__init_thread_masks(struct record *rec) > > if (!record__threads_enabled(rec)) > > return record__init_thread_default_masks(rec, cpus); > > > > + if (cpu_map__is_dummy(cpus)) { > > + pr_err("--per-thread option is mutually exclusive to parallel streaming mode.\n"); > > + return -EINVAL; > > + } > > + > > switch (rec->opts.threads_spec) { > > case THREAD_SPEC__CPU: > > ret = record__init_thread_cpu_masks(rec, cpus); > > -- - Arnaldo