[to-be-updated] mm-kmemleak-use-read_once-for-accessing-jiffies_scan_wait.patch removed from -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm/kmemleak: use READ_ONCE() for accessing jiffies_scan_wait
has been removed from the -mm tree.  Its filename was
     mm-kmemleak-use-read_once-for-accessing-jiffies_scan_wait.patch

This patch was dropped because an updated version will be merged

------------------------------------------------------
From: Yanfei Xu <yanfei.xu@xxxxxxxxxxxxx>
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@xxxxxxxxxxxxx
Signed-off-by: Yanfei Xu <yanfei.xu@xxxxxxxxxxxxx>
Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 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@xxxxxxxxxxxxx are

mm-kmemleak-fix-the-possible-wrong-memory-scanning-period.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux