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 3C475C433EF for ; Sat, 18 Jun 2022 09:03:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231192AbiFRJDI (ORCPT ); Sat, 18 Jun 2022 05:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbiFRJDG (ORCPT ); Sat, 18 Jun 2022 05:03:06 -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 6590D101E3 for ; Sat, 18 Jun 2022 02:03:04 -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 091A0B81440 for ; Sat, 18 Jun 2022 09:03:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A834CC3411A; Sat, 18 Jun 2022 09:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655542981; bh=G2NVbw5GE1KUhRgKcRWq5GgSU83SgY43XdstIbqHLgw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hsZdCg4KciT1MCynTN15yLnPrAMI9/GR5LX/K1fDWZ+2jyhgqSbOm6WmbHsiK0wxO VUmi60QwaPkk8nhlcTGsmwJnUsfpGeQ4IjJG4eVZwBtH2sg3Fe+O2EtP0XpbnzKjcD O6JRKI6BS1qI9ex+8CXOIP92rCqIyOI05VEOPDPCfdsEbnOzZDMuOLsn2SoOg462V5 Hf1uuKJ5LKd4Jm2F7gBMihn1aVgiAAYGDClGLK8WnG7dSS2VRLIrNCFZnWJchegUDq /WGUI0MUa4u2ViBuvVuVm2FbJtk2Eo8wNVmSND5aKlggLSpKDSrb1sZSaQFgYTMl7y ctyVQWmXxEXyg== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.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 1o2ULA-001RtF-1J; Sat, 18 Jun 2022 10:02:59 +0100 Date: Sat, 18 Jun 2022 10:01:55 +0100 Message-ID: <87h74ipcos.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: <20220616064028.57933-5-samuel@sholland.org> References: <20220616064028.57933-1-samuel@sholland.org> <20220616064028.57933-5-samuel@sholland.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 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? Thanks, M. -- Without deviation from the norm, progress is not possible.