Blame SOURCES/0001-libnuma-make-numa_police_memory-free-of-race.patch
|
|
8f4a09 |
From 93867c59b0bb29470873a427dc7f06ebaf305221 Mon Sep 17 00:00:00 2001
|
|
|
8f4a09 |
From: Pingfan Liu <piliu@redhat.com>
|
|
|
8f4a09 |
Date: Mon, 29 Mar 2021 17:33:06 +0800
|
|
|
8f4a09 |
Subject: [PATCH] libnuma: make numa_police_memory() free of race
|
|
|
8f4a09 |
|
|
|
8f4a09 |
When numa_police_memory() read-write to memory, it can risk the race of
|
|
|
8f4a09 |
another thread write to the same area.
|
|
|
8f4a09 |
|
|
|
8f4a09 |
Using atomic function to protect the read-write operation
|
|
|
8f4a09 |
|
|
|
8f4a09 |
Signed-off-by: Pingfan Liu <piliu@redhat.com>
|
|
|
8f4a09 |
---
|
|
|
8f4a09 |
libnuma.c | 6 ++++--
|
|
|
8f4a09 |
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
8f4a09 |
|
|
|
8f4a09 |
diff --git a/libnuma.c b/libnuma.c
|
|
|
8f4a09 |
index f073c50..7b8290c 100644
|
|
|
8f4a09 |
--- a/libnuma.c
|
|
|
8f4a09 |
+++ b/libnuma.c
|
|
|
8f4a09 |
@@ -864,8 +864,10 @@ void numa_police_memory(void *mem, size_t size)
|
|
|
8f4a09 |
{
|
|
|
8f4a09 |
int pagesize = numa_pagesize_int();
|
|
|
8f4a09 |
unsigned long i;
|
|
|
8f4a09 |
- for (i = 0; i < size; i += pagesize)
|
|
|
8f4a09 |
- ((volatile char*)mem)[i] = ((volatile char*)mem)[i];
|
|
|
8f4a09 |
+ char *p = mem;
|
|
|
8f4a09 |
+ for (i = 0; i < size; i += pagesize, p += pagesize)
|
|
|
8f4a09 |
+ __atomic_and_fetch(p, 0xff, __ATOMIC_RELAXED);
|
|
|
8f4a09 |
+
|
|
|
8f4a09 |
}
|
|
|
8f4a09 |
|
|
|
8f4a09 |
make_internal_alias(numa_police_memory);
|
|
|
8f4a09 |
--
|
|
|
8f4a09 |
2.29.2
|
|
|
8f4a09 |
|