From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a6-smtp.messagingengine.com (fout-a6-smtp.messagingengine.com [103.168.172.149]) (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 5A17240097E for ; Tue, 11 Aug 2026 08:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.149 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786436042; cv=none; b=SJ4cfGvAcVNajWBSQEgEcj7G3VdnIa4irIEmCjneul92Dx82Q65ZQ6g8Q7pX/XeDH+ekbPjMk5MJURSvgSUd1ovgTKe6R3MzAg4KGeVU4jlyA8NGH/10KeER3iPH+psyE5zdaQua6YS29noLPMRU232Elu4Gx2PTg6YN8glNNQ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786436042; c=relaxed/simple; bh=y8//R/Z/kFqVGyG1U88P4pBbGM6aRsvkbtfrXU9xgYA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PksQ1iXeQCyxL33k+o6gImgrxv/p51utZ3TqXcFIiuSAFzcJpOLTitUuMzCGlReTiIq15ahPt/D8N5vs0W/MECaVQwWFrR2gNYl8Y1zBg4S1cF5W5oZ67l0rQWV/0aiY58tim0MWBDkpSfxJZchP4Aa3Fs3aSUoKyUixfO8/EkM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=iAKF0vzn; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=juyNrIPc; arc=none smtp.client-ip=103.168.172.149 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="iAKF0vzn"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="juyNrIPc" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 64083EC0193; Tue, 11 Aug 2026 04:13:59 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Tue, 11 Aug 2026 04:13:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1786436039; x= 1786522439; bh=0ajr+2X82y097keSGPBQy9gP1XxGBowm825FRmWtCq0=; b=i AKF0vznh63W+KD5qLfYRiL9O2NX3S65SheodA+ANO0ZTkqounjUq9mb8sdqw8AoZ zu72CnSX3ZyXo8lRPV3zgELj3yy+r6lxLlL72ocNWE94KAQFbOqz5cOm2mFt9515 zzrsulIiw98GaV1Fprt1ljfFXkAv4ISQhe31SyhIJG70n63AqU7rbcJLCmuHumct d33PDrFewJoCtj0flsGZCfOpRtNbiFs49b11gaumBCPs80ETCOPLHYQLpF5E16Nl Ot49RcIZelHf+likgEhRRxgJQVK+XpN7TSIITfakypiND4i2r5DnxaVU9zRAnsz+ PT+bFgkvFM5vdwhGP7pkw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1786436039; x=1786522439; bh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OK8vlx7TpitZth4NCpQQc9TTbEPiYtqBL4O6XsEag X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 11 Aug 2026 04:13:57 -0400 (EDT) Date: Tue, 11 Aug 2026 17:13:55 +0900 From: Takashi Sakamoto To: nihaal@cse.iitm.ac.in, linux1394-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/3] firewire: core: add KUnit tests for tree building Message-ID: <20260811081355.GA512665@sakamocchi.jp> Mail-Followup-To: nihaal@cse.iitm.ac.in, linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20260810064119.410324-1-o-takashi@sakamocchi.jp> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260810064119.410324-1-o-takashi@sakamocchi.jp> On Mon, Aug 10, 2026 at 03:41:16PM +0900, Takashi Sakamoto wrote: > Hi, > > The core function builds internal node tree by parsing self ID sequence > at bus reset. Abdun Nihaal points to a memory leak in this process at > encountering a failure in the middle of self ID sequence enumeration[1]. > This issue is not yet solved, and some unit tests make it easier to work > for it, mainly to avoid some regressions when refactoring codes. > > This patchset adds some KUnit tests for the purpose. Especially, the > tests added at the last patch includes actual cases to hit the memory > leak. > > In my development environment (Ubuntu 26.04, amd64), I can see the > memory leak by enabling and redirecting some tracepoints events to kmsg > on the qemu process for KUnit tests execution: > > ``` > $ python3 tools/testing/kunit/kunit.py run \ > --arch=x86_64 \ > --cross_compile=x86_64-linux-gnu- \ > --kunitconfig=drivers/firewire/ \ > --kconfig_add=CONFIG_FTRACE=y \ > --kernel_args=tp_printk=1 \ > --kernel_args=trace_event=kmem:kmalloc,kmem:kfree \ > --kernel_args=hash_pointers=never \ > --raw_output=all > ``` > > In the KUnit tests for successful cases, the allocated memory objects > are released successfully in the test side, like: > > ``` > kmalloc: call_site=build_tree+0x203/0x5d0 ptr=ffff8e10413f0b80 bytes_req=48 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO node=-1 accounted=false > kmalloc: call_site=build_tree+0x203/0x5d0 ptr=ffff8e10413f0b40 bytes_req=64 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO node=-1 accounted=false > kfree: call_site=for_each_fw_node+0x17c/0x230 ptr=ffff8e10413f0b40 > kfree: call_site=for_each_fw_node+0x17c/0x230 ptr=ffff8e10413f0b80 > ``` > > For the issued cases, we can see no kfree events corresponding to the > allocated memory objects, like: > > ``` > kmalloc: call_site=build_tree+0x203/0x5d0 ptr=ffff8e10413f0940 bytes_req=64 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO node=-1 accounted=false > kmalloc: call_site=build_tree+0x203/0x5d0 ptr=ffff8e10413f0900 bytes_req=48 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO node=-1 accounted=false > kmalloc: call_site=build_tree+0x203/0x5d0 ptr=ffff8e10413f08c0 bytes_req=64 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO node=-1 accounted=false > kmalloc: call_site=build_tree+0x203/0x5d0 ptr=ffff8e10413f0880 bytes_req=64 bytes_alloc=64 gfp_flags=GFP_ATOMIC|__GFP_ZERO node=-1 accounted=false > firewire_core node_tree_test_invalid_parent_port_count.dummy-device: parent port inconsistency for node 3: parent_count=2 > ... > ``` > > The memory objects remain in the build_tree() function and should be > released internally. This is the addressing issue. > > [1] https://lore.kernel.org/lkml/20260801110915.82561-1-nihaal@cse.iitm.ac.in/ > > > Takashi Sakamoto (3): > firewire: core: add KUnit test skeleton for node tree > firewire: core: add KUnit tests for successful tree building > firewire: core: add KUnit tests for failure of tree building > > drivers/firewire/.kunitconfig | 1 + > drivers/firewire/Kconfig | 15 + > drivers/firewire/core-topology.c | 4 + > drivers/firewire/node-tree-test.c | 611 ++++++++++++++++++++++++++++++ > 4 files changed, 631 insertions(+) > create mode 100644 drivers/firewire/node-tree-test.c Applied to for-next branch. Regards Takashi Sakamoto