From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796065888; b=ittljzvt47xl/S2ouiyAj3gTWb5UmFfkeGcjsrAZcwEMYjgXgAFB58JCvafXasRd7NlY CmrtUNNSSQxbH9iSZW5EIoJq1ovT7kL4u1vVz8tgclM6H40grcg4Kqlg2XY9vh4+H8Pwk Ph+z9/L1yG7iiWPJ93tFWCsnSkz9vg/XyXtNWpkCFvpwYTcDROGd/HEaT/XQ15hxbM64H VIkDy7hqjfGUNWt1a1o8tEXUWyf7PJoV9GYSrhfdgNwblkOwUuUq+6jPLDzKYZtPUsaTS OdHT2hFDFvlUXWKCVGkUiZpmUL2JyFVEX6uaDUack62Vm995HHZ9Z1oOO/YLKTEndfw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796065888; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=kU7YeMuXUrpg5e9pszobEqUqr/6foh3/v7LXuaREzng=; b=ddMjQCrYlpRd4gThrRMZ9Cw8gIvpaEVZU/wP+XoRE8cuiyfz4W4BxEV+8DxxBWm8aNSu Q6xNuEWen3Yt1/f2C9twEcCt8HA8ewnZ3J0Epj+iEljenTFQaIH0QFbEfrUydgrFVJBT9 LcfD23JsHr5N1mFSyQu/Mt9uha1N6k6+qp7UmvsTRU6NCKq3SR0hpTOr2KHN7ye7VmsKs sP12rmPVXtLWMuyM24ivSSkCBoINPp49KMMVpscpY/GW2QRVzcwL0ehPRxStm0y2Xd+Kl lIZz1mjch7aRdTGFn5nm3YxgzRx81/kfZ9nzUCKG5BrfaDqexjRP0pocQKBclmmKStQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=oVH1eu6D; arc=none smtp.remote-ip=74.125.82.171 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2106B606A31C for ; Mon, 30 Nov 2026 19:11:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2106B606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=oVH1eu6D Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-3869f03af6aso10172497eec.1 for ; Mon, 30 Nov 2026 11:11:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1796065887; x=1796670687; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=kU7YeMuXUrpg5e9pszobEqUqr/6foh3/v7LXuaREzng=; b=oVH1eu6DcRhQpo32s9vtB6WVrQniI2+/AMq3DDUGQ0VgXIMwZjHSZIWE0s7kL6qeTP EbpthCAEP1jW9vUq5jsWxnd4Tp6IOyGTkpp2sh5th0jo7+RDOrnIl781ZQzf818Hlbfj AEq3nENWu/Aul8TLyRbhUeFSgASuSqn3wn/u4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796065887; x=1796670687; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=kU7YeMuXUrpg5e9pszobEqUqr/6foh3/v7LXuaREzng=; b=FcRVgSj5W6wK5fNZy1gRUN9CA4fWAQ9aKRMeQAiZZwGPCdpq+pzlm9BkLrKMXr518o 2Yv1OHtY2NnY1x9EWgjDvHv5O9cAkKcVidb+d4qoUFCE51jBE0oIBQVTgI2WoOGSly3l GXN6uIP8FfpCX2d7wxVvyKMdQRmLI9kMIPU4+NLSFRh8K29ID/vWZub9SQtnj2gfQFIh /2y7WC5jWJ3lvH2NUovdBa7falN2YMQV4wCtTDJFQXIhQ4WrLRKIR35wCG3cLDdyVqjR q3sLI+6JLepQxkKqXAjCs78zzWU/+rgEk4QfhpD8of9TDS/OyN03Y3jdw2yW+GmLrylz YDjA== X-Forwarded-Encrypted: i=1; AL+hErHTjiTAdEhyfVnbjBLvZAMnpupOso3Ai0W5FLE4kJ1JuBZbd1fVWdqowGuHdnFvPFN6DdtPHUw28dYkw5c=@vger.kernel.org X-Gm-Message-State: APuU4Z+ZW3qBfz6RBBcKbbiz5KcfCYv6uQuuV33qncBy5t4HKrHMsl2V G97SUJ8hUL7P+TBE8rp0BNL7ULeIvSDWvupgyBPPeMDdfDd2cmo1FU6WAGyXj2xbAA== X-Gm-Gg: AZFdTZd4umw2Y0eRprRFOy1FZ2CPEGVIEav5VEzX6RCP3BIzNagYfu4Hu7uCSAcqfog q172FAs8bpaRv6FVlEhQYfytnl+iLUgJB7evMgzG5C00pLlyrhWMG9qBXL53jQ/aZsVllt5kxhk 3e0PqweCKZ5w7rZfDCdyidO0uOh8DMztsqbLAoR3MxDTP29Hd97HacT9Z2/56NF517DYicuINsA N9uhNNGU4bxd1+puVCYPbMfmaJHDqNLHmxPVVg8sj7jDBXGnKH1uXByEuhwxLmBFiv1+NOdv/jG qDy1Z7Pbs6FFKydLKS4trjHmwD3ppFh6iKaBIdyHJ8eM1qsqCg3DF/A8ebmGWTTpRk1C0Fyg469 xnBxJQrs9LdAEuX68TxWZQ9ngfrwcQpLRLkqRcupkg29tJmNa95C0ScVgk3xCyVfdNcQKh7CuQb Lh26MeUmJaACmGVeco6YkvaSYp+ZeGU9hnoBKdaBPEFE4jeHazWZseZy0k0vYjGGrZUzzOkmBM8 asCBgkHbLztGagD+c3isVty6KDkaszcLsmUUOExQlhYmeXhntfkmp1RFfDngs+5NDysfVe0a0LV IfWlQpwfoFe5bFISY5jZ0JvLiPynoBxAuvC4zU9H0E1RYzP/ic7ezGjDO10sXjFZLKBDZw== X-Received: by 2002:a05:7300:50fa:b0:383:9f52:e54d with SMTP id 5a478bee46e88-3856ff52e83mr35869140eec.8.1796065887099; Mon, 30 Nov 2026 11:11:27 -0800 (PST) Received: from localhost ([2a00:79e0:2e7c:8:d64c:d468:46b8:64da]) by smtp.gmail.com with UTF8SMTPSA id 5a478bee46e88-386c7c62a91sm62585168eec.17.2026.11.30.11.11.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 11:11:26 -0800 (PST) Date: Mon, 30 Nov 2026 11:11:24 -0800 From: Brian Norris To: Xiaolei Wang Cc: tglx@kernel.org, radu@rendec.net, linux@roeck-us.net, davidgow@google.com, linux-kernel@vger.kernel.org, geert@linux-m68k.org, kunit-dev@googlegroups.com Subject: Re: [PATCH] genirq/test: Release fake irq descriptors after KUnit tests Message-ID: References: <20261130104426.1384855-1-wangxiaolei01@kaihong.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261130104426.1384855-1-wangxiaolei01@kaihong.com> On Mon, Nov 30, 2026 at 10:44:26AM +0000, Xiaolei Wang wrote: > Each of the four irq_test_cases cases allocates a virtual interrupt via > irq_domain_alloc_descs() in irq_test_setup_fake_irq(), but only calls > free_irq() at the end. free_irq() releases the irqaction, not the > descriptor, so every run of the suite leaves 4 fake irq descriptors behind. > Each leaked descriptor keeps its debugfs node alive at > /sys/kernel/debug/irq/irqs/ ("chip: fake"), and the nodes accumulate > across repeated runs. > > kmemleak does not report this because irq descriptors have a kobject/rcu > lifetime, but the descriptors are never returned to the irq_desc radix > tree and the debugfs entries are never removed. > > Register a cleanup callback with kunit_add_action_or_reset() immediately > after the descriptor is allocated. On test exit, including an early abort > on a failed assertion, it frees any still-registered action and then > calls irq_free_descs() to release the descriptor. The _or_reset() variant > also cleans up when registering the action itself fails. > > Fixes: 66067c3c8a1e ("genirq: Add kunit tests for depth counts") > Signed-off-by: Xiaolei Wang Thanks for the fix. Looks fine to me: Reviewed-by: Brian Norris > --- > kernel/irq/irq_test.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/kernel/irq/irq_test.c b/kernel/irq/irq_test.c > index e2d31914b3c4..283fe32bf39a 100644 > --- a/kernel/irq/irq_test.c > +++ b/kernel/irq/irq_test.c > @@ -41,14 +41,29 @@ static struct irq_chip fake_irq_chip = { > .flags = IRQCHIP_SKIP_SET_WAKE, > }; > > +static void irq_test_free_fake_irq(void *data) > +{ > + unsigned int virq = (unsigned long)data; > + struct irq_desc *desc = irq_to_desc(virq); > + > + if (desc->action) > + free_irq(virq, NULL); I wondered whether we should remove free_irq() from the tail of each test, but I suppose it's not really logically the right responsibility -- irq_test_setup_fake_irq() isn't really about assigning IRQ actions, so its cleanup here is just done for safety, not because it's really the best place to do it. Regards, Brian > + > + irq_free_descs(virq, 1); > +} > + > static int irq_test_setup_fake_irq(struct kunit *test, struct irq_affinity_desc *affd) > { > struct irq_desc *desc; > - int virq; > + int virq, ret; > > virq = irq_domain_alloc_descs(-1, 1, 0, NUMA_NO_NODE, affd); > KUNIT_ASSERT_GE(test, virq, 0); > > + ret = kunit_add_action_or_reset(test, irq_test_free_fake_irq, > + (void *)(unsigned long)virq); > + KUNIT_ASSERT_EQ(test, ret, 0); > + > irq_set_chip_and_handler(virq, &fake_irq_chip, handle_simple_irq); > > desc = irq_to_desc(virq); > -- > 2.34.1 >