Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp278481pxb; Sat, 21 Aug 2021 02:22:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV2vdRwelP3kFfK/OmzVd2QlA4auAL+ye220RoSVBcs5JVIl/MevPd7fHhY5LqW74lKp1q X-Received: by 2002:a92:194b:: with SMTP id e11mr16841017ilm.200.1629537724612; Sat, 21 Aug 2021 02:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629537724; cv=none; d=google.com; s=arc-20160816; b=fEc0ll5TW+xXV1q0SGT2JeCpv4n7N52Ct8LV52YTFyErg3KJJBE9FwMkfvPnLp/yYJ LGWMHnDoQucUmIRe4dglQeA6xans/kFS8x7t/TCG1gsbnxp+xP8j8lbzXahA4gUZ6QQy alkqdIi0dmUG1N5GuEZELvYiE7K2xSjuVdBTkz1/OSQES+rIN9GQ2mHrfakJtK/+kzPG iuL7x4coZDxr3CUAb3jq5rgfGF//aFJEJM55a5PUqUTkAIVp74fo5KZsvhsa59ZTAZOV yDTLpB6WGF+DRfg52utH+uERfhCVKTgyrx749hJ49JNlWhLaRiCOh8+Fry7yiDJ60Q+U KsGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GdLOUQfMiSvyr/krR4mQnx8RhZT43Ru8R5OO/VTr+4g=; b=xNAz3A99RR4LYkD5i8Ry2FyOZzkcYbiJ1nLMsAYPPo6qthSIRKh+aVGRg6W/lRquRB fqOtQNEn1DZ5+Fs1sJC2JWVgagVxw681vYQe7GGRun4MDmpX3rlJ2YRiujqzripvyAKH hvd/WM2PqIKw5hxQA0XqcCSSPyovTpthQHVM4NE/euUPRpMDC1fwmgRuGLhC/xFVK3la LHLAKIjp25Kwq4sD8IOBkuKNt1Ha+BBk3/gPNAgobjcvHgOhdAFwb0Z6z1Fq/i77aRDa dH0MnJ7QFIiiWIL6KZS9G2jdS7XEJlyStqpneKNn/jSD4xjmzZ5Ni2JxFrKzik8e+mEU DBvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oex+PMhE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d131si11276541iog.11.2021.08.21.02.21.53; Sat, 21 Aug 2021 02:22:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=oex+PMhE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234556AbhHUJVZ (ORCPT + 99 others); Sat, 21 Aug 2021 05:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234216AbhHUJUv (ORCPT ); Sat, 21 Aug 2021 05:20:51 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C733AC0612A3; Sat, 21 Aug 2021 02:20:05 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id g21so17634290edw.4; Sat, 21 Aug 2021 02:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GdLOUQfMiSvyr/krR4mQnx8RhZT43Ru8R5OO/VTr+4g=; b=oex+PMhEWJc4qwt8Ggjweiaj75IMXWNcxKWGsglVkLTpLuRsDVhhn9Wih1vYhRL6uf LAC+2aZENq3Dtc+KwR9Lt7gGQSGV+pDfGS8r+J3PeoTRCvpV5XXrjquIgDFvqAeMrAS3 9oiakVOvaZiFkni2m8E1FK2cu60iW+4wLCIBem/tQVDSffnmj8La6mCuj/UftextcpKu LAVtX8rKzltLdnPy4zAtpMvZb9yJTWhkmOdSc3zZKkbXO1IZ+Wh9BY/CXeoUfqdub1VJ zgpzgEUvNjZcdKNbCfyJI/ZBaRChM35Hh2Ls4pfU0hWowUWGSlInw6IjIqt2ovkU5IbJ tnDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GdLOUQfMiSvyr/krR4mQnx8RhZT43Ru8R5OO/VTr+4g=; b=TS3NuNSexre3XEqxfRLfyX0xuqC88AAW3NAr3kwuTSl4k5Yw6DWNTPZlj+3+2b1RMK IneIbaVrOXjCK29Whe28ttRK4pZLuVl/ZDYz6SVXiydHw6FbWhOhO1JwEh0Q9ZaEhR6X 9XbY8A+Tn8ryMBcsDdE9aIR6RBMG//yRGVBrmTvS3c9GUrJ/zfjxr1XGg7bclyOKG0Uy dAQcYr2jHeqUjJg2mOcSRk1Do0qZclgZ9NSDPso3s4HSWhz85y8sLR0a6OiKZhHgs3h9 nk480nE0eQ05nVGYY7+wsT6mDIF5Il5P7baEDdBHalr4C2h+OabV2ie05cQYFxUocVUO ONbQ== X-Gm-Message-State: AOAM532mcYlrkj43o7cnxBryE6c/JQsOoLQqww/CiJGNbs5osflqA4MA /WGlHeU75PmFoN/mhu439WI= X-Received: by 2002:aa7:ce87:: with SMTP id y7mr26928301edv.306.1629537604387; Sat, 21 Aug 2021 02:20:04 -0700 (PDT) Received: from honeypot.. (mob-176-243-254-204.net.vodafone.it. [176.243.254.204]) by smtp.googlemail.com with ESMTPSA id a25sm4003878ejv.91.2021.08.21.02.20.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 02:20:04 -0700 (PDT) From: Riccardo Mancini To: Arnaldo Carvalho de Melo Cc: Ian Rogers , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Riccardo Mancini Subject: [RFC PATCH v1 13/37] perf evlist: add multithreading to evlist__close Date: Sat, 21 Aug 2021 11:19:19 +0200 Message-Id: <5473d8d537e30b3fd5333038dc5fdd25ba027d06.1629490974.git.rickyman7@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In this patch, evlist__for_each_evsel_cpu is used in evlist__close to allow it to run in parallel. Signed-off-by: Riccardo Mancini --- tools/perf/util/evlist.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index fbe2d6ed8ecc8f21..f0a839107e8849bf 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1340,11 +1340,17 @@ void evlist__set_selected(struct evlist *evlist, struct evsel *evsel) evlist->selected = evsel; } +static int __evlist__close_evsel_cpu_func(struct evlist *evlist __maybe_unused, + struct evsel *evsel, int cpu, + void *args __maybe_unused) +{ + perf_evsel__close_cpu(&evsel->core, cpu); + return 0; +} + void evlist__close(struct evlist *evlist) { struct evsel *evsel; - struct affinity affinity; - int cpu, i, cpu_idx; /* * With perf record core.cpus is usually NULL. @@ -1356,19 +1362,8 @@ void evlist__close(struct evlist *evlist) return; } - if (affinity__setup(&affinity) < 0) - return; - evlist__for_each_cpu(evlist, i, cpu) { - affinity__set(&affinity, cpu); + evlist__for_each_evsel_cpu(evlist, __evlist__close_evsel_cpu_func, NULL); - evlist__for_each_entry_reverse(evlist, evsel) { - cpu_idx = evsel__find_cpu(evsel, cpu); - if (cpu_idx < 0) - continue; - perf_evsel__close_cpu(&evsel->core, cpu_idx); - } - } - affinity__cleanup(&affinity); evlist__for_each_entry_reverse(evlist, evsel) { perf_evsel__free_fd(&evsel->core); perf_evsel__free_id(&evsel->core); -- 2.31.1