From nobody Tue Sep 29 09:09:01 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 730F73A6B92; Mon, 10 Aug 2026 08:57:49 +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=1786352278; cv=none; b=H5fya/elL7+z/Ijx1u1FBD4jJsfO9GR5sC9D+p3sY7h74lYUh8I0TFwtCaQLW/j/PxHBsMhjCUJLYaA4oZsbcnOluyY/S/lmULul+pVw/fzj500wH86/Ysy4ANupIHNmR0zbYA1pcT0mCtRtxkmrbh65AQKEbsJaRzdS3TmGfwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786352278; c=relaxed/simple; bh=Py60t3J8PTYqkWnuyOGh3waqvvV2+ksOdhJhlXKg594=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=rI/Gdt68CXj51zfCk7yUrui3dkqXXR6mIeYhOHfoyaqbOnCge7yFEe178aZ3VXabpzFmnIQsfhYQmtBvmmaVH1Yz9812Wo/ZKAoxD2Q7cKOpHEhFq4F6VH44AUKVlvJUiru3Tq8oXM3r5eKNORcqt1V4IcyJGv8mnogKExLWAbo= 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=18axf5GC; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=5wLEOHTn; 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="18axf5GC"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="5wLEOHTn" Date: Mon, 10 Aug 2026 08:57:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1786352266; 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=FTJcNQTqyx5Xi6NyBGuBw4Kk1WopRCOSYCEdedAg6vs=; b=18axf5GC8mfQf6XnIA32BSADJQDspFnK1Qkb1U1XAFQLqp8EsB419LpsyRONkNljjTLo+W nQMRjWSRdl0D/b/KvbzOhQsTHCyM+5elGUMxsXhsp2HQlF7B+izh56kqACBJeDRCNO2hI3 yJD+D3JyL4O+/aex87mFumLqquiniRtDbe0AuiJtSlynzydso5L0KiDJ0T0ifjsOzsSb0u B40b79LA4UbNBGeQNnWXV6E+Kpw/lsg+SP/FZ5lCibrTCLZTMQvP/llxs+yAl4GEyVfwb8 nS6jt9HDSqqv+LqOzexvu/lpOOUJb14hmqCUSgDbDjbKFQ1SzeeQPOv3OsqDqA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1786352266; 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=FTJcNQTqyx5Xi6NyBGuBw4Kk1WopRCOSYCEdedAg6vs=; b=5wLEOHTnDHRXXOWlFaHTDXibrfJGC6dxUP2MQLWPbARpPVzVEsQnCE2jFzUr/8nwlEhGl+ yE5ZpjhgwSTpD1AQ== 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: <178635226529.442315.10340892158658145846.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: 07a88e2bcd5b5bd7881b2e12b6aad1897a7ee1de Gitweb: https://git.kernel.org/tip/07a88e2bcd5b5bd7881b2e12b6aad1897= a7ee1de Author: Lyude Paul AuthorDate: Tue, 04 Aug 2026 09:14:28 -07:00 Committer: Peter Zijlstra CommitterDate: Mon, 10 Aug 2026 10:50:18 +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");