Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp279738pxb; Sat, 21 Aug 2021 02:24:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbo1yIphjOTfFAiG+7Wf/2tnmmlnwSsKK8xJ3t0fjMPglwaxBK05jXKJPG9lmU66gfKo2x X-Received: by 2002:aa7:c782:: with SMTP id n2mr26805654eds.77.1629537864193; Sat, 21 Aug 2021 02:24:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629537864; cv=none; d=google.com; s=arc-20160816; b=sTEgesHZqhJXlwvNLOZ/Op+F7muFYZ8Z2wFkbSuL9fEllJNDQu4txZo22gk7Tip5C6 16Yg2flRUuv1Y7IkhcPDABxrvHOVVmhT2iVyntjIKouP6WZz5xY2a12uWzt8AaMV/vAC 0e+oE2qA7JTyDG1DI6UHKR3Avkx6EzB9I0zDBBTycqFN6eGCrS0Oif4wjJT8pU2Rdtsg LdG9Km0y3FHUciEsw/tcnjE/k1PL1tCjID5cmVAD9LrSXZ9XYflCSS4yY38B1BCGyFCv F8ldgh7JF/lYE/dhJa7vruPFeqQQ3UXchA+UHAcPskfGeZ16AvAcdD4u5vPmlkuM15sL m4+w== 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=QZgLUS1D1n1+osF5QCdhScd9/ZmMYRc9ErCmnvjzL/o=; b=yVBwr0UkZSkI+FZ8Y0D032RY56ZB6I0QX/bNmedyYieq32G+O0ljJLZoFeV0jpuexj OHJk7BSDVnZosb9Pk032cBL5T0i8kEc6WcrYCVGLOUD1y36yF6SQzcsSX4e1FiNXvCjc lNKS86L3GYqSMBd3IFsGqSgrr+IQK+aTJbu0e/9hQ8isZbWMJNAMTuw2pgDgYVYhk/Cj oDRy2vYmqU2i+4G7I/himLotI5HlvY0DTFIfL1Q2Dlbs0RCY9Prix70KtKq5otnodMnO EWbuhhg7pAoSuwooc5Cj3yE7XvPRucwG0QFDOy53soOSwbjOGSnwy73XlI7RZ+HG4VNd n+hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aXZ7T+Da; 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 b1si3264550ejb.152.2021.08.21.02.24.01; Sat, 21 Aug 2021 02:24:24 -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=aXZ7T+Da; 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 S241072AbhHUJXJ (ORCPT + 99 others); Sat, 21 Aug 2021 05:23:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233997AbhHUJWc (ORCPT ); Sat, 21 Aug 2021 05:22:32 -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 5B341C061151; Sat, 21 Aug 2021 02:20:31 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id bo19so17596097edb.9; Sat, 21 Aug 2021 02:20:31 -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=QZgLUS1D1n1+osF5QCdhScd9/ZmMYRc9ErCmnvjzL/o=; b=aXZ7T+Da/te6Uru6w9k13v1OvEQIVyjAlHMvzTX1OMB1TOzHXd+8FIUWDnImHdut8v l+7P9LQmIPxcWjI/fQRy70tNtZTXRVS2hjJ/2Wm9E2H3LQY9hw2lP+mzh/wwJYjGVx1V wUBLO4h6zs6iUTlaKnA5C9m1KAw2ry+zadZNW/rZA59ZBGltah2VSaO8fFfFUmQlP5DE 32iOqmlLqady8+ykIaJ39vxA7U8Z1ua7WuGasHmSdqDVx35ADu1tjWt5Gc+/h4LJ9nBg eUUpBKLqvQHHulayj4Y9gpax7ySY36ciDJy1ftqJgK2PXlzpNpqhNE9ExgrqFCx30Ooh TRag== 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=QZgLUS1D1n1+osF5QCdhScd9/ZmMYRc9ErCmnvjzL/o=; b=C5nOZxzdZWtnCu8ngwhwgBp6KngZMV2TRbs1Bk5Rp4O5ynMwJzIrPW3bG8aE4zcSQ6 Cy4eyLuOvt82ZWsxhmShlwBSjK0kAG2MLbulTGHAb86uYuZ0E74F+E5Fco0VuOqU1HYn TIA0yhViMJiz0AQKiHYFNBtNv3HZFNPvtIquSeaOFabhSkRi81JxBhdwbHrTrh6DFdGU l9emkudzXp2D5mX0KfpZgNeR149+OZZwexA9YJu32Hti7xVe0Hcph0dzvPaTkTxxdlBP tP9RWBqIjyxjMp27d5xCMZaoLJWJe5qMqPJm8xUV/5hKFxrl/M2t1CvK5Fj2/ed8rAma m5qg== X-Gm-Message-State: AOAM5321AXtLQcRJ+rE/VML2xraMTXIvw+jFAD6UtZ8NCgZgcMD38NBc Vk89AWaQxKmrf1vEa2ARVPYbIW6dO0vRamxe0Ck= X-Received: by 2002:a05:6402:1011:: with SMTP id c17mr26254970edu.144.1629537629951; Sat, 21 Aug 2021 02:20:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Aug 2021 02:20:29 -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 33/37] perf record: pin threads to monitored cpus if enough threads available Date: Sat, 21 Aug 2021 11:19:39 +0200 Message-Id: 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 This patch sets the affinity of the workqueue threads to pin them to each monitored CPU in case the --threads option is set with enough threads and evlist multithreading is enabled. This yields a better performance for the evlist operations, since affinity need not be sent by each thread everytime. Signed-off-by: Riccardo Mancini --- tools/perf/builtin-record.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 7802a0e25f631fac..e2d2445e05d7c07a 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -2945,6 +2945,16 @@ int cmd_record(int argc, const char **argv) pr_err("setup_global_workqueue: %s\n", errbuf); goto out; } + + if ((int)rec->opts.nr_threads >= rec->evlist->core.all_cpus->nr + && rec->opts.multithreaded_evlist) { + err = workqueue_set_affinities_cpu(global_wq, rec->evlist->core.all_cpus); + if (err) { + workqueue_strerror(global_wq, err, errbuf, sizeof(errbuf)); + pr_err("workqueue_set_affinities_cpu: %s\n", errbuf); + goto out; + } + } } err = __cmd_record(&record, argc, argv); -- 2.31.1