libnuma: make numa_police_memory() free of race
Resolves: bz1949860 Signed-off-by: Pingfan Liu <piliu@redhat.com>
This commit is contained in:
parent
f2a7b63e4e
commit
63aaaa73ed
35
0001-libnuma-make-numa_police_memory-free-of-race.patch
Normal file
35
0001-libnuma-make-numa_police_memory-free-of-race.patch
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
From 93867c59b0bb29470873a427dc7f06ebaf305221 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pingfan Liu <piliu@redhat.com>
|
||||||
|
Date: Mon, 29 Mar 2021 17:33:06 +0800
|
||||||
|
Subject: [PATCH] libnuma: make numa_police_memory() free of race
|
||||||
|
|
||||||
|
When numa_police_memory() read-write to memory, it can risk the race of
|
||||||
|
another thread write to the same area.
|
||||||
|
|
||||||
|
Using atomic function to protect the read-write operation
|
||||||
|
|
||||||
|
Signed-off-by: Pingfan Liu <piliu@redhat.com>
|
||||||
|
---
|
||||||
|
libnuma.c | 6 ++++--
|
||||||
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libnuma.c b/libnuma.c
|
||||||
|
index f073c50..7b8290c 100644
|
||||||
|
--- a/libnuma.c
|
||||||
|
+++ b/libnuma.c
|
||||||
|
@@ -864,8 +864,10 @@ void numa_police_memory(void *mem, size_t size)
|
||||||
|
{
|
||||||
|
int pagesize = numa_pagesize_int();
|
||||||
|
unsigned long i;
|
||||||
|
- for (i = 0; i < size; i += pagesize)
|
||||||
|
- ((volatile char*)mem)[i] = ((volatile char*)mem)[i];
|
||||||
|
+ char *p = mem;
|
||||||
|
+ for (i = 0; i < size; i += pagesize, p += pagesize)
|
||||||
|
+ __atomic_and_fetch(p, 0xff, __ATOMIC_RELAXED);
|
||||||
|
+
|
||||||
|
}
|
||||||
|
|
||||||
|
make_internal_alias(numa_police_memory);
|
||||||
|
--
|
||||||
|
2.29.2
|
||||||
|
|
30
numactl.spec
30
numactl.spec
@ -13,6 +13,33 @@ BuildRequires: libtool automake autoconf
|
|||||||
|
|
||||||
ExcludeArch: s390 %{arm}
|
ExcludeArch: s390 %{arm}
|
||||||
|
|
||||||
|
#START INSERT
|
||||||
|
#
|
||||||
|
# Patches 0 through 100 are meant for x86
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Patches 101 through 200 are meant for x86_64
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Patches 301 through 400 are meant for ppc64le
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Patches 401 through 500 are meant for s390x
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Patches 501 through 600 are meant for aarch64
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Patches 601 onward are generic patches
|
||||||
|
#
|
||||||
|
Patch601: 0001-libnuma-make-numa_police_memory-free-of-race.patch
|
||||||
|
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Simple NUMA policy support. It consists of a numactl program to run
|
Simple NUMA policy support. It consists of a numactl program to run
|
||||||
other programs with a specific NUMA policy.
|
other programs with a specific NUMA policy.
|
||||||
@ -37,6 +64,9 @@ Provides development headers for numa library calls
|
|||||||
%prep
|
%prep
|
||||||
%autosetup
|
%autosetup
|
||||||
|
|
||||||
|
#patch
|
||||||
|
#%patch601 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%configure --prefix=/usr --libdir=%{_libdir}
|
%configure --prefix=/usr --libdir=%{_libdir}
|
||||||
# Using recipe to fix rpaths, from here:
|
# Using recipe to fix rpaths, from here:
|
||||||
|
Loading…
Reference in New Issue
Block a user