From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=203.29.242.92 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796130294; b=ekEWV+/u6W9MY1zQzs86nnofJAEQutDg0Su35Pt9X4Krc3vRPMNYez06IV9mVjSe+LF+ qcVF1AfdLI5IJ3zWvSXKEeSTF55IpOHBx//yJdPK/TC2VKYWaLU8txSLRH+YLoyu4jSnY C2WYA7w5x3naCHAIoIG6h7nxqZ8o1W8FvzMRPYPd5hquiG5s99l3MIE8A4OQnv9obOwq6 PcZARVScq0HVClJ6mz0mR3pHbj2ZJh+WVXASmHt0sQ/PjHcGgPsrDbJhkWaU2QR02VaQr C3LA6sz59AcjujN0wRF60qAmnVqCvJr4QKysbGQsQXDdxRRrH238YyOL0q5Q8ZD/9lw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796130294; h=DMARC-Filter:DKIM-Signature:Received:X-Spam-Checker-Version: X-Spam-Level:X-Spam-Status:DKIM-Signature:Received:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language: From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=9dVc57O9hmhf4iudk5XJ+7pKsaKQKCAQOFNHcNuOoh8=; b=YEHTnHAzoDZ6U3W0s5oM69o5sTzY8XESE0zgiu7NG/Wygf4AqsRykLftmy8k0RXibAtw +Lqs96+rPhWEA2Bht/xPEi6kj5bmvqOO6PWfY6GY40XfZQpSXmaJhcA6WafjSMUiyUX9E uezGWefCbD0dakXfzOlr5Lv9LQSfzmB6bkvDidLCInN8SS+xwefq5ZrOt2rpTijWzvnRD qG/I0ny9ZN7XQlhjskub48db0ucmsKtJnReJ31LJ3VY2sx6U4j8SOB90xmX+T9+mv3aAX 19J/rTePcHgE0PeW3mt3jJf4hbPOzjtTpMiyBS0pbEAOdRNoaoeaE2ed99yspEwQZmQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=davidgow.net; spf=pass smtp.mailfrom=davidgow.net; dkim=pass header.d=davidgow.net header.i=@davidgow.net header.a=rsa-sha256 header.s=201606 header.b=NW562I+3; dkim=pass header.d=davidgow.net header.i=@davidgow.net header.a=rsa-sha256 header.s=201606 header.b=AqMSJz5a; arc=none smtp.remote-ip=203.29.242.92 Received: from sphereful.davidgow.net (sphereful.davidgow.net [203.29.242.92]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C794606A31A for ; Tue, 1 Dec 2026 13:04:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4C794606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=davidgow.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=davidgow.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key, unprotected) header.d=davidgow.net header.i=@davidgow.net header.a=rsa-sha256 header.s=201606 header.b=NW562I+3; dkim=pass (4096-bit key) header.d=davidgow.net header.i=@davidgow.net header.a=rsa-sha256 header.s=201606 header.b=AqMSJz5a DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=davidgow.net; s=201606; t=1796130284; bh=9P+w2ZHjMx/Cmo2vVMigROoIh2K7u5TforzNEX9GzVM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NW562I+3KZjUCWevkQ9gsWjmriaqlGVb1g5CLw/HJgEku4OlljgHN/ICcha/MASGT mp7AYEUPPS6Mo6pDZrqtyPimQDj2AnwQvRyfek87/eooj1IM8XG8DihMDmcyLK4kgU 2pcIo3fzSnaU4zhBuxNrUYxG0T4GucfS4908zKolQc+NO1ZTB+mQyJZp24WrfI49Fw JIaB/Myxp2rPdxqC4meJ9XLPThacH8fpSx9/1Afir2oB0ucNG7ZfVtFvBKDM/pFyye PkiiNLJRmzhZ9aBXbHLEYV9TvlTgy0ZDmD5T71l63XAFkbfdQ1/NxwQzxXT7zPHnaS WcNlxfB6XvYH7kIjA5eSnTK1cNYmCgXpr8RA0Dtepf1Vh3eLhzUAQeeWwAc/vdCR0H 6VI5B1r2pz0MTggY5mB0HXh8pkhNkHClsh1Oawwu2OO/seZ+Itwe/KgidXDEnng1tR 08RMQiU9BbeNt4nNtbDl8lwSDBWOmXQzKSwdu97Gs05P8MXEIqxL64p3KtTmXewRwh 8EWnDj5Sf74IybTM1sNuqQ92jhjMBcknXWFc3TyPFjVhsBTgP75uMDUfdpX4ph3YxL ycSDy1aseS0AhQm5erafff7j1JDnStNY1BaeaBpqD6XTPSWct4eNpIKSdvFg/oD8qy d3OtrY7YWuXDTW5JDhVXLs/A= Received: by sphereful.davidgow.net (Postfix, from userid 119) id B888A200D79; Tue, 1 Dec 2026 21:04:44 +0800 (AWST) X-Spam-Level: DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=davidgow.net; s=201606; t=1796130282; bh=9P+w2ZHjMx/Cmo2vVMigROoIh2K7u5TforzNEX9GzVM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=AqMSJz5acBz1YQ+jM5roxM46+CvSpIgfTWZwyIlKsUJ0qjJq6TaM593roWCbVGlDZ PMNsWVFRAin8vsYljiGBRYkMeuo20VpLVbHCw6ZqeLfIUHaqYW1uwXgu+M0H1ZKjff PN2UnM9Dn9Z6WkvZ4tvgcdDCF+mrkjg46hWQ6oPFqkIBPLJr/I7Fv1cuCPy2vzy3m6 GjUu9koteiBNX88AYsKycqCy9i3T+qMNnjHKJoNeQC+7lU0tAtCHWGe0tzUCAGCzTp 1YBAn9t6oSwLoyR7H042NqDAUdEdsZvd45GQ2Oltc2HzakLwR32dC2tx+uoRN/zBHn 4R7ZZtGn5JUr4R2981sH7SAOaK59yDOAv83xkdg+d86oy4Q+YCZQZiLe8ckNWhc+sS Z3Y/7lUnaFgHBP94qecOQpdr42x+YiiIdN7m/c+DuINYCG8RmGLySE4rrSL8LciAuQ s/HJVdsD6Kf3m1JI+18P3sfLOSq6Y9dt3JfRogNgwb757nizB4Vq5m5FSM2zo1pqFD PFFj/Df/3XsFbrQhk/KjsU3yn4fXYH1ymZeEAJjYbZLnrLgzWOGmncN6IGPWHLgOF/ Wk2v3avehdHtTCAcZFPn7EK3vt9PJlE8w3dkcV2mz2WmFQpXsAcNw03DAvGzrmRjBE ohXWgKz+rs8sDtYrcHzyHvfk= Received: from [IPV6:2001:8003:8802:7000::41b] (unknown [IPv6:2001:8003:8802:7000::41b]) by sphereful.davidgow.net (Postfix) with ESMTPSA id A7C12200D72; Tue, 1 Dec 2026 21:04:42 +0800 (AWST) Message-ID: Date: Tue, 1 Dec 2026 21:04:40 +0800 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] genirq/test: Release fake irq descriptors after KUnit tests To: Xiaolei Wang , tglx@kernel.org, radu@rendec.net, briannorris@chromium.org, linux@roeck-us.net, davidgow@google.com Cc: linux-kernel@vger.kernel.org, geert@linux-m68k.org, kunit-dev@googlegroups.com References: <20261130104426.1384855-1-wangxiaolei01@kaihong.com> Content-Language: en-US From: David Gow In-Reply-To: <20261130104426.1384855-1-wangxiaolei01@kaihong.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 30/11/2026 à 18:44, Xiaolei Wang a écrit : > 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 > --- Tested-by: David Gow Cheers, -- David > 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); > + > + 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);