From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CFBA4C433EF for ; Tue, 21 Jun 2022 08:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vNhn/AVxGvx6GIkjAVwtjIwhC9/XdR1i1Bg8Sr1P3lY=; b=NEfBAokZx+zMZr Ybxr13bnujmoxeJRlCf+caRpkEZmckXvGNI0xSQ5FbWDJMny/bIKWVdOYxt7YvrrZ021s2ZxZ2xwQ aR2T5lp9cYZbMnArulupaTeTIkFJJx9ajFd+AqubC4L+fMu/Dc2y2pteMc5P72IMrt5YlrCgFpqUI Rk8H5D8ErebFE5N26JYvVGTmlGgvxmnPkScgSpOaO52lFsBM0m+IJn27UP7XnJW+iSn3wXy9PGQRY seV3KoEE8ClUaE/qBYRL6stoCekmIOLfV+YnNeJiccFrjCPLoPyCU1BcPnK8B509I4i18sedw8Z53 cRy4lYAd0qFBNpfSlL3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3Yu3-004I5R-Bw; Tue, 21 Jun 2022 08:06:27 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3Ytz-004I3L-FG; Tue, 21 Jun 2022 08:06:25 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D1253B816AD; Tue, 21 Jun 2022 08:06:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 831E4C3411D; Tue, 21 Jun 2022 08:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655798779; bh=8qCnewqKJmo59l8Sj5lCGp78mJervPUiBsnnQAaSXP8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Qkya9AELvEs7KfBcoqWIV90YtDor5KNTIHOQolDsiamDPj1nWG9NoZXtYf7Jky0Pk 1sTAYweIRfZUetfph6wzdC9h90W31Rss/4k13wb8D17EHfhxd5mF0tKKIfYMezWXTR y6E8omfbdSOqRHsr47icJOllfMcCaeZLa/qQTuVFyGIP5L2v+q09/gzttpo/n8ZeKU IjP7FiEcXL4vUcTwVGRLuiRP8/YwKvUU9AvgPI/h4nnVnNERnhMnvrJ8Zn3Qpg0CyW vlFJJfG0VMm/1Hi9PtWG3B4KEshMYyFlnH/Xga10WYVRH77YvspXYZMnlkD1gbZQ1v TQNoLtozhj5mQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1o3Ytt-001zIC-EW; Tue, 21 Jun 2022 09:06:17 +0100 Date: Tue, 21 Jun 2022 09:06:17 +0100 Message-ID: <87sfny30g6.wl-maz@kernel.org> From: Marc Zyngier To: Samuel Holland Cc: Thomas Gleixner , Palmer Dabbelt , Paul Walmsley , Albert Ou , Bartosz Golaszewski , Guo Ren , Mark Rutland , Russell King , Wei Xu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v2 4/6] genirq: Provide an IRQ affinity mask in non-SMP configs In-Reply-To: References: <20220616064028.57933-1-samuel@sholland.org> <20220616064028.57933-5-samuel@sholland.org> <87h74ipcos.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: samuel@sholland.org, tglx@linutronix.de, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, brgl@bgdev.pl, guoren@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, xuwei5@hisilicon.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220621_010623_893512_8F2DF20B X-CRM114-Status: GOOD ( 35.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 21 Jun 2022 05:03:43 +0100, Samuel Holland wrote: > > On 6/18/22 4:01 AM, Marc Zyngier wrote: > > Hi Samuel, > > > > On Thu, 16 Jun 2022 07:40:26 +0100, > > Samuel Holland wrote: > >> > >> IRQ affinity masks are not allocated in uniprocessor configurations. > >> This requires special case non-SMP code in drivers for irqchips which > >> have per-CPU enable or mask registers. > >> > >> Since IRQ affinity is always the same in a uniprocessor configuration, > >> we can still provide the correct affinity mask without allocating one > >> per IRQ. We can reuse the system-wide cpu_possible_mask. > >> > >> By returning a real cpumask from irq_data_get_affinity_mask even when > >> SMP is disabled, irqchip drivers which iterate over that mask will > >> automatically do the right thing. > >> > >> Signed-off-by: Samuel Holland > >> --- > >> > >> (no changes since v1) > >> > >> include/linux/irq.h | 6 ++++++ > >> 1 file changed, 6 insertions(+) > >> > >> diff --git a/include/linux/irq.h b/include/linux/irq.h > >> index 69ee4e2f36ce..d5e958b026aa 100644 > >> --- a/include/linux/irq.h > >> +++ b/include/linux/irq.h > >> @@ -151,7 +151,9 @@ struct irq_common_data { > >> #endif > >> void *handler_data; > >> struct msi_desc *msi_desc; > >> +#ifdef CONFIG_SMP > >> cpumask_var_t affinity; > >> +#endif > >> #ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK > >> cpumask_var_t effective_affinity; > >> #endif > >> @@ -881,7 +883,11 @@ static inline int irq_data_get_node(struct irq_data *d) > >> > >> static inline struct cpumask *irq_data_get_affinity_mask(struct irq_data *d) > >> { > >> +#ifdef CONFIG_SMP > >> return d->common->affinity; > >> +#else > >> + return &__cpu_possible_mask; > >> +#endif > > > > I have a bad feeling about this one. Being in a !SMP configuration > > doesn't necessarily mean that __cpu_possible_mask only contains a > > single CPU, specially with things like CONFIG_INIT_ALL_POSSIBLE. I can > > also imagine an architecture populating this bitmap from firmware > > tables irrespective of the SMP status of the kernel. > > > > Can't you use something like: > > > > return cpumask_of(0); > > > > which is guaranteed to be the right thing on !SMP configuration? > > I can if I cast away the const. However I see a lot of: > > cpumask_copy(irq_data_get_affinity_mask(d), foo); > > which I suppose is a great reason not to do what I am doing. Ah, indeed. Not going to work very well... > The right solution seems to be adding irq_data_update_affinity() to > match irq_data_update_effective_affinity(), and making both getters > return a const cpumask. Then I can use cpumask_of(0). Sounds like a plan. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel