* [PATCH] common/rc: cleanup old .kmemleak files
@ 2023-07-12 14:51 Luís Henriques
2023-07-12 16:32 ` Darrick J. Wong
2023-07-12 16:35 ` [PATCH v2] " Luís Henriques
0 siblings, 2 replies; 6+ messages in thread
From: Luís Henriques @ 2023-07-12 14:51 UTC (permalink / raw)
To: fstests; +Cc: Luís Henriques
I've spent a non-negligible amount of time looking into a kmemleak that
didn't exist in the code I was testing because there was an old .kmemleak
file in the results directory. I don't think this is an intended behaviour,
so I'm proposing to remove these files everytime we capture the result of a
new scan.
Signed-off-by: Luís Henriques <lhenriques@suse.de>
---
common/rc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/common/rc b/common/rc
index 741579af82d2..6aa6be704e51 100644
--- a/common/rc
+++ b/common/rc
@@ -4433,6 +4433,8 @@ _capture_kmemleak()
local kern_knob="$DEBUGFS_MNT/kmemleak"
local leak_file="$1"
+ rm -f "$leak_file"
+
# Tell the kernel to scan for memory leaks. Apparently the write
# returns before the scan is complete, so do it twice in the hopes
# that twice is enough to capture all the leaks.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] common/rc: cleanup old .kmemleak files
2023-07-12 14:51 [PATCH] common/rc: cleanup old .kmemleak files Luís Henriques
@ 2023-07-12 16:32 ` Darrick J. Wong
2023-07-12 16:35 ` [PATCH v2] " Luís Henriques
1 sibling, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2023-07-12 16:32 UTC (permalink / raw)
To: Luís Henriques; +Cc: fstests
On Wed, Jul 12, 2023 at 03:51:01PM +0100, Luís Henriques wrote:
> I've spent a non-negligible amount of time looking into a kmemleak that
> didn't exist in the code I was testing because there was an old .kmemleak
> file in the results directory. I don't think this is an intended behaviour,
> so I'm proposing to remove these files everytime we capture the result of a
> new scan.
>
> Signed-off-by: Luís Henriques <lhenriques@suse.de>
> ---
> common/rc | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/common/rc b/common/rc
> index 741579af82d2..6aa6be704e51 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4433,6 +4433,8 @@ _capture_kmemleak()
> local kern_knob="$DEBUGFS_MNT/kmemleak"
> local leak_file="$1"
>
> + rm -f "$leak_file"
Some callers of this helper specify a device file when all they want to
do is clear the old kmemleak report data:
$ git grep -w _capture_kmemleak
common/rc:4490:_capture_kmemleak()
common/rc:4535: _capture_kmemleak /dev/null
common/rc:4555: _capture_kmemleak /dev/null
common/rc:4560: _capture_kmemleak "$leak_file"
The simplest fix here I think would be:
# Some callers pass in /dev/null when they want to clear the
# kernel's leak report file and do not care what was in that.
test -f "$leak_file" && rm -f "$leak_file"
--D
> +
> # Tell the kernel to scan for memory leaks. Apparently the write
> # returns before the scan is complete, so do it twice in the hopes
> # that twice is enough to capture all the leaks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] common/rc: cleanup old .kmemleak files
2023-07-12 14:51 [PATCH] common/rc: cleanup old .kmemleak files Luís Henriques
2023-07-12 16:32 ` Darrick J. Wong
@ 2023-07-12 16:35 ` Luís Henriques
2023-07-12 22:06 ` Darrick J. Wong
1 sibling, 1 reply; 6+ messages in thread
From: Luís Henriques @ 2023-07-12 16:35 UTC (permalink / raw)
To: fstests; +Cc: Luís Henriques
I've spent a non-negligible amount of time looking into a kmemleak that
didn't exist in the code I was testing because there was an old .kmemleak
file in the results directory. I don't think this is an intended behaviour,
so I'm proposing to remove these files everytime we capture the result of a
new scan.
Signed-off-by: Luís Henriques <lhenriques@suse.de>
---
common/rc | 2 ++
1 file changed, 2 insertions(+)
Changes since v1:
I realised that _capture_kmemleak() is called with /dev/null as argument, so
this version is probably better.
diff --git a/common/rc b/common/rc
index 741579af82d2..6850889e815e 100644
--- a/common/rc
+++ b/common/rc
@@ -4433,6 +4433,8 @@ _capture_kmemleak()
local kern_knob="$DEBUGFS_MNT/kmemleak"
local leak_file="$1"
+ [ -f "$leak_file" ] && rm -f "$leak_file"
+
# Tell the kernel to scan for memory leaks. Apparently the write
# returns before the scan is complete, so do it twice in the hopes
# that twice is enough to capture all the leaks.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] common/rc: cleanup old .kmemleak files
2023-07-12 16:35 ` [PATCH v2] " Luís Henriques
@ 2023-07-12 22:06 ` Darrick J. Wong
2023-07-13 8:23 ` Luís Henriques
0 siblings, 1 reply; 6+ messages in thread
From: Darrick J. Wong @ 2023-07-12 22:06 UTC (permalink / raw)
To: Luís Henriques; +Cc: fstests
On Wed, Jul 12, 2023 at 05:35:00PM +0100, Luís Henriques wrote:
> I've spent a non-negligible amount of time looking into a kmemleak that
> didn't exist in the code I was testing because there was an old .kmemleak
> file in the results directory. I don't think this is an intended behaviour,
> so I'm proposing to remove these files everytime we capture the result of a
> new scan.
>
> Signed-off-by: Luís Henriques <lhenriques@suse.de>
> ---
> common/rc | 2 ++
> 1 file changed, 2 insertions(+)
>
> Changes since v1:
> I realised that _capture_kmemleak() is called with /dev/null as argument, so
> this version is probably better.
>
> diff --git a/common/rc b/common/rc
> index 741579af82d2..6850889e815e 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -4433,6 +4433,8 @@ _capture_kmemleak()
> local kern_knob="$DEBUGFS_MNT/kmemleak"
> local leak_file="$1"
>
> + [ -f "$leak_file" ] && rm -f "$leak_file"
I was hoping you'd incorporate the comment explaining why the test uses
-f and not -e.
--D
> +
> # Tell the kernel to scan for memory leaks. Apparently the write
> # returns before the scan is complete, so do it twice in the hopes
> # that twice is enough to capture all the leaks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] common/rc: cleanup old .kmemleak files
2023-07-12 22:06 ` Darrick J. Wong
@ 2023-07-13 8:23 ` Luís Henriques
2023-07-13 14:04 ` Darrick J. Wong
0 siblings, 1 reply; 6+ messages in thread
From: Luís Henriques @ 2023-07-13 8:23 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: fstests
"Darrick J. Wong" <djwong@kernel.org> writes:
> On Wed, Jul 12, 2023 at 05:35:00PM +0100, Luís Henriques wrote:
>> I've spent a non-negligible amount of time looking into a kmemleak that
>> didn't exist in the code I was testing because there was an old .kmemleak
>> file in the results directory. I don't think this is an intended behaviour,
>> so I'm proposing to remove these files everytime we capture the result of a
>> new scan.
>>
>> Signed-off-by: Luís Henriques <lhenriques@suse.de>
>> ---
>> common/rc | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> Changes since v1:
>> I realised that _capture_kmemleak() is called with /dev/null as argument, so
>> this version is probably better.
>>
>> diff --git a/common/rc b/common/rc
>> index 741579af82d2..6850889e815e 100644
>> --- a/common/rc
>> +++ b/common/rc
>> @@ -4433,6 +4433,8 @@ _capture_kmemleak()
>> local kern_knob="$DEBUGFS_MNT/kmemleak"
>> local leak_file="$1"
>>
>> + [ -f "$leak_file" ] && rm -f "$leak_file"
>
> I was hoping you'd incorporate the comment explaining why the test uses
> -f and not -e.
You're right. The reason I didn't was because I sent out v2 before seeing
your email. Anyway, I'll send out v3 in a second. And thanks for the
review, by the way!
Cheers,
--
Luís
>
> --D
>
>> +
>> # Tell the kernel to scan for memory leaks. Apparently the write
>> # returns before the scan is complete, so do it twice in the hopes
>> # that twice is enough to capture all the leaks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] common/rc: cleanup old .kmemleak files
2023-07-13 8:23 ` Luís Henriques
@ 2023-07-13 14:04 ` Darrick J. Wong
0 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2023-07-13 14:04 UTC (permalink / raw)
To: Luís Henriques; +Cc: fstests
On Thu, Jul 13, 2023 at 09:23:32AM +0100, Luís Henriques wrote:
> "Darrick J. Wong" <djwong@kernel.org> writes:
>
> > On Wed, Jul 12, 2023 at 05:35:00PM +0100, Luís Henriques wrote:
> >> I've spent a non-negligible amount of time looking into a kmemleak that
> >> didn't exist in the code I was testing because there was an old .kmemleak
> >> file in the results directory. I don't think this is an intended behaviour,
> >> so I'm proposing to remove these files everytime we capture the result of a
> >> new scan.
> >>
> >> Signed-off-by: Luís Henriques <lhenriques@suse.de>
> >> ---
> >> common/rc | 2 ++
> >> 1 file changed, 2 insertions(+)
> >>
> >> Changes since v1:
> >> I realised that _capture_kmemleak() is called with /dev/null as argument, so
> >> this version is probably better.
> >>
> >> diff --git a/common/rc b/common/rc
> >> index 741579af82d2..6850889e815e 100644
> >> --- a/common/rc
> >> +++ b/common/rc
> >> @@ -4433,6 +4433,8 @@ _capture_kmemleak()
> >> local kern_knob="$DEBUGFS_MNT/kmemleak"
> >> local leak_file="$1"
> >>
> >> + [ -f "$leak_file" ] && rm -f "$leak_file"
> >
> > I was hoping you'd incorporate the comment explaining why the test uses
> > -f and not -e.
>
> You're right. The reason I didn't was because I sent out v2 before seeing
> your email. Anyway, I'll send out v3 in a second. And thanks for the
> review, by the way!
aha, ok.
--D
> Cheers,
> --
> Luís
>
> >
> > --D
> >
> >> +
> >> # Tell the kernel to scan for memory leaks. Apparently the write
> >> # returns before the scan is complete, so do it twice in the hopes
> >> # that twice is enough to capture all the leaks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-07-13 14:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-12 14:51 [PATCH] common/rc: cleanup old .kmemleak files Luís Henriques
2023-07-12 16:32 ` Darrick J. Wong
2023-07-12 16:35 ` [PATCH v2] " Luís Henriques
2023-07-12 22:06 ` Darrick J. Wong
2023-07-13 8:23 ` Luís Henriques
2023-07-13 14:04 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox