Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp655015lqo; Wed, 8 May 2024 10:33:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWF7GMzIaYVJPPC0CehDs+cUmLpEfzkr3z87pAYG2sottT1LfWWuipjDE1XhNduFzIARjoF/0ilykpoXOJpw8Mi7sWOFQc05lMxEb1QtQ== X-Google-Smtp-Source: AGHT+IEml29GUFRj1zIpZwyrIr0Fsez27XGlLynueWdx/M5f4Kf1xhF/Wet45F88cCcAy33sU399 X-Received: by 2002:a05:6871:2b1c:b0:23f:6353:a927 with SMTP id 586e51a60fabf-240985a297emr3584623fac.39.1715189611491; Wed, 08 May 2024 10:33:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715189611; cv=pass; d=google.com; s=arc-20160816; b=bUDphNo6LHHESERxxt+ol4bU+bos4f64cvY2Gr25XRcYx+oyqfwimJQNa6KyJhiPcT 7tsrZt2SfVNlHWsA5BMdrhD2fCCjxEphqUyfsk6GQjfyZbIMpAjlwBG0RbTOQHkNK/QL VsGr0q5dojboL45xxgiT4ExCVezfqNdN53nZwKQIC8pA6EoElG8gx8hPJbZzuogntb76 lje/fA93hnSm5RlYtDHlWGSv2f1So7mfDZNsRCARsrNYBUScinx1qwqcbZ+m0oftYKLU +q2ihIlwqMzg9hNS8UkUCeVOhvvhPW+u0nIeDwbVORSlcoqWspLdKpX8OEFLMfZ4+elO 6/6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=qFLJ8C/vJOy8ztY+ErSoPE9hPN1aNMGglndtw+goyc4=; fh=Jm256tzRRTVX3Ts4s97zGiIOk6WKPnmTv8sZ8hLufHY=; b=LD3gAyTGPCF/mH0lJ4s0DABDENaKvF+t5QwBihJsP/jiHcbHZUqnmVzguIdSXVfJXx QaSc7Bs7R4Bmgxqjjud/SW6ypRumuidhpKYXlIsjmtpMzjIAIrEtmwnI9bKeGvlxdi2a AfQTyS03Zf/AHjbiA4BPr6apLei2Y8wBsWk0t/BpM6cd7/bVkYH9zDDzgWcXbYbcIT2M UFkdCG1l2/r552ZQy5O/PZ7yHD0V7lPo6haHJgoettvdQV/dVUzu4mbCc/yntltWjX4X b381NrgA72tbnPwHhYprEwOIxK9kYDlL7h2oNo0SvLVR9YNIcX8IdkAgy0y7FRWliR53 8M0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gaisler.com header.s=unoeuro header.b=EMdtwJpD; arc=pass (i=1 spf=pass spfdomain=gaisler.com dkim=pass dkdomain=gaisler.com dmarc=pass fromdomain=gaisler.com); spf=pass (google.com: domain of linux-kernel+bounces-173635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gaisler.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f17-20020a05620a409100b00792912c81ecsi9832406qko.462.2024.05.08.10.33.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 10:33:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173635-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; dkim=pass header.i=@gaisler.com header.s=unoeuro header.b=EMdtwJpD; arc=pass (i=1 spf=pass spfdomain=gaisler.com dkim=pass dkdomain=gaisler.com dmarc=pass fromdomain=gaisler.com); spf=pass (google.com: domain of linux-kernel+bounces-173635-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173635-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gaisler.com 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 9837B1C2240D for ; Wed, 8 May 2024 17:33:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2778A12AAC7; Wed, 8 May 2024 17:32:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=gaisler.com header.i=@gaisler.com header.b="EMdtwJpD" Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) (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 BF2FF128806; Wed, 8 May 2024 17:32:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=94.231.106.210 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715189571; cv=none; b=usIEm1klYeprFes6Aa521qRopCWFRiYOC66A+/I98DI/w33vv238NOGel8my76JayE5M90Y+5pRzNwgZvJJX19W9JH0E1en8cOIXWOZCo/3h7DsjBiWAt14CugsAZB/+BlDmJpm9p3HlAFgIpIdRkqi3qlMEKCdpBAkvBtUM+JY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715189571; c=relaxed/simple; bh=PxR5CNx0YeCBV12sK3NEaQgIkG5iTrz7NBVUDZ1Z6l8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NpNggZo8thCs3ZYKpOJ2MLBuzsXT/MYCklWVT2ZQ+2CLCIzylmYm/728ZsX9wHentuB8w/X6lsnraiArMyVaDlLEmWzCLZmUHev7y2vKfs74iCfEkzaMoCB4BhZx5Gf//r9VJhLmji+kkJvIRIwog/i9Ao4v9rdh+G6GjXBD8dA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com; spf=pass smtp.mailfrom=gaisler.com; dkim=pass (1024-bit key) header.d=gaisler.com header.i=@gaisler.com header.b=EMdtwJpD; arc=none smtp.client-ip=94.231.106.210 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gaisler.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gaisler.com Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4VZMfg4H7Xz683x; Wed, 8 May 2024 19:32:43 +0200 (CEST) Received: from [192.168.0.25] (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by smtp.simply.com (Simply.com) with ESMTPSA id 4VZMfg2360z683f; Wed, 8 May 2024 19:32:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=unoeuro; t=1715189563; bh=qFLJ8C/vJOy8ztY+ErSoPE9hPN1aNMGglndtw+goyc4=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=EMdtwJpDLqaCLEUY9rcA4LKsuJBXljK6a+sSvt71da1bFK7iyJPuiPzQhOHvokuJm YrBWAJColD+H5mvb3FJOFhUipfhklisGeh29JpgZQbqcEDQIGM5C1o/W/j31R1xbfL +kU3aV1ZOmG7VcLoXxTVaQrlc5Or2HExzgHfI3Nk= Message-ID: Date: Wed, 8 May 2024 19:32:42 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 5/5] sparc/leon: Remove on-stack cpumask var To: Dawei Li , davem@davemloft.net Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, sam@ravnborg.org References: <20240424025548.3765250-1-dawei.li@shingroup.cn> <20240424025548.3765250-6-dawei.li@shingroup.cn> Content-Language: en-US From: Andreas Larsson In-Reply-To: <20240424025548.3765250-6-dawei.li@shingroup.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2024-04-24 04:55, Dawei Li wrote: > 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_subset() and cpumask_first_and() to avoid the need for a > temporary cpumask on the stack. > > Reviewed-by: Sam Ravnborg > Signed-off-by: Dawei Li > --- > arch/sparc/kernel/leon_kernel.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c > index 4c61da491fee..a43cf794bb1e 100644 > --- a/arch/sparc/kernel/leon_kernel.c > +++ b/arch/sparc/kernel/leon_kernel.c > @@ -106,13 +106,12 @@ unsigned long leon_get_irqmask(unsigned int irq) > #ifdef CONFIG_SMP > static int irq_choose_cpu(const struct cpumask *affinity) > { > - cpumask_t mask; > + unsigned int cpu = cpumask_first_and(affinity, cpu_online_mask); > > - cpumask_and(&mask, cpu_online_mask, affinity); > - if (cpumask_equal(&mask, cpu_online_mask) || cpumask_empty(&mask)) > + if (cpumask_subset(cpu_online_mask, affinity) || cpu >= nr_cpu_ids) > return boot_cpu_id; > else > - return cpumask_first(&mask); > + return cpu; > } > #else > #define irq_choose_cpu(affinity) boot_cpu_id Reviewed-by: Andreas Larsson Tested-by: Andreas Larsson Picking this up to my for-next. Thanks, Andreas