Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1211971lqt; Sat, 20 Apr 2024 05:41:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWCCubypYwrEDQfdp3jkRohV1n6HqCOjitONzdNF0tsXwO9ECKaRWKfJzzIk/cwSY9/wgQCnd8Sdyawll0egYVaYUA+ZoZrgXP2F3hPyQ== X-Google-Smtp-Source: AGHT+IGxftY/cjRT/UFz8oQNVVBuAcRayPWK+DQ/ZSlzwxJ9WHJuuHe7uJk8KJw6b2Y/+1rfWQiM X-Received: by 2002:a05:6a21:328f:b0:1a7:5100:7559 with SMTP id yt15-20020a056a21328f00b001a751007559mr6724591pzb.32.1713616875919; Sat, 20 Apr 2024 05:41:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713616875; cv=pass; d=google.com; s=arc-20160816; b=wxW4eQmQmX/FLxt4ZCWSUxDKdlZnkrMiP13ozC06kYT0/rpalJ6D3TiW6US6j7jBYn 4Vck7pSRsWYX+nLfu1gVfOJUPiM+tvbB44T9wB/L1oP52y9cHJSYJKqnm+6Hs+OWJ1Xr ddw40nlG5lolWTtxx0FihiHhqfSZXA7bZXIFnu6gX2/D6N6iXse2wF/4PKBbFsn2C1bN tncmKwWRCcDfHtMjfrWB69Jxc67kDEJaSIXqwjVHKIL+KxF4Am+T06yno0EvzHTPjPkB GhXBliFR61bq0SdST4f/2+sy79JnKkFMXXZwOR9WhPGy+rSNp4yKTpIvPN1xPruTUkNi +c3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=nWCbwvo1uo83UNZFGd9WmKa4miqwEJNzC1UhPZb6JUo=; fh=1jjd/CvD+Z2W8HLWXZN5YIYg9x9kG7zaJgJi1INjUWA=; b=tmRM3tIF3D8XjWGHFRwLDdUJQSMBxRnkBsVG15hTkbM6X1+ugJLTu0YAHeurFjz7og 5brLBjoVxs5cFirvJL3mUm4tgRonYpD5PAv8CPrbXUxSfweKdZjI7/XdgN4nhS/kwyl7 UvkOPDa+ftwEeUfdqZ8jbJspiIQoau5RLE7kmM/JfILzfPQ+tOAdj72Sbxwq3xkSIBZL c93NwO5MOSwnablPkDNVnhZH+jsyWEoqRwI7sQOmEyU2EhRNcFV5MAiHoUcYVjZoXrfN TRcWvfxKjLT3Y29ihgEkVziyHb8Jo6IQqG/nm1+4dKQdLAtfLHhKoScXBQ+AVGntTH3W tBPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ravnborg.org header.s=rsa1 header.b=coeI7fYn; dkim=neutral (no key) header.i=@ravnborg.org header.s=ed1 header.b=8IoaAiqw; arc=pass (i=1 dkim=pass dkdomain=ravnborg.org); spf=pass (google.com: domain of linux-kernel+bounces-152177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152177-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id gk9-20020a056a00848900b006ecfdfb8281si4670044pfb.237.2024.04.20.05.41.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 05:41:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ravnborg.org header.s=rsa1 header.b=coeI7fYn; dkim=neutral (no key) header.i=@ravnborg.org header.s=ed1 header.b=8IoaAiqw; arc=pass (i=1 dkim=pass dkdomain=ravnborg.org); spf=pass (google.com: domain of linux-kernel+bounces-152177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152177-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6B68DB21A8C for ; Sat, 20 Apr 2024 08:33:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 733A9107B2; Sat, 20 Apr 2024 08:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ravnborg.org header.i=@ravnborg.org header.b="coeI7fYn"; dkim=permerror (0-bit key) header.d=ravnborg.org header.i=@ravnborg.org header.b="8IoaAiqw" Received: from mailrelay4-1.pub.mailoutpod3-cph3.one.com (mailrelay4-1.pub.mailoutpod3-cph3.one.com [46.30.211.243]) (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 D6C4917F3 for ; Sat, 20 Apr 2024 08:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.30.211.243 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713601995; cv=none; b=KkfCDhi7nCMtQIcclPl2IjKmvt4ZNReET6ELkxfRbJlxZREp5aVSU1Yi0H133jT6jVs1mYFx17HD3bal1eM4sV0RtsX+dBj7aHLg7xiPXgaFREwsivXeRf/8Pbbm8wgL9oGZT+IeBfcJNlbClNcEY9DGSBU1AODJeVMJD4ZQbpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713601995; c=relaxed/simple; bh=4x68Wh4z9wJz89EDOwn5nMgn6u9lCHiLHM+sU2wqKNY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=r/db+o8arspuaDR+6u4F3cXydJLmKKTcnmUzST7o7ZSbHeGdSoUF87pUGjRoU6MQCybmwJ0ck857hdoaYzTpTYz/dzFxFmcvqEdcv88I8p0+PlYyO9n7zGKSE4LDwEvBklwO+YyczAbLQ+ejlAV3AK5y5GisBl65No0QXsKU3mE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org; spf=none smtp.mailfrom=ravnborg.org; dkim=pass (2048-bit key) header.d=ravnborg.org header.i=@ravnborg.org header.b=coeI7fYn; dkim=permerror (0-bit key) header.d=ravnborg.org header.i=@ravnborg.org header.b=8IoaAiqw; arc=none smtp.client-ip=46.30.211.243 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ravnborg.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ravnborg.org; s=rsa1; h=in-reply-to:content-type:mime-version:references:message-id:subject:cc:to: from:date:from; bh=nWCbwvo1uo83UNZFGd9WmKa4miqwEJNzC1UhPZb6JUo=; b=coeI7fYnLnH6DhNSuoGk9V3zCKSEMFHvx0g7KTK7JSsvvAF1M3Pu8VaWpseIskFGCAd73NWOmVgMt lbpQq9XRU0wsmfUbN5RGu9zdADJ82cLSbMIADzFW94YysrGkUjDK9+/fHj+zE+NVLhtZ1p0w+yE0dj DPX2Q8SOK50bdMFSHbyVqRJ7PnMPa1HUYDDeI8CDSzlGJKeLRgc0BAreTp/TCoMXTLE8SbNR7495no UHgUrsBHg94NAa7zP4Rt3X5r1BmIlKrxyljqqQ6XWFF/JGrLbfHeuBfgHp74ln6NeXLjeaiCnLu57t UiCYpFTKjvaHHYqazaqDRZLbZHvT1Tw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ravnborg.org; s=ed1; h=in-reply-to:content-type:mime-version:references:message-id:subject:cc:to: from:date:from; bh=nWCbwvo1uo83UNZFGd9WmKa4miqwEJNzC1UhPZb6JUo=; b=8IoaAiqwyBghZ/zBs/cDDTHZvwCqyzoaRearXX+FsuFHNMVBA6zwSme9IXgWDCA2cUvcxDJ3Dj56Q fP3uPs/Dg== X-HalOne-ID: 7563e990-fef0-11ee-a0f9-591fce59e039 Received: from ravnborg.org (2-105-2-98-cable.dk.customer.tdc.net [2.105.2.98]) by mailrelay4.pub.mailoutpod3-cph3.one.com (Halon) with ESMTPSA id 7563e990-fef0-11ee-a0f9-591fce59e039; Sat, 20 Apr 2024 08:32:03 +0000 (UTC) Date: Sat, 20 Apr 2024 10:32:02 +0200 From: Sam Ravnborg To: Dawei Li Cc: davem@davemloft.net, andreas@gaisler.com, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 6/7] sparc/leon: Remove on-stack cpumask var Message-ID: <20240420083202.GF614130@ravnborg.org> References: <20240420051547.3681642-1-dawei.li@shingroup.cn> <20240420051547.3681642-7-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=us-ascii Content-Disposition: inline In-Reply-To: <20240420051547.3681642-7-dawei.li@shingroup.cn> On Sat, Apr 20, 2024 at 01:15:46PM +0800, 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. > > Signed-off-by: Dawei Li > --- > arch/sparc/kernel/leon_kernel.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c > index 4c61da491fee..0070655041bb 100644 > --- a/arch/sparc/kernel/leon_kernel.c > +++ b/arch/sparc/kernel/leon_kernel.c > @@ -106,13 +106,10 @@ 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)) > - return boot_cpu_id; > - else > - return cpumask_first(&mask); > + return cpumask_subset(cpu_online_mask, affinity) || cpu >= nr_cpu_ids ? > + boot_cpu_id : cpu; This looks wrong - or if it is correct is is hard to parse. Drop ?: and use an if so the code is more readable. Sam