Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2805247lqz; Wed, 3 Apr 2024 09:04:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUC9MWjLnuNalnJIrpymHdT4BEVHAW0pPx6BCpFCFCgXFe/k/Qd6seYKxgxVVLOZa3DGn9Y9y51884u/NnJKC08io6HVcJj97rpHiBwYw== X-Google-Smtp-Source: AGHT+IGQFGjvMyz1wjs+CJ56AKXrhl2NnHtyTgkVApMOo85e9CY96mYgZuvRM9eC0pj9dLkWQDeU X-Received: by 2002:a05:620a:29d3:b0:78b:c74c:f025 with SMTP id s19-20020a05620a29d300b0078bc74cf025mr19758848qkp.2.1712160298001; Wed, 03 Apr 2024 09:04:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712160297; cv=pass; d=google.com; s=arc-20160816; b=IfdaBuLx/igCQfJJuFL1TE72LE7buT8Cf766TOdIRRDPlaXdWPWr4GxxOPuJ9PbaGz vLNbryOg9SoWPshn36CTD4WewGUAGySBdiByI9adtN9ZNISExHGYu8JoY6ojcp66Lx9P r5ePzkZXwopfuBungSSURB7Pd/hfVzj8aoUf1VFtrD2Dz6FjOMzPliXla18XScQTPVzE y1JMIP+hfMJX/4A3t67fa4B3Kf3mTnUrdK1PbxZugmjvoAY1TaIiUdR19zYG3J2gV6jV 4PBOpSMCmE/9r/QL3HET6MyiUTk1C7yVGC+o4ya2zlkeLtsdfY5vaCmc9vUag0bGvhlE 2Ywg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Apaqa6hGkOpX+06CDr8md6ckcIxxFq4aFxzFQUaXzpw=; fh=K1EjY/iDKwuQSBahFsPqCvcaIzvvxPUGKK+WBDBIaaQ=; b=Paj6dYdBEtCBct5hVpIDx6jOX6yPWhToOVNbPhJOb/cZhH0tE68HDDB74g4whkUHeB La6/9WHyUwPEoElBt1WyYCuHgBPhomiiWvVCzbXCgIuNTpvkFnhlwXRtN+LQvz5Bld3A 9UEQ38nANenqPYzLCHFE9MfLFLZocXbDX5vvYdHp79HC8UuF9v0BKlocXlQRLC7OzfnO sZiuxVps5bKHimUwAgW91SyjSROZwumxoZmwc/Xxt+nMraeeVmB9puvAnH8u9o+SaejS zsWFvngILLylPdJt3qppP6khOwPh/EdYYY6RRJqv4HLfgbIbjSlmGBW30yHGJlW2XrGl Y13A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=shingroup.cn dmarc=pass fromdomain=shingroup.cn); spf=pass (google.com: domain of linux-kernel+bounces-130164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pa41-20020a05620a832900b0078a36e7bd63si14378883qkn.491.2024.04.03.09.04.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 09:04:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=shingroup.cn dmarc=pass fromdomain=shingroup.cn); spf=pass (google.com: domain of linux-kernel+bounces-130164-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B5F041C26345 for ; Wed, 3 Apr 2024 16:04:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9947414B099; Wed, 3 Apr 2024 16:02:49 +0000 (UTC) Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7890B14A0A0; Wed, 3 Apr 2024 16:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.92.39.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712160169; cv=none; b=JUL0Q7tOySQDECsc8DL+FM/ePZE7pbUceg2BgcxWhsSYiUiN7wLOPnAtvxZUdLQopj2+Qq9Xmd/TUlfRJJHMgO0HFTEaRR22lsYZjFbU1HHBi23NmjKis1FedXRquT9e1JzyMqu1VIAGRuHXh7k8jRPzKn3aArzxUWA/i1q9eSU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712160169; c=relaxed/simple; bh=JER5mHSZGhD0udPKWpH+F+JeOasxCW1BBaV/SoNA/uo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cI7zWHgCDsplzCI4VcNukaKzAMk3mn9nf80UWFI/k+vkDuGHCDE8fiIPo7q8QGH5eyK4L9ND9/7mXJprKHuMYv0v0fKB3J3UxwFRqneZ57sybly2r2W+UI9I+PWoTzK822373IGAuD4zFBzjnAwgTVcf2o4jkDWhaBSTT0BoLqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shingroup.cn; spf=pass smtp.mailfrom=shingroup.cn; arc=none smtp.client-ip=54.92.39.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shingroup.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shingroup.cn X-QQ-mid: bizesmtpsz1t1712160085tos1143 X-QQ-Originating-IP: Otqadma0z07KqqIZT+FduXyNos/JdYlfYRqjDNsvzu0= Received: from localhost ( [112.0.147.175]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 04 Apr 2024 00:01:23 +0800 (CST) X-QQ-SSF: 01400000000000704000000A0000000 X-QQ-FEAT: aLjW147EVxPnQ/6oOU8GRSgWLTrRNYcNhCWJZET1WPtO8Qce7Z4NMwuqtGPkX UUS3z/3CASpxB6M5/VH9zBnCe7QFb7YNCl9rsPnFZER/Z83rqNBmLBtpuWrQPVbqSoZ6COx qOV83QlvLohg0t4UIJmsKlPkkoTEu3l5L0y8iy7f/gOeAJ4dRdZoUj3glWemVvJmF4IXxYG wcwJKGyQXr1BrvBOK+oAK5n8A5o0mQjEp+UGufTnTm+qH6Pv+bwp5AKuhYShO0aQmDhApP7 620gWfxVCpp57XZ5LOcqd1IaaeqyMrynZoTuMBkLsaWtObJ7VfQE3CYjFyNtR1Hsxr6VqX1 qVJvmStqdkulI8FFHILuxq4M7nAQII4RwJ3oeOAKsG+Gvpm//K1YUB85tObqmz9fOhpqLSm 3L7jZ5WiHoA= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 17025534961024682546 From: Dawei Li To: will@kernel.org, mark.rutland@arm.com, yury.norov@gmail.com, linux@rasmusvillemoes.dk Cc: xueshuai@linux.alibaba.com, renyu.zj@linux.alibaba.com, yangyicong@hisilicon.com, jonathan.cameron@huawei.com, andersson@kernel.org, konrad.dybcio@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Dawei Li Subject: [PATCH v3 09/10] perf/qcom_l2: Avoid placing cpumask on the stack Date: Wed, 3 Apr 2024 23:59:49 +0800 Message-Id: <20240403155950.2068109-10-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240403155950.2068109-1-dawei.li@shingroup.cn> References: <20240403155950.2068109-1-dawei.li@shingroup.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 In general it's preferable to avoid placing cpumasks on the stack, as for large values of NR_CPUS these can consume significant amounts of stack space and make stack overflows more likely. Use cpumask_any_and_but() to avoid the need for a temporary cpumask on the stack. Suggested-by: Mark Rutland Reviewed-by: Mark Rutland Signed-off-by: Dawei Li --- drivers/perf/qcom_l2_pmu.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/perf/qcom_l2_pmu.c b/drivers/perf/qcom_l2_pmu.c index 148df5ae8ef8..b5a44dc1dc3a 100644 --- a/drivers/perf/qcom_l2_pmu.c +++ b/drivers/perf/qcom_l2_pmu.c @@ -801,9 +801,8 @@ static int l2cache_pmu_online_cpu(unsigned int cpu, struct hlist_node *node) static int l2cache_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node) { - struct cluster_pmu *cluster; struct l2cache_pmu *l2cache_pmu; - cpumask_t cluster_online_cpus; + struct cluster_pmu *cluster; unsigned int target; l2cache_pmu = hlist_entry_safe(node, struct l2cache_pmu, node); @@ -820,9 +819,8 @@ static int l2cache_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node) cluster->on_cpu = -1; /* Any other CPU for this cluster which is still online */ - cpumask_and(&cluster_online_cpus, &cluster->cluster_cpus, - cpu_online_mask); - target = cpumask_any_but(&cluster_online_cpus, cpu); + target = cpumask_any_and_but(&cluster->cluster_cpus, + cpu_online_mask, cpu); if (target >= nr_cpu_ids) { disable_irq(cluster->irq); return 0; -- 2.27.0