diff --git a/0001-libnuma-make-numa_police_memory-free-of-race.patch b/0001-libnuma-make-numa_police_memory-free-of-race.patch new file mode 100644 index 0000000..f724cda --- /dev/null +++ b/0001-libnuma-make-numa_police_memory-free-of-race.patch @@ -0,0 +1,35 @@ +From 93867c59b0bb29470873a427dc7f06ebaf305221 Mon Sep 17 00:00:00 2001 +From: Pingfan Liu +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 +--- + 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 + diff --git a/numactl.spec b/numactl.spec index 55078ae..2affde2 100644 --- a/numactl.spec +++ b/numactl.spec @@ -13,6 +13,33 @@ BuildRequires: libtool automake autoconf 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 Simple NUMA policy support. It consists of a numactl program to run other programs with a specific NUMA policy. @@ -37,6 +64,9 @@ Provides development headers for numa library calls %prep %autosetup +#patch +#%patch601 -p1 + %build %configure --prefix=/usr --libdir=%{_libdir} # Using recipe to fix rpaths, from here: