From nobody Tue Nov 26 18:31:10 2024 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 5E2A91C07C7; Wed, 16 Oct 2024 20:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729109050; cv=none; b=PAiOIAIBSGnAowzaqYZ86sjIbaFR/RI25hqEx+uZF0ytYZBRHTejBhn8qBFfy7eEBtQcvSnUnYZ+WlEwz6FzkuKakaBIrz2FXYUs+mRuHA3mqMq+3+jp/YAs5UVuxggyk+AaPB42u1XBvXy3L7IQBZwMI9npW8GXNhQneG9zBO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729109050; c=relaxed/simple; bh=NegUyxvPIo0AewzxC2v1Gngpcr9k6R3zwLsRFYw4zrc=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=lpjkBYyK8m6d48azvR1qjJ9EgLTDTMIiS/FqcCkN83DrgBQ40zu4j5LoAe/JKmWlVnuqsNgM5PMu2qEtM6td3VdN0hz4rHn6ug/6krfbPYrRrFSF4nbsyI6OtzMzI9ufCPuVnROp46rRsj0M9dBHP+A7wQfENe8hyu3vpq448wA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=19igvSdi; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=qRreb05J; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="19igvSdi"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qRreb05J" Date: Wed, 16 Oct 2024 20:04:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1729109046; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kJpJLWfqNlNMV6iR9mISRD3clYKlUQEro1oIxSOSwdA=; b=19igvSdivUvAz7BylmYUaXc4hHRPUCN6cBMK63Ycd8Etnqkv5Y7MO8G29dSsGHW8HqBL+T I96h2V/nLhb8hH0eJOxB3OS8mbmGah2cL+xKmjz1uP6zofbook62JzHiOrRHyBQI72KDwT ZrE1xyGfKNlEHeORsDPMM64GAGLhCLSds0fNrTS50ogbQ4UyfdaQIKS6BHCA95xX2jSRFY cbzjrLhU+E1O91O+XelnDrAK4CFh9M6E5y0iTA8L4IcmTZOKEbGJSTFD3YJ9etq6U/CgR1 5xwBcUjix4H/Eu8dnHB7VSTG+/Qw+6kKmuiuNG3vCym+yHsrEku1UKIOVv7ayQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1729109046; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kJpJLWfqNlNMV6iR9mISRD3clYKlUQEro1oIxSOSwdA=; b=qRreb05JqOMfNpAhHW+lkkJAADqjoRo20SQ2H0Py/h8U5upJwcPx/0oeBJ4ebEJ7u7ywyi 6q/FKEJFgySYK2CQ== From: "tip-bot2 for Bart Van Assche" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] genirq: Switch to irq_get_nr_irqs() Cc: Bart Van Assche , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20241015190953.1266194-22-bvanassche@acm.org> References: <20241015190953.1266194-22-bvanassche@acm.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <172910904397.1442.10984493492959840181.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the irq/core branch of tip: Commit-ID: 1ad2048bf7146efb83bc033147ca1611a7fe8494 Gitweb: https://git.kernel.org/tip/1ad2048bf7146efb83bc033147ca1611a= 7fe8494 Author: Bart Van Assche AuthorDate: Tue, 15 Oct 2024 12:09:52 -07:00 Committer: Thomas Gleixner CommitterDate: Wed, 16 Oct 2024 21:56:59 +02:00 genirq: Switch to irq_get_nr_irqs() Use the irq_get_nr_irqs() function instead of the global variable 'nr_irqs'. Cache the result of this function in a local variable in order not to rely on CSE (common subexpression elimination). Prepare for changing 'nr_irqs' from an exported global variable into a variable with file scope. Signed-off-by: Bart Van Assche Signed-off-by: Thomas Gleixner Link: https://lore.kernel.org/all/20241015190953.1266194-22-bvanassche@acm.= org --- include/linux/irqnr.h | 33 +++++++++++++++++++-------------- kernel/irq/irqdomain.c | 2 +- kernel/irq/proc.c | 3 ++- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h index 7419b80..a33088d 100644 --- a/include/linux/irqnr.h +++ b/include/linux/irqnr.h @@ -11,26 +11,31 @@ unsigned int irq_set_nr_irqs(unsigned int nr); extern struct irq_desc *irq_to_desc(unsigned int irq); unsigned int irq_get_next_irq(unsigned int offset); =20 -# define for_each_irq_desc(irq, desc) \ - for (irq =3D 0, desc =3D irq_to_desc(irq); irq < nr_irqs; \ - irq++, desc =3D irq_to_desc(irq)) \ - if (!desc) \ - ; \ - else - +#define for_each_irq_desc(irq, desc) \ + for (unsigned int __nr_irqs__ =3D irq_get_nr_irqs(); __nr_irqs__; \ + __nr_irqs__ =3D 0) \ + for (irq =3D 0, desc =3D irq_to_desc(irq); irq < __nr_irqs__; \ + irq++, desc =3D irq_to_desc(irq)) \ + if (!desc) \ + ; \ + else =20 # define for_each_irq_desc_reverse(irq, desc) \ - for (irq =3D nr_irqs - 1, desc =3D irq_to_desc(irq); irq >=3D 0; \ - irq--, desc =3D irq_to_desc(irq)) \ + for (irq =3D irq_get_nr_irqs() - 1, desc =3D irq_to_desc(irq); \ + irq >=3D 0; irq--, desc =3D irq_to_desc(irq)) \ if (!desc) \ ; \ else =20 -# define for_each_active_irq(irq) \ - for (irq =3D irq_get_next_irq(0); irq < nr_irqs; \ - irq =3D irq_get_next_irq(irq + 1)) +#define for_each_active_irq(irq) \ + for (unsigned int __nr_irqs__ =3D irq_get_nr_irqs(); __nr_irqs__; \ + __nr_irqs__ =3D 0) \ + for (irq =3D irq_get_next_irq(0); irq < __nr_irqs__; \ + irq =3D irq_get_next_irq(irq + 1)) =20 -#define for_each_irq_nr(irq) \ - for (irq =3D 0; irq < nr_irqs; irq++) +#define for_each_irq_nr(irq) \ + for (unsigned int __nr_irqs__ =3D irq_get_nr_irqs(); __nr_irqs__; \ + __nr_irqs__ =3D 0) \ + for (irq =3D 0; irq < __nr_irqs__; irq++) =20 #endif diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index e0bff21..ec6d8e7 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1225,7 +1225,7 @@ int irq_domain_alloc_descs(int virq, unsigned int cnt= , irq_hw_number_t hwirq, virq =3D __irq_alloc_descs(virq, virq, cnt, node, THIS_MODULE, affinity); } else { - hint =3D hwirq % nr_irqs; + hint =3D hwirq % irq_get_nr_irqs(); if (hint =3D=3D 0) hint++; virq =3D __irq_alloc_descs(-1, hint, cnt, node, THIS_MODULE, diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 9081ada..d226282 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -457,11 +457,12 @@ int __weak arch_show_interrupts(struct seq_file *p, i= nt prec) } =20 #ifndef ACTUAL_NR_IRQS -# define ACTUAL_NR_IRQS nr_irqs +# define ACTUAL_NR_IRQS irq_get_nr_irqs() #endif =20 int show_interrupts(struct seq_file *p, void *v) { + const unsigned int nr_irqs =3D irq_get_nr_irqs(); static int prec; =20 int i =3D *(loff_t *) v, j;