mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
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
Date: Tue, 11 Aug 2026 17:13:55 +0900	[thread overview]
Message-ID: <20260811081355.GA512665@sakamocchi.jp> (raw)
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

      parent reply	other threads:[~2026-08-11  8:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10  6:41 Takashi Sakamoto
2026-08-10  6:41 ` [PATCH 1/3] firewire: core: add KUnit test skeleton for node tree Takashi Sakamoto
2026-08-10  6:41 ` [PATCH 2/3] firewire: core: add KUnit tests for successful tree building Takashi Sakamoto
2026-08-10  6:41 ` [PATCH 3/3] firewire: core: add KUnit tests for failure of " Takashi Sakamoto
2026-08-11  8:13 ` Takashi Sakamoto [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260811081355.GA512665@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=nihaal@cse.iitm.ac.in \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®