linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tests bp_account: Fix leaked file descriptor
@ 2025-07-11 11:10 Leo Yan
  2025-07-11 15:46 ` Ian Rogers
  2025-07-14  5:15 ` Namhyung Kim
  0 siblings, 2 replies; 3+ messages in thread
From: Leo Yan @ 2025-07-11 11:10 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers
  Cc: linux-perf-users, linux-kernel, Aishwarya TCV, Leo Yan

Since the commit e9846f5ead26 ("perf test: In forked mode add check that
fds aren't leaked"), the test "Breakpoint accounting" reports the error:

  # perf test -vvv "Breakpoint accounting"
  20: Breakpoint accounting:
  --- start ---
  test child forked, pid 373
  failed opening event 0
  failed opening event 0
  watchpoints count 4, breakpoints count 6, has_ioctl 1, share 0
  wp 0 created
  wp 1 created
  wp 2 created
  wp 3 created
  wp 0 modified to bp
  wp max created
  ---- end(0) ----
  Leak of file descriptor 7 that opened: 'anon_inode:[perf_event]'

A watchpoint's file descriptor was not properly released. This patch
fixes the leak.

Fixes: 032db28e5fa3 ("perf tests: Add breakpoint accounting/modify test")
Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/tests/bp_account.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c
index 4cb7d486b5c178c622be4fc7e9c8c5a924df9d9b..047433c977bc9de4f8984268a2a9826d6bfa6f17 100644
--- a/tools/perf/tests/bp_account.c
+++ b/tools/perf/tests/bp_account.c
@@ -104,6 +104,7 @@ static int bp_accounting(int wp_cnt, int share)
 		fd_wp = wp_event((void *)&the_var, &attr_new);
 		TEST_ASSERT_VAL("failed to create max wp\n", fd_wp != -1);
 		pr_debug("wp max created\n");
+		close(fd_wp);
 	}
 
 	for (i = 0; i < wp_cnt; i++)

---
base-commit: a62b7a37e6fcf4a675b1548e7c168b96ec836442
change-id: 20250711-perf_fix_breakpoint_accounting-ea3e8b2e8f51

Best regards,
-- 
Leo Yan <leo.yan@arm.com>


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

* Re: [PATCH] perf tests bp_account: Fix leaked file descriptor
  2025-07-11 11:10 [PATCH] perf tests bp_account: Fix leaked file descriptor Leo Yan
@ 2025-07-11 15:46 ` Ian Rogers
  2025-07-14  5:15 ` Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2025-07-11 15:46 UTC (permalink / raw)
  To: Leo Yan
  Cc: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa,
	linux-perf-users, linux-kernel, Aishwarya TCV

On Fri, Jul 11, 2025 at 4:10 AM Leo Yan <leo.yan@arm.com> wrote:
>
> Since the commit e9846f5ead26 ("perf test: In forked mode add check that
> fds aren't leaked"), the test "Breakpoint accounting" reports the error:
>
>   # perf test -vvv "Breakpoint accounting"
>   20: Breakpoint accounting:
>   --- start ---
>   test child forked, pid 373
>   failed opening event 0
>   failed opening event 0
>   watchpoints count 4, breakpoints count 6, has_ioctl 1, share 0
>   wp 0 created
>   wp 1 created
>   wp 2 created
>   wp 3 created
>   wp 0 modified to bp
>   wp max created
>   ---- end(0) ----
>   Leak of file descriptor 7 that opened: 'anon_inode:[perf_event]'
>
> A watchpoint's file descriptor was not properly released. This patch
> fixes the leak.
>
> Fixes: 032db28e5fa3 ("perf tests: Add breakpoint accounting/modify test")
> Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
> Signed-off-by: Leo Yan <leo.yan@arm.com>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/tests/bp_account.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c
> index 4cb7d486b5c178c622be4fc7e9c8c5a924df9d9b..047433c977bc9de4f8984268a2a9826d6bfa6f17 100644
> --- a/tools/perf/tests/bp_account.c
> +++ b/tools/perf/tests/bp_account.c
> @@ -104,6 +104,7 @@ static int bp_accounting(int wp_cnt, int share)
>                 fd_wp = wp_event((void *)&the_var, &attr_new);
>                 TEST_ASSERT_VAL("failed to create max wp\n", fd_wp != -1);
>                 pr_debug("wp max created\n");
> +               close(fd_wp);
>         }
>
>         for (i = 0; i < wp_cnt; i++)
>
> ---
> base-commit: a62b7a37e6fcf4a675b1548e7c168b96ec836442
> change-id: 20250711-perf_fix_breakpoint_accounting-ea3e8b2e8f51
>
> Best regards,
> --
> Leo Yan <leo.yan@arm.com>
>

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

* Re: [PATCH] perf tests bp_account: Fix leaked file descriptor
  2025-07-11 11:10 [PATCH] perf tests bp_account: Fix leaked file descriptor Leo Yan
  2025-07-11 15:46 ` Ian Rogers
@ 2025-07-14  5:15 ` Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2025-07-14  5:15 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Jiri Olsa, Ian Rogers, Leo Yan
  Cc: linux-perf-users, linux-kernel, Aishwarya TCV

On Fri, 11 Jul 2025 12:10:15 +0100, Leo Yan wrote:
> Since the commit e9846f5ead26 ("perf test: In forked mode add check that
> fds aren't leaked"), the test "Breakpoint accounting" reports the error:
> 
>   # perf test -vvv "Breakpoint accounting"
>   20: Breakpoint accounting:
>   --- start ---
>   test child forked, pid 373
>   failed opening event 0
>   failed opening event 0
>   watchpoints count 4, breakpoints count 6, has_ioctl 1, share 0
>   wp 0 created
>   wp 1 created
>   wp 2 created
>   wp 3 created
>   wp 0 modified to bp
>   wp max created
>   ---- end(0) ----
>   Leak of file descriptor 7 that opened: 'anon_inode:[perf_event]'
> 
> [...]
Applied to perf-tools-next, thanks!

Best regards,
Namhyung



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

end of thread, other threads:[~2025-07-14  5:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-11 11:10 [PATCH] perf tests bp_account: Fix leaked file descriptor Leo Yan
2025-07-11 15:46 ` Ian Rogers
2025-07-14  5:15 ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).