Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp349748lqz; Fri, 29 Mar 2024 22:09:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJZh3yotYIwfzXyYxg1ORcTFLrGVRMLy2qD0lPD0NmITcze36NwrhFELgPuE0wbX5vD38qeKWhUyuX1VJZ+wTp1mS5OAYX7CAUJJj+sQ== X-Google-Smtp-Source: AGHT+IGGBgnUC61LGPnHtCoTBoeexAGebTA/doihpmxOosf7jC63+LZTc6rkCHFZqj2TnIvn1sI6 X-Received: by 2002:a05:6830:4bc:b0:6e6:9914:87b6 with SMTP id l28-20020a05683004bc00b006e6991487b6mr4228122otd.17.1711775354832; Fri, 29 Mar 2024 22:09:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711775354; cv=pass; d=google.com; s=arc-20160816; b=YUtsbxZCHkaf4PCb6I7OdWssJx2j7fJYrLTkRnnUDDDyl5PUYgdW4w3k56GZFTL4S3 9UbQlZkk6w/ouSUFmHgRDGrKuPjuJQ9pNISmkrI1JMTyHhnJgWoWNLb3phKmfMWENxp2 qIyQM2xo0G1sNM8X5ARtT9egZ48HYwgF//HbiNLrRnOOpXWy2DwrXRE0KHhVtVaj10xV RJEFmTYqiZujZnqTOGGoQEHDQekudtjYgqrWhderj87sR201MTJML6UL7Z3IeTFzJ3a1 SdbOvWnhVEpR41PQa4TdjZKAPA0hiuZ7pE1rgUMFbhNTi7Doq0pbuj472aZYpR5NMkws 4WDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date; bh=wplCbUEk8NhRcV12q/iInp2ikqREcY2RQLho68ZJjzE=; fh=pUwCSp8R0nxvlMjlnjNyrBI4Rs/zkrit6WxEaD65kZc=; b=JtWSm/nNlaVp8hH3kLgQSfeb9oygup+UoAVwmwIAOGiuDd1Kg5Ios6jhJZSBfAz6Ow Cd9XqNuUU/oaVuCBwIqldvImOaalLj6EgSSzYxe4dlf0wT3q33geNOhY89+2a0ew+K+c iKyw7QhpODP2jZAZzYTCal0YxtOwenflsWNapgzSEBtTKRiQZzmDswsxR0bg3TwBthVr qw4vu7M8iJGRGyjBzTgMJ3P0MRcl/peUT50hW38JRRY/QY4g2OYYn9TZc6FdpbwA3+Py CRqwhVdVY5Nd0zGzhFmhy184jooPQ35bM69OYJZ/RwWhape5dnM8GUtz76b5g2+ALWMV K9IA==; 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-125600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w21-20020a63af15000000b005f057f38dcbsi375682pge.455.2024.03.29.22.09.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 22:09:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-125600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125600-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5B14828397D for ; Sat, 30 Mar 2024 05:09:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AAD58C04; Sat, 30 Mar 2024 05:09:06 +0000 (UTC) Received: from bg1.exmail.qq.com (bg1.exmail.qq.com [114.132.65.219]) (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 418523FF1; Sat, 30 Mar 2024 05:08:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.132.65.219 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711775345; cv=none; b=gfLWY1ioFi9jl1ZBFjmxmFW2tHmdP96al/rViDheOnyYsGPNiY/6rojsa6KuCViu6ospo8JqIPmrQ5kYhXxI4fWTd13oBUM7loEJ816ctuoV5AIOJRDqdy8LJMFGF588bEGNcNoJZnlMJ+26z+gcXZ2kaQlCf0QR+U0nKFsVYlw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711775345; c=relaxed/simple; bh=nYsJpAvl6D6Ldufd73Rjy7YF1XYSzElH1fykgREgPxY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nPDDajRC5sef6WYcCenUzFrJabkj3nFiAaNM8jxBguQE+fYD0jUXLYNwIYYdx/DfR8ex7tUilcegtdOsom4YdWhROAmwHDAxg4AfPonb2M1mMwD3xYUyVNldguOl29V8JvaRRyAAWjRH+cUhqKQq6qdlYHWWn1MFfLqI2qghuRo= 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.65.219 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: bizesmtpsz13t1711775229tdi4p2 X-QQ-Originating-IP: RfTYRleHqifmaUL5vg3HHBAADHtyt3J2efZxDgCsTa0= Received: from localhost ( [112.0.147.175]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 30 Mar 2024 13:07:07 +0800 (CST) X-QQ-SSF: 01400000000000704000000A0000000 X-QQ-FEAT: OtIeQkg1QQHVkELNGhnn3Ao/OxN3u837g2WY2miXs+dKwNICeHodGDXYI+XIN MLiksvoY6OK484p/H1Pd7HcbM0rICeev22amIC6/BI2BPXdj7hZR/NjRgIzO0ujc7AJYyuh hSs4kN6XesHATJzk7YtHOv0oscVKSJDG1YcCID61KeNwB//v/SP6Vco5Zi0zVzK2CryiHy7 MDlcbxtiVcvQbWgHR9uJniyBUgkXuWUpSRm9PGge+rsWbj+CoXH7KA5p92J+1tMYPfc3pMS a2+D1HW1CQDyFXgH/iGbdQU2wmJ3Udzd7Q8BgYnuoVkISFF2Z3cH4G9BqZDzzOAp62v8M7U 2sZsZTz6rWN4NWIO+LXnMPEd2Ftx/MDN8OxPXGUXp3ZrWXMIP1dg4Nut1Jfsg== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 10889329762490604258 Date: Sat, 30 Mar 2024 13:07:06 +0800 From: Dawei Li To: Eric Dumazet Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, ioana.ciornei@nxp.com, wintera@linux.ibm.com, twinkler@linux.ibm.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: Re: [PATCH net-next 1/2] net/iucv: Avoid explicit cpumask var allocation on stack Message-ID: <4E49057A4198779C+Zged+hXhxE4GksiL@centos8> References: <20240329105610.922675-1-dawei.li@shingroup.cn> <20240329105610.922675-2-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-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 Hi Eric, On Fri, Mar 29, 2024 at 02:21:28PM +0100, Eric Dumazet wrote: > On Fri, Mar 29, 2024 at 11:57 AM Dawei Li wrote: > > > > 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 > > --- > > net/iucv/iucv.c | 37 ++++++++++++++++++++++++++----------- > > 1 file changed, 26 insertions(+), 11 deletions(-) > > > > diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c > > index a4ab615ca3e3..b51f46ec32f9 100644 > > --- a/net/iucv/iucv.c > > +++ b/net/iucv/iucv.c > > @@ -520,14 +520,19 @@ static void iucv_setmask_mp(void) > > */ > > static void iucv_setmask_up(void) > > { > > - cpumask_t cpumask; > > + cpumask_var_t cpumask; > > int cpu; > > > > + if (!alloc_cpumask_var(&cpumask, GFP_KERNEL)) > > + return; > > This can not be right. iucv_setmask_up() is not supposed to fail. > > Since iucv_setmask_up() is only called with iucv_register_mutex held, > you could simply add a 'static' for @cpumask variable. Correct, iucv_register_mutex is a global lock and can serialize access on static cpumask var. I will respin V2 as you suggested. Thanks, Dawei > > > > > + > > /* Disable all cpu but the first in cpu_irq_cpumask. */ > > - cpumask_copy(&cpumask, &iucv_irq_cpumask); > > - cpumask_clear_cpu(cpumask_first(&iucv_irq_cpumask), &cpumask); > > - for_each_cpu(cpu, &cpumask) > > + cpumask_copy(cpumask, &iucv_irq_cpumask); > > + cpumask_clear_cpu(cpumask_first(&iucv_irq_cpumask), cpumask); > > + for_each_cpu(cpu, cpumask) > > smp_call_function_single(cpu, iucv_block_cpu, NULL, 1); > > + > > + free_cpumask_var(cpumask); > > } >