Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1983106lqz; Tue, 2 Apr 2024 04:00:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUxnmLBCY5aCANx3OK6nqwTb7IUpejpc4mDLUjnydEj8YDY3I+OVLEtjfi9tMdJQAOU4KgnnaTClkndMAPrwkPG3FjQoXlrDpIqjHD3UQ== X-Google-Smtp-Source: AGHT+IHMQzS4A2IhNocggZ/q4X9WbFOczYMDVCEHBHevX2yhoycVnJ/GD3UjdWl7E2IqS2K+3zCn X-Received: by 2002:a17:906:3a8a:b0:a4e:2696:ca47 with SMTP id y10-20020a1709063a8a00b00a4e2696ca47mr6904406ejd.71.1712055644585; Tue, 02 Apr 2024 04:00:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712055644; cv=pass; d=google.com; s=arc-20160816; b=zbzzC15pX9lFLO6houEaRB80QKTd8RfbdeNJfdSVlDma2elFVRYtk+V+/cfE2s0NQ4 bVQCVIhJ6LYaB6PK+zK+XOtfJ7Zkk8KzS0kqf7S4g3CaWtYxX+bUrXkS9NkkDeryfjzG UDnrrRcb2gj8Tb+v8bte6bwJW5JIow3XeTYYgmSw3u/IYgP5OzCL0cKg/Drk5FCripQi B9tdLdFLdL1kKhCfp1xZrDBpOYTgq1UadNls9mtUKZcMcrvdSyjmtThdAaltjwfzJ2Eg nXHXaPuQH5/f8mTdhD1H0U4EdgsFJsb+kCln7KKiiP0l+mZPEIN4cAAWJD9kH653X6Kv S6HA== 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=b0gRvurch3hbhSwd/Ynwzoa3AFnC5kcyPtqDLXvLMrE=; fh=o/k7AuWPbRjdLmUU3oEa80kWPrFP2UiheGxXV2RAKKE=; b=T/kblrgYFzmL1oR3Z5CdyW5GWsD5wXITm5GmVZ8fLs6o/gognUrgrkHItUPiouNhFM xQ7m0TvyhIHqgyiqwPXoE+2Yj7ndbgfEuav8388+A0Ni/R47yiZZmtos7eKxAwIpfQIA ccyuF4L54hkAXPxWCSCduuQV3b3iBbvqM5sTw13FaoVJFLI6DPgeYIPs+LOAQFFfE5j9 K7BRllImZepujaTUUzh1xyOzgRRTx5ANoYqPsdGS4mdTqu66S/L4XFY5MPEUdUGnQ2SP /2U4pki3usVt4tEAl63rzPFO/gPf/E2aVCOYePPb2/R6/iJ0AEHl+2jvPZr5IV9tGLQ1 vWTA==; 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-127804-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127804-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bi12-20020a170906a24c00b00a492f0757d6si5533147ejb.662.2024.04.02.04.00.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 04:00:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127804-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-127804-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127804-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 525561F23B31 for ; Tue, 2 Apr 2024 11:00:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9019B6997B; Tue, 2 Apr 2024 10:58:16 +0000 (UTC) Received: from bg1.exmail.qq.com (bg1.exmail.qq.com [114.132.62.65]) (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 CB9F984A35; Tue, 2 Apr 2024 10:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.132.62.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712055496; cv=none; b=eXZm6GZv8U24Qa7vn+lHej4F8yck9bI0OZBJ/JZJboWz6uruv+OTY6phfdrWZQ59coMqBlnITYVNQsEhOHvO85AYb43OqT/0o0ck1/MRvss7C0rr87+wNeTuT1/Q6aHYiGp1375jyVeXINpSmc0QnhWYMtYLgJisX+WCNEwP7YA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712055496; c=relaxed/simple; bh=Hp5Kotv+V9yNIc4Tg2u+vJrrmMQdftSMs1SkQH7KC+k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WBVg/vprAE12NBAMLPH4AzWQyE2FnMxlN+mXvbYxd4KNaoR28fSmdy2YAbCm7AWvJVmvXaTahw4OqIueDQmrFTc8Z6O56390i00OCruTIZVHC9qOIIDNCAS53RDV2y6jKnIa2dcp+/ct3+p2v9RyCC/Tl5/Xk670n86GdEY7twA= 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=114.132.62.65 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: bizesmtpsz8t1712055405t6jdpo5 X-QQ-Originating-IP: zMSS9njKLfe5qpNl4MMAMhdArcJiYg0YoFBp8ktzVXQ= Received: from localhost ( [112.0.147.175]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 02 Apr 2024 18:56:43 +0800 (CST) X-QQ-SSF: 01400000000000704000000A0000000 X-QQ-FEAT: /gpUuYPpeIUOZ5s4aenzg3ecAzQ5K7SRWRK0Che4X0DDJnKnqcBFQ3cHWYAn9 cC/dPwRl0hcLzexcfoeO00x98gWN2YFe9xxEMIqqAwMtfS8gs12iNpMKdpHocr0FdLJwbcq +emWo5zvWekdtysQtOjjfOBqCVqCfJEKNxB7kSUUL5lvNVHQDOk5JBAOiw7Iu26y6O0B4Gb 9DqRc22fi4nNYUaDy7fftLuAwpVhNm/7Hl5Kc7rzSsPwn/riyxIOjFFO+hPOlPUqtHgqkGy cfrEyy2vTIS6l3JFKTwalV/DRu7+29DUKticbHws+GMLWcAshAdfwnhqvt86apeFvFyTLCU UCdFTaAMhQQNh9KermXJV28Vn3+Y7NnwJK3FE37g9nkVKf413DQMY49v7TfCA57vzfc6hWk VLW+wSF7XBU0RP/V2c0OmQ== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 5033886388015913016 From: Dawei Li To: will@kernel.org, mark.rutland@arm.com 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 1/9] perf/alibaba_uncore_drw: Avoid explicit cpumask var allocation from stack Date: Tue, 2 Apr 2024 18:56:02 +0800 Message-Id: <20240402105610.1695644-2-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240402105610.1695644-1-dawei.li@shingroup.cn> References: <20240402105610.1695644-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 For CONFIG_CPUMASK_OFFSTACK=y kernel, explicit allocation of cpumask variable on stack is not recommended since it can cause potential stack overflow. Instead, kernel code should always use *cpumask_var API(s) to allocate cpumask var in config- neutral way, leaving allocation strategy to CONFIG_CPUMASK_OFFSTACK. Use *cpumask_var API(s) to address it. Signed-off-by: Dawei Li --- drivers/perf/alibaba_uncore_drw_pmu.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/perf/alibaba_uncore_drw_pmu.c b/drivers/perf/alibaba_uncore_drw_pmu.c index a9277dcf90ce..251f0a2dee84 100644 --- a/drivers/perf/alibaba_uncore_drw_pmu.c +++ b/drivers/perf/alibaba_uncore_drw_pmu.c @@ -743,25 +743,28 @@ static void ali_drw_pmu_remove(struct platform_device *pdev) static int ali_drw_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node) { + cpumask_var_t node_online_cpus; struct ali_drw_pmu_irq *irq; struct ali_drw_pmu *drw_pmu; unsigned int target; int ret; - cpumask_t node_online_cpus; irq = hlist_entry_safe(node, struct ali_drw_pmu_irq, node); if (cpu != irq->cpu) return 0; - ret = cpumask_and(&node_online_cpus, + if (!alloc_cpumask_var(&node_online_cpus, GFP_KERNEL)) + return 0; + + ret = cpumask_and(node_online_cpus, cpumask_of_node(cpu_to_node(cpu)), cpu_online_mask); if (ret) - target = cpumask_any_but(&node_online_cpus, cpu); + target = cpumask_any_but(node_online_cpus, cpu); else target = cpumask_any_but(cpu_online_mask, cpu); if (target >= nr_cpu_ids) - return 0; + goto __free_cpumask; /* We're only reading, but this isn't the place to be involving RCU */ mutex_lock(&ali_drw_pmu_irqs_lock); @@ -772,6 +775,8 @@ static int ali_drw_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node) WARN_ON(irq_set_affinity_hint(irq->irq_num, cpumask_of(target))); irq->cpu = target; +__free_cpumask: + free_cpumask_var(node_online_cpus); return 0; } -- 2.27.0