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 ED82AC433EF for ; Sun, 5 Dec 2021 15:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235341AbhLEPSA (ORCPT ); Sun, 5 Dec 2021 10:18:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56939 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235526AbhLEPR4 (ORCPT ); Sun, 5 Dec 2021 10:17:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638717268; 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: in-reply-to:in-reply-to:references:references; bh=q7akbz8jVd1XxiHDhBppiOOGWNtATaVJhrEtgV9SmwQ=; b=WKzy+70Fhj59Ii9EmNnmaFOT+UTJLmbI9TRh56Vqch48eU/0N9bHUBlNfNfJKiq9mVyjkN aPJJbJGTHedVnt+aCoTlkIa3SPdrZAvK3M5DriR1RFixYwt8nC9sRKN1J0ujoezMkIvfah iKCgKgphWk8+UaSwBv1h9BsYjTv0GKc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-338-in8uGCICPNWhykojDxQ9Bg-1; Sun, 05 Dec 2021 10:14:27 -0500 X-MC-Unique: in8uGCICPNWhykojDxQ9Bg-1 Received: by mail-wm1-f72.google.com with SMTP id 144-20020a1c0496000000b003305ac0e03aso6591028wme.8 for ; Sun, 05 Dec 2021 07:14:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=q7akbz8jVd1XxiHDhBppiOOGWNtATaVJhrEtgV9SmwQ=; b=T/24Gv+G5VCZJBUezvnTz3xz0vcBP4PnN/Rpb6IBy/p1jaKXb0HjAz3uJHlgtxQ/Jd aMu9jmxU3UnpWetoEVTWCPxXLzzR9m0fQd0AimT4ehOPRuKqZxk6U8OhT9ihZ3/h4dml OFrx5BnjDNmI7cXCCHPkwQL+d63WgmBFopPmS8+IGWKELkvZgQl+BiB6MZZexqusX8VW DA+uJfJ7yXLOWUt07OJbA2GrdyTrevapFjvk/oJ6dXv02613mYW8PHbeLbHAbY5b8yID 8BUYjlNShx0i0YyjSlSlDRSMtnmueMky3V6PsmnK2Kyz0BZiOqQvMkpEne2uXl8owj0a IeJQ== X-Gm-Message-State: AOAM533mm6arQxgXcqjNEjNaCJBQTpCEe8aloB/QvZ4y1UmqeXKSuzO7 NYYsvXWBKMiUsi98FR/IPGsWDmPb0MlPbWPh5q1XFFtZ8pZjQEsQubYCGvFVOs7C8duYfIcZMy6 SsQADI5zc6tystc9MSy3JT/57 X-Received: by 2002:adf:ecce:: with SMTP id s14mr34784403wro.98.1638717266710; Sun, 05 Dec 2021 07:14:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJyl2Jrpzf3evyNciZUQ8KQ4IrylZUe4Aqu0MqPMtjETss7W2up3Q20B3tskMjOwN7OflRq8Nw== X-Received: by 2002:adf:ecce:: with SMTP id s14mr34784387wro.98.1638717266584; Sun, 05 Dec 2021 07:14:26 -0800 (PST) Received: from krava (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id az15sm8201072wmb.0.2021.12.05.07.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 07:14:26 -0800 (PST) Date: Sun, 5 Dec 2021 16:14:24 +0100 From: Jiri Olsa To: Alexey Bayduraev 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 Subject: Re: [PATCH v12 13/16] perf record: Extend --threads command line option Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 23, 2021 at 05:08:09PM +0300, Alexey Bayduraev wrote: SNIP > > +static int record__init_thread_masks_spec(struct record *rec, struct perf_cpu_map *cpus, > + const char **maps_spec, const char **affinity_spec, > + u32 nr_spec) > +{ > + u32 s; > + int ret = 0, t = 0; > + struct mmap_cpu_mask cpus_mask; > + struct thread_mask thread_mask, full_mask, *prev_masks; > + > + ret = record__mmap_cpu_mask_alloc(&cpus_mask, cpu__max_cpu()); > + if (ret) > + goto out; > + record__mmap_cpu_mask_init(&cpus_mask, cpus); > + ret = record__thread_mask_alloc(&thread_mask, cpu__max_cpu()); > + if (ret) > + goto out_free_cpu_mask; > + ret = record__thread_mask_alloc(&full_mask, cpu__max_cpu()); > + if (ret) > + goto out_free_thread_mask; > + record__thread_mask_clear(&full_mask); > + > + for (s = 0; s < nr_spec; s++) { > + record__thread_mask_clear(&thread_mask); > + > + record__mmap_cpu_mask_init_spec(&thread_mask.maps, maps_spec[s]); > + record__mmap_cpu_mask_init_spec(&thread_mask.affinity, affinity_spec[s]); > + > + if (!bitmap_and(thread_mask.maps.bits, thread_mask.maps.bits, > + cpus_mask.bits, thread_mask.maps.nbits) || > + !bitmap_and(thread_mask.affinity.bits, thread_mask.affinity.bits, > + cpus_mask.bits, thread_mask.affinity.nbits)) > + continue; > + > + ret = record__thread_mask_intersects(&thread_mask, &full_mask); > + if (ret) > + goto out_free_full_mask; > + record__thread_mask_or(&full_mask, &full_mask, &thread_mask); please put some explanation to comment on the intersection checks, like what's allowed and what's not.. and also some info about that to documentation thanks, jirka > + > + prev_masks = rec->thread_masks; > + rec->thread_masks = realloc(rec->thread_masks, > + (t + 1) * sizeof(struct thread_mask)); > + if (!rec->thread_masks) { > + pr_err("Failed to allocate thread masks\n"); > + rec->thread_masks = prev_masks; > + ret = -ENOMEM; > + goto out_free_full_mask; > + } > + rec->thread_masks[t] = thread_mask; > + if (verbose) { > + pr_debug("thread_masks[%d]: ", t); > + mmap_cpu_mask__scnprintf(&rec->thread_masks[t].maps, "maps"); > + pr_debug("thread_masks[%d]: ", t); > + mmap_cpu_mask__scnprintf(&rec->thread_masks[t].affinity, "affinity"); > + } > + t++; > + ret = record__thread_mask_alloc(&thread_mask, cpu__max_cpu()); > + if (ret) > + goto out_free_full_mask; > + } SNIP