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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD652C43334 for ; Tue, 21 Jun 2022 08:06:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348022AbiFUIG0 (ORCPT ); Tue, 21 Jun 2022 04:06:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348029AbiFUIGW (ORCPT ); Tue, 21 Jun 2022 04:06:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 029112496F for ; Tue, 21 Jun 2022 01:06:22 -0700 (PDT) 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 BA776B8169E for ; 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") Content-Type: text/plain; charset=US-ASCII 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.