* + mm-kmemleak-use-read_once-for-accessing-jiffies_scan_wait.patch added to -mm tree
@ 2021-06-10 23:08 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2021-06-10 23:08 UTC (permalink / raw)
To: catalin.marinas, mm-commits, yanfei.xu
The patch titled
Subject: mm/kmemleak: use READ_ONCE() for accessing jiffies_scan_wait
has been added to the -mm tree. Its filename is
mm-kmemleak-use-read_once-for-accessing-jiffies_scan_wait.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/mm-kmemleak-use-read_once-for-accessing-jiffies_scan_wait.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/mm-kmemleak-use-read_once-for-accessing-jiffies_scan_wait.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Yanfei Xu <yanfei.xu@windriver.com>
Subject: mm/kmemleak: use READ_ONCE() for accessing jiffies_scan_wait
The stop_scan_thread() and start_scan_thread() cannot really solve the
problem of concurrent accessing the global jiffies_scan_wait.
kmemleak_write kmemleak_scan_thread
while (!kthread_should_stop())
stop_scan_thread
jiffies_scan_wait = xxx timeout = jiffies_scan_wait
start_scan_thread
We could replace these with a READ_ONCE() when reading jiffies_scan_wait.
It also can prevent compiler from reordering the jiffies_scan_wait which
is in while loop.
Link: https://lkml.kernel.org/r/20210609155657.26972-1-yanfei.xu@windriver.com
Signed-off-by: Yanfei Xu <yanfei.xu@windriver.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/kmemleak.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
--- a/mm/kmemleak.c~mm-kmemleak-use-read_once-for-accessing-jiffies_scan_wait
+++ a/mm/kmemleak.c
@@ -1567,7 +1567,7 @@ static int kmemleak_scan_thread(void *ar
}
while (!kthread_should_stop()) {
- signed long timeout = jiffies_scan_wait;
+ signed long timeout = READ_ONCE(jiffies_scan_wait);
mutex_lock(&scan_mutex);
kmemleak_scan();
@@ -1812,11 +1812,8 @@ static ssize_t kmemleak_write(struct fil
ret = kstrtoul(buf + 5, 0, &secs);
if (ret < 0)
goto out;
- stop_scan_thread();
- if (secs) {
+ if (secs)
jiffies_scan_wait = msecs_to_jiffies(secs * 1000);
- start_scan_thread();
- }
} else if (strncmp(buf, "scan", 4) == 0)
kmemleak_scan();
else if (strncmp(buf, "dump=", 5) == 0)
_
Patches currently in -mm which might be from yanfei.xu@windriver.com are
mm-kmemleak-use-read_once-for-accessing-jiffies_scan_wait.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-10 23:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 23:08 + mm-kmemleak-use-read_once-for-accessing-jiffies_scan_wait.patch added to -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.