From nobody Thu Oct 2 06:30:12 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CFB8930146D; Mon, 22 Sep 2025 08:28:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529727; cv=none; b=FgFEIhvK9/e9VnqpPjzmdiwDCeoopn7XdEWOcwiYdy7jBcyMR1BVGi+Z0xU2yBJz1ZTOEQUXJM5Ufn9b6hubUNdk0WNxeqNeuP0ngIWAZw7yYiY4ssQEbFvrGV2MVFiM0tWebZpgEmjCMmgnhJj/Jhb+kq8jVhCbncyDVeBHtas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758529727; c=relaxed/simple; bh=wUb93rzYZ46AvuCm0nEYQtzHfIxnso9k5I5Egiwv/gQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RM8gXHVHzYF3yyJGedEbYj6QKJAV61u4Yo3vvPHiIYCv8PgBJX+ajTjQV7ZD18xkPLMNqhjlud9Uu0fOpOarI+4yEhNl4Dt+6iU4ZWmLf+WxMHqdlCNp1OkfkJ9ruQ1YB2DYA39vahlYO5lMqsJJfSn3DJlcSIByKINdbUpACbk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gPj0XVCk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gPj0XVCk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A7FEC4CEF0; Mon, 22 Sep 2025 08:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758529727; bh=wUb93rzYZ46AvuCm0nEYQtzHfIxnso9k5I5Egiwv/gQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPj0XVCkEY3x4shdXEnzhoTL7NxkNREGUzFf8D3rcwHTKETiXq8Ed8rAQlLxLcUam NQGslrB+b/FMJ9fxRTXCbcjFNIxpuEGhsp+Ajo8+1AgmnelN8IHr5qrkbY6jneyHjD 3uFFC8QH8EP1A31L2HeE7+3HD+rqlv370zdTS79No4YEIG8szNkYKPgCb/F8BtvoQH 7uDlzDnQRTvIQFbq1/iYR8vjMBZK3bj/riaD/LIwzFX+m97Uw8v8BtvreE/HHHCxWr X1IEZX5KmcflnYFfOXSQ17oGA4cKPkID5o1EOUowoU+3D3uBVubqSA/MvsrHMEBks5 svtC3kXC4vBNw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1v0buf-00000008Kds-1gEz; Mon, 22 Sep 2025 08:28:45 +0000 From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org Cc: Thomas Gleixner , Mark Rutland , Will Deacon , "Rafael J. Wysocki" , Rob Herring , Saravana Kannan , Greg Kroah-Hartman , Sven Peter , Janne Grunau , Suzuki K Poulose , James Clark , Jonathan Cameron Subject: [PATCH v3 13/26] genirq: Factor-in percpu irqaction creation Date: Mon, 22 Sep 2025 09:28:20 +0100 Message-ID: <20250922082833.2038905-14-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250922082833.2038905-1-maz@kernel.org> References: <20250922082833.2038905-1-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, tglx@linutronix.de, mark.rutland@arm.com, will@kernel.org, rafael@kernel.org, robh@kernel.org, saravanak@google.com, gregkh@linuxfoundation.org, sven@kernel.org, j@jannau.net, suzuki.poulose@arm.com, james.clark@linaro.org, jonathan.cameron@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Content-Type: text/plain; charset="utf-8" Move the code creating a per-cpu irqaction into its own helper, so that future changes to this code can be kept localised. At the same time, fix the documentation which appears to say the wrong thing when it comes to interrupts being automatically enabled (percpu_devid interrupts never are). Reviewed-by: Jonathan Cameron Signed-off-by: Marc Zyngier --- kernel/irq/manage.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index c94837382037e..d9ddc30678b5d 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -2442,6 +2442,24 @@ int setup_percpu_irq(unsigned int irq, struct irqact= ion *act) return retval; } =20 +static +struct irqaction *create_percpu_irqaction(irq_handler_t handler, unsigned = long flags, + const char *devname, void __percpu *dev_id) +{ + struct irqaction *action; + + action =3D kzalloc(sizeof(struct irqaction), GFP_KERNEL); + if (!action) + return NULL; + + action->handler =3D handler; + action->flags =3D flags | IRQF_PERCPU | IRQF_NO_SUSPEND; + action->name =3D devname; + action->percpu_dev_id =3D dev_id; + + return action; +} + /** * __request_percpu_irq - allocate a percpu interrupt line * @irq: Interrupt line to allocate @@ -2450,9 +2468,9 @@ int setup_percpu_irq(unsigned int irq, struct irqacti= on *act) * @devname: An ascii name for the claiming device * @dev_id: A percpu cookie passed back to the handler function * - * This call allocates interrupt resources and enables the interrupt on the - * local CPU. If the interrupt is supposed to be enabled on other CPUs, it - * has to be done on each CPU using enable_percpu_irq(). + * This call allocates interrupt resources, but doesn't enable the interru= pt + * on any CPU, as all percpu-devid interrupts are flagged with IRQ_NOAUTOE= N. + * It has to be done on each CPU using enable_percpu_irq(). * * @dev_id must be globally unique. It is a per-cpu variable, and * the handler gets called with the interrupted CPU's instance of @@ -2477,15 +2495,10 @@ int __request_percpu_irq(unsigned int irq, irq_hand= ler_t handler, if (flags && flags !=3D IRQF_TIMER) return -EINVAL; =20 - action =3D kzalloc(sizeof(struct irqaction), GFP_KERNEL); + action =3D create_percpu_irqaction(handler, flags, devname, dev_id); if (!action) return -ENOMEM; =20 - action->handler =3D handler; - action->flags =3D flags | IRQF_PERCPU | IRQF_NO_SUSPEND; - action->name =3D devname; - action->percpu_dev_id =3D dev_id; - retval =3D irq_chip_pm_get(&desc->irq_data); if (retval < 0) { kfree(action); @@ -2546,16 +2559,11 @@ int request_percpu_nmi(unsigned int irq, irq_handle= r_t handler, if (irq_is_nmi(desc)) return -EINVAL; =20 - action =3D kzalloc(sizeof(struct irqaction), GFP_KERNEL); + action =3D create_percpu_irqaction(handler, IRQF_NO_THREAD | IRQF_NOBALAN= CING, + name, dev_id); if (!action) return -ENOMEM; =20 - action->handler =3D handler; - action->flags =3D IRQF_PERCPU | IRQF_NO_SUSPEND | IRQF_NO_THREAD - | IRQF_NOBALANCING; - action->name =3D name; - action->percpu_dev_id =3D dev_id; - retval =3D irq_chip_pm_get(&desc->irq_data); if (retval < 0) goto err_out; --=20 2.47.3