All of lore.kernel.org
 help / color / mirror / Atom feed
From: akpm@linux-foundation.org
To: catalin.marinas@arm.com, mm-commits@vger.kernel.org,
	yanfei.xu@windriver.com
Subject: + mm-kmemleak-use-read_once-for-accessing-jiffies_scan_wait.patch added to -mm tree
Date: Thu, 10 Jun 2021 16:08:13 -0700	[thread overview]
Message-ID: <20210610230813.V6S0m6K6c%akpm@linux-foundation.org> (raw)


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


                 reply	other threads:[~2021-06-10 23:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210610230813.V6S0m6K6c%akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=yanfei.xu@windriver.com \
    /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 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.