mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] firewire: core: add KUnit tests for tree building
@ 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
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Takashi Sakamoto @ 2026-08-10  6:41 UTC (permalink / raw)
  To: nihaal, linux1394-devel; +Cc: linux-kernel

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


base-commit: a5367912ba81dfb3180fce89b545b009e57f17a5
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-11  8:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-10  6:41 [PATCH 0/3] firewire: core: add KUnit tests for tree building 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 ` [PATCH 0/3] firewire: core: add KUnit tests for " Takashi Sakamoto

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®