From nobody Tue Sep 29 10:32:56 2026 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 AB5B237E2E6; Sat, 8 Aug 2026 20:48:33 +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=1786222115; cv=none; b=lyWhXAOl3rx9p1cGUyyLBkSZ67PhIfhqA8FPm9/35GST4WaQQNenKQOv2Iq4V6WgFg26omiyiJ/qWBsegMifch0SqVgZC+A0onf3AgMxx7VkGPgY8UK3mFbxfyZ2hyrkvCaDoM7kf9DUU6Hd8R58Ei+OjWTvnsLCRAh/0wksVos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786222115; c=relaxed/simple; bh=zfXdKzR4hMUaS+nAryjBTX092CKjX6TbN2HKXpLkC84=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=H/g44Cn05UYCXK7bD6x23j9zO87fenjuBoB9+HnlHgTkhs8M4hFWLUJoehJhDzC1oyLi+Rv9Q66jA/OFNEuJoqus8SjsbrdfmfzPFnz2iNVDHEh23E5kQk9ts9DSmZutog0Y2cVaRZ4k7qVKEpaFHV5zWPWj4QOJWhO67P1Tlws= 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=ebR8V1Sh; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PAi7yrQW; 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="ebR8V1Sh"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PAi7yrQW" Date: Sat, 08 Aug 2026 20:48:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786222111; 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=nQqaGKoX4+QoOhwPp73UTbU2y8CyV5zjYCIkgL1C0E0=; b=ebR8V1ShHcSLM+xdDYrBxx9kJknMdTo49JW2b2fGyI8UP7ltHKHIh4culiqd5vjAsAR9uq URl/VT0e41MlcrnLup1KDELxNAeBA4ZE1XrMieQhcIdW8Vf7rzlg5Rzz6eoNvTCg56XnPW 5G9VX56QOlLOUGzetJKE04h4fVx2XrnBzrQlod0hI5VmK3IeocH+qmtYIjmkFQir+qp/lV Nf8/4Jo6NvhT8Hn3xy7+Z/oMNQILB0/iPus0IIcQGYzTVInRp3HBiOfAdGGEoSN7HXkUXg YdWitIOM/ad/wx/MtdHvDIT9u7feIh0ylXqBjLd7pmtNLvCkERd0LCNtgYYCBA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786222111; 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=nQqaGKoX4+QoOhwPp73UTbU2y8CyV5zjYCIkgL1C0E0=; b=PAi7yrQWQPwHwvhO25NP1tJh/ZpoR90XlABG5ftlrmE0gX5JBCvGilyW7sf98XIrEWDfho WWE5/4vDlt32+rBQ== From: "tip-bot2 for Lyude Paul" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] irq: Add KUnit test for refcounted interrupt enable/disable Cc: Lyude Paul , Boqun Feng , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260804161447.84806-7-boqun@kernel.org> References: <20260804161447.84806-7-boqun@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178622210952.442315.15156943601588382807.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 locking/core branch of tip: Commit-ID: 417f9684716b6577c717b09337e14040a1a067f2 Gitweb: https://git.kernel.org/tip/417f9684716b6577c717b09337e14040a= 1a067f2 Author: Lyude Paul AuthorDate: Tue, 04 Aug 2026 09:14:28 -07:00 Committer: Peter Zijlstra CommitterDate: Sat, 08 Aug 2026 22:44:07 +02:00 irq: Add KUnit test for refcounted interrupt enable/disable While making changes to the refcounted interrupt patch series, at some point on my local branch I broke something and ended up writing some kunit tests for testing refcounted interrupts as a result. So, let's include these tests now that we have refcounted interrupts. Signed-off-by: Lyude Paul Signed-off-by: Boqun Feng Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260804161447.84806-7-boqun@kernel.org --- kernel/irq/Makefile | 1 +- kernel/irq/refcount_interrupt_test.c | 109 ++++++++++++++++++++++++++- 2 files changed, 110 insertions(+) create mode 100644 kernel/irq/refcount_interrupt_test.c diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile index 86a2e5a..44c4d6f 100644 --- a/kernel/irq/Makefile +++ b/kernel/irq/Makefile @@ -16,3 +16,4 @@ obj-$(CONFIG_SMP) +=3D affinity.o obj-$(CONFIG_GENERIC_IRQ_DEBUGFS) +=3D debugfs.o obj-$(CONFIG_GENERIC_IRQ_MATRIX_ALLOCATOR) +=3D matrix.o obj-$(CONFIG_IRQ_KUNIT_TEST) +=3D irq_test.o +obj-$(CONFIG_KUNIT) +=3D refcount_interrupt_test.o diff --git a/kernel/irq/refcount_interrupt_test.c b/kernel/irq/refcount_int= errupt_test.c new file mode 100644 index 0000000..ca904db --- /dev/null +++ b/kernel/irq/refcount_interrupt_test.c @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * KUnit test for refcounted interrupt enable/disables. + */ + +#include +#include + +#define TEST_IRQ_ON() KUNIT_EXPECT_FALSE(test, irqs_disabled()) +#define TEST_IRQ_OFF() KUNIT_EXPECT_TRUE(test, irqs_disabled()) + +/* =3D=3D=3D=3D=3D Test cases =3D=3D=3D=3D=3D */ +static void test_single_irq_change(struct kunit *test) +{ + local_interrupt_disable(); + TEST_IRQ_OFF(); + local_interrupt_enable(); +} + +static void test_nested_irq_change(struct kunit *test) +{ + local_interrupt_disable(); + TEST_IRQ_OFF(); + local_interrupt_disable(); + TEST_IRQ_OFF(); + local_interrupt_disable(); + TEST_IRQ_OFF(); + + local_interrupt_enable(); + TEST_IRQ_OFF(); + local_interrupt_enable(); + TEST_IRQ_OFF(); + local_interrupt_enable(); + TEST_IRQ_ON(); +} + +static void test_multiple_irq_change(struct kunit *test) +{ + local_interrupt_disable(); + TEST_IRQ_OFF(); + local_interrupt_disable(); + TEST_IRQ_OFF(); + + local_interrupt_enable(); + TEST_IRQ_OFF(); + local_interrupt_enable(); + TEST_IRQ_ON(); + + local_interrupt_disable(); + TEST_IRQ_OFF(); + local_interrupt_enable(); + TEST_IRQ_ON(); +} + +static void test_irq_save(struct kunit *test) +{ + unsigned long flags; + + local_irq_save(flags); + TEST_IRQ_OFF(); + local_interrupt_disable(); + TEST_IRQ_OFF(); + local_interrupt_enable(); + TEST_IRQ_OFF(); + local_irq_restore(flags); + TEST_IRQ_ON(); + + local_interrupt_disable(); + TEST_IRQ_OFF(); + local_irq_save(flags); + TEST_IRQ_OFF(); + local_irq_restore(flags); + TEST_IRQ_OFF(); + local_interrupt_enable(); + TEST_IRQ_ON(); +} + +static struct kunit_case test_cases[] =3D { + KUNIT_CASE(test_single_irq_change), + KUNIT_CASE(test_nested_irq_change), + KUNIT_CASE(test_multiple_irq_change), + KUNIT_CASE(test_irq_save), + {}, +}; + +/* init and exit are the same. */ +static int test_init(struct kunit *test) +{ + TEST_IRQ_ON(); + + return 0; +} + +static void test_exit(struct kunit *test) +{ + TEST_IRQ_ON(); +} + +static struct kunit_suite refcount_interrupt_test_suite =3D { + .name =3D "refcount_interrupt", + .test_cases =3D test_cases, + .init =3D test_init, + .exit =3D test_exit, +}; + +kunit_test_suite(refcount_interrupt_test_suite); +MODULE_AUTHOR("Lyude Paul "); +MODULE_DESCRIPTION("Refcounted interrupt unit test suite"); +MODULE_LICENSE("GPL");