Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
474296843b
!74 回合上游社区补丁
From: @wilhelmleibniz 
Reviewed-by: @wangbin224 
Signed-off-by: @wangbin224
2024-12-05 06:22:30 +00:00
Andy Lau
4b271d4f91 backport patches from upstream community 2024-12-03 14:26:36 +08:00
openeuler-ci-bot
0f6b7ae901
!63 Fix the using of the uninitialized value
From: @jamesblunt 
Reviewed-by: @liqingqing_1229 
Signed-off-by: @liqingqing_1229
2024-11-05 02:39:44 +00:00
Zhang Yaqi
ea09aba17c Fix the using of the uninitialized value 2024-07-02 10:47:48 +08:00
openeuler-ci-bot
0ad8c1cd08
!58 libnuma: Fix incorrect print and exit of numa_preferred/_many APIs
From: @zhangnaichuan 
Reviewed-by: @wangbin224 
Signed-off-by: @wangbin224
2024-04-19 01:22:34 +00:00
zhangnaichuan
3ec1d618a2 libnuma: Fix incorrect print and exit of numa_preferred/_many APIs 2024-04-16 15:14:21 +08:00
openeuler-ci-bot
bdd3e299b4
!52 numactl: fix memory leaks when run with -H
From: @chenhaixaing 
Reviewed-by: @liqingqing_1229 
Signed-off-by: @liqingqing_1229
2023-12-22 01:52:23 +00:00
chenhaixiang
f7bc85f23b numactl: fix memory leaks when run with -H
signed-off-by:chenhaixiang3@huawei.com
2023-12-18 20:29:54 -05:00
openeuler-ci-bot
0c9136a214
!40 去除已不再需要的RISC-V -latomic参数
From: @laokz 
Reviewed-by: @liqingqing_1229 
Signed-off-by: @liqingqing_1229
2023-07-19 03:00:40 +00:00
laokz
728a187a22 riscv64: remove -latomic flag
OpenEuler gcc already support inline subword atomic for
RISC-V. So remove the redundant flag.
2023-07-18 19:46:01 +08:00
8 changed files with 288 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From a37ca95db184fb97c55a294449fe7622a5aecdda Mon Sep 17 00:00:00 2001
From: laokz <zhangkai@iscas.ac.cn>
Date: Tue, 18 Jul 2023 19:37:14 +0800
Subject: [PATCH] riscv64: remove flag -latomic
Because openEuler gcc already support inline subword atomic
for RISC-V, remove the redundant flag.
---
Makefile.am | 3 ---
Makefile.in | 1 -
2 files changed, 4 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index d64df5d..ba6cd48 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,9 +41,6 @@ memhog_LDADD = libnuma.la
libnuma_la_SOURCES = libnuma.c syscall.c distance.c affinity.c affinity.h sysfs.c sysfs.h rtnetlink.c rtnetlink.h versions.ldscript
libnuma_la_LDFLAGS = -version-info 1:0:0 -Wl,--version-script,$(srcdir)/versions.ldscript -Wl,-init,numa_init -Wl,-fini,numa_fini
-if RISCV64
-libnuma_la_LDFLAGS += -latomic
-endif
check_PROGRAMS = \
test/distance \
diff --git a/Makefile.in b/Makefile.in
index 8cbad1c..a196ea0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -95,7 +95,6 @@ target_triplet = @target@
bin_PROGRAMS = numactl$(EXEEXT) numastat$(EXEEXT) numademo$(EXEEXT) \
migratepages$(EXEEXT) migspeed$(EXEEXT) memhog$(EXEEXT)
@HAVE_TREE_VECTORIZE_TRUE@am__append_1 = -ftree-vectorize
-@RISCV64_TRUE@am__append_2 = -latomic
check_PROGRAMS = test/distance$(EXEEXT) test/ftok$(EXEEXT) \
test/mbind_mig_pages$(EXEEXT) test/migrate_pages$(EXEEXT) \
test/move_pages$(EXEEXT) test/mynode$(EXEEXT) \
--
2.40.1

View File

@ -0,0 +1,27 @@
From 8daaae302b214539bba6b002c7c40b700ddcdc4b Mon Sep 17 00:00:00 2001
From: will_niutao <vincenttom@users.noreply.github.com>
Date: Thu, 24 Aug 2023 11:08:23 +0800
Subject: [PATCH] fix: fix memory leaks when run with -H
Conflict: NA
Reference: https://github.com/numactl/numactl/commit/8daaae302b214539bba6b002c7c40b700ddcdc4b
---
numactl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/numactl.c b/numactl.c
index 47cbf39..562f319 100755
--- a/numactl.c
+++ b/numactl.c
@@ -242,6 +242,8 @@ static void print_node_cpus(int node)
printf(" %d", i);
}
putchar('\n');
+
+ numa_free_cpumask(cpus);
}
static void hardware(void)
--
2.39.3

View File

@ -0,0 +1,49 @@
From e763e8c86d9f10761a75c2be8510a79f25d63831 Mon Sep 17 00:00:00 2001
From: Chunsheng Luo <luochunsheng@ustc.edu>
Date: Thu, 25 Jan 2024 23:54:56 +0800
Subject: [PATCH] libnuma: Fix unexpected output
When errno is 0, numa_error(__FILE__) will print "xx: Success",
which is not as expected
Signed-off-by: Chunsheng Luo <luochunsheng@ustc.edu>
Reported-by: Ajay Panyala
Conflict: NA
Reference:https://github.com/numactl/numactl/commit/e763e8c86d9f10761a75c2be8510a79f25d63831
---
libnuma.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libnuma.c b/libnuma.c
index 8b07ab0..e898297 100644
--- a/libnuma.c
+++ b/libnuma.c
@@ -1882,8 +1882,10 @@ static struct bitmask *__numa_preferred(void)
policy != MPOL_BIND)
return bmp;
- if (numa_bitmask_weight(bmp) > 1)
+ if (numa_bitmask_weight(bmp) > 1) {
+ errno = EINVAL;
numa_error(__FILE__);
+ }
return bmp;
}
@@ -1903,8 +1905,11 @@ int numa_preferred(void)
static void __numa_set_preferred(struct bitmask *bmp)
{
int nodes = numa_bitmask_weight(bmp);
- if (nodes > 1)
+ if (nodes > 1) {
+ errno = EINVAL;
numa_error(__FILE__);
+ }
+
setpol(nodes ? MPOL_PREFERRED : MPOL_LOCAL, bmp);
}
--
2.27.0

View File

@ -0,0 +1,35 @@
From 00dd4c32240694ae8619ed5445e4ffbc463f8eb0 Mon Sep 17 00:00:00 2001
From: Chunsheng Luo <luochunsheng@ustc.edu>
Date: Fri, 26 Jan 2024 00:30:13 +0800
Subject: [PATCH] libnuma: Fix incorrect print and exit of numa_preferred/_many
APIs
Only when policy is preferred, numa_bitmask_weight will be judged,
because mbind and preferred_many support multiple nodes.
fixes: 87c6834("libnuma: Convert preferred node into a mask")
Signed-off-by: Chunsheng Luo <luochunsheng@ustc.edu>
Conflict: NA
Reference: https://github.com/numactl/numactl/commit/00dd4c32240694ae8619ed5445e4ffbc463f8eb0
---
libnuma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libnuma.c b/libnuma.c
index e898297..ef93558 100644
--- a/libnuma.c
+++ b/libnuma.c
@@ -1882,7 +1882,7 @@ static struct bitmask *__numa_preferred(void)
policy != MPOL_BIND)
return bmp;
- if (numa_bitmask_weight(bmp) > 1) {
+ if (policy == MPOL_PREFERRED && numa_bitmask_weight(bmp) > 1) {
errno = EINVAL;
numa_error(__FILE__);
}
--
2.27.0

View File

@ -0,0 +1,26 @@
From 119eb590f5f0b89611d46cdec805b22767f8a6c0 Mon Sep 17 00:00:00 2001
From: Pingfan Liu <piliu@redhat.com>
Date: Wed, 17 Apr 2024 10:36:34 +0800
Subject: [PATCH] numademo: Fix the using of the uninitialized value
Signed-off-by: Pingfan Liu <piliu@redhat.com>
---
numademo.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/numademo.c b/numademo.c
index 374afd3..8886d7f 100644
--- a/numademo.c
+++ b/numademo.c
@@ -248,6 +248,8 @@ static void memtest(char *name, unsigned char *mem)
#endif
default:
+ gettimeofday(&start,NULL);
+ gettimeofday(&end,NULL);
break;
}
--
2.27.0

View File

@ -0,0 +1,31 @@
From 0efea0eb1980964c3264c901ec4e8934c4c05541 Mon Sep 17 00:00:00 2001
From: filimonov <1549571+filimonov@users.noreply.github.com>
Date: Mon, 21 Oct 2024 18:45:02 +0200
Subject: [PATCH] Make numa_available respect EPERM
Make numa_available respect EPERM
In the Docker environment, usage of `get_mempolicy` is restricted by seccomp security profiles:
https://docs.docker.com/engine/security/seccomp/ (unless `CAP_SYS_NICE` is set).
But `numa_available` used to ignore EPERM and return 'true', i.e., available. This led to further code attempting other API calls, which resulted in "operation not permitted" errors printed to stderr.
See details in:
https://github.com/ClickHouse/ClickHouse/issues/68747#issuecomment-2426210768
---
libnuma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libnuma.c b/libnuma.c
index f10d127..0989943 100644
--- a/libnuma.c
+++ b/libnuma.c
@@ -871,7 +871,7 @@ long numa_node_size(int node, long *freep)
int numa_available(void)
{
- if (get_mempolicy(NULL, NULL, 0, 0, 0) < 0 && errno == ENOSYS)
+ if (get_mempolicy(NULL, NULL, 0, 0, 0) < 0 && (errno == ENOSYS || errno == EPERM))
return -1;
return 0;
}

View File

@ -0,0 +1,54 @@
From a7651aa406a370fdcf431a215485040ba84c2d01 Mon Sep 17 00:00:00 2001
From: q66 <q66@chimera-linux.org>
Date: Thu, 22 Aug 2024 08:51:23 +0200
Subject: [PATCH] libnuma: fix nodemask allocation size for get_mempolicy
This prevents buffer corrpution which manifests as firefox
failing to play videos with mimalloc in hardened mode (as the
get_mempolicy will corrupt the metadata).
The documentation for get_mempolicy specifies the following:
```
unsigned long nodemask[(.maxnode + ULONG_WIDTH - 1)
/ ULONG_WIDTH]
```
where maxnode is the following argument. Since we are calling
get_mempolicy with `nodemask_sz + 1`, that means the size
will be `(nodemask_sz + 1 + ULONG_WIDTH - 1) / ULONG_WIDTH)`
i.e. `(nodemask_sz + ULONG_WIDTH) / ULONG_WIDTH` or
`nodemask_sz / ULONG_WIDTH + 1`.
Since `ULONG_WIDTH` is `sizeof ulong * 8`, and the
nodemask is an array of ulong, that means the allocation
size should be:
```
sizeof ulong * (nodemask_sz / (sizeof ulong * 8) + 1)
```
which is equal to:
```
sizeof ulong + nodemask_size / 8
```
That means we need an extra ulong in the buffer.
---
libnuma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libnuma.c b/libnuma.c
index 89a17e0..5d99e81 100644
--- a/libnuma.c
+++ b/libnuma.c
@@ -427,7 +427,7 @@ set_nodemask_size(void)
nodemask_sz = 16;
do {
nodemask_sz <<= 1;
- mask = realloc(mask, nodemask_sz / 8);
+ mask = realloc(mask, nodemask_sz / 8 + sizeof(unsigned long));
if (!mask)
return;
} while (get_mempolicy(&pol, mask, nodemask_sz + 1, 0, 0) < 0 && errno == EINVAL &&

View File

@ -1,6 +1,6 @@
Name: numactl
Version: 2.0.16
Release: 7
Release: 12
Summary: Library for tuning for Non Uniform Memory Access machines
License: GPLv2
URL: https://github.com/numactl/numactl
@ -15,6 +15,13 @@ Patch0005: 0005-numactl.c-Remove-unused-variable.patch
Patch0006: 0006-numactl.c-Fix-merging-of-neighboring-pages-policies-.patch
Patch0007: 0007-shm.c-Replace-stat64-fstat64-ftruncate64mmap64-with-.patch
Patch0008: 0008-numastat-Update-system-hugepages-memory-info-from-sy.patch
Patch0009: 0009-riscv64-remove-flag-latomic.patch
Patch0010: 0010-fix-fix-memory-leaks-when-run-with-H.patch
Patch0011: 0011-libnuma-Fix-unexpected-output.patch
Patch0012: 0012-libnuma-Fix-incorrect-print-and-exit-of-numa_preferr.patch
Patch0013: 0013-fix-the-using-of-the-uninitialized-value.patch
Patch0014: 0014-backport-Make-numa_available-respect-EPERM.patch
Patch0015: 0015-backport-fix-nodemask-allocation-size-for-get_mempolicy.patch
%description
Simple NUMA policy support. It consists of a numactl program to run other
@ -83,6 +90,23 @@ LD_LIBRARY_PATH=$(pwd)/.libs make check
%{_mandir}/man3/*.3*
%changelog
* Tue Dec 3 2024 andy <liuyang01@kylinos.cn> - 2.0.16-12
- backport patches from upstream
- libnuma: Make numa_available respect EPERM
- libnuma: fix nodemask allocation size for get_mempolicy
* Tue Jul 2 2024 zhangyaqi <zhangyaqi@kylinos.cn> - 2.0.16-11
- numademo: Fix the using of the uninitialized value
* Tue Apr 16 2024 zhangnaichuan <zhangnaichuan@huawei.com> - 2.0.16-10
- libnuma: Fix incorrect print and exit of numa_preferred/_many APIs
* Tue Dec 19 2023 chenhaixiang <chenhaixiang3@huawei.com> - 2.0.16-9
- fix: fix memory leaks when run with -H
* Wed Jul 19 2023 laokz <zhangkai@iscas.ac.cn> - 2.0.16-8
- Makefile: remove redundant -latomic flag for riscv64
* Sun Jun 25 2023 wuxu <wuxu.wu@huawei.com> - 2.0.16-7
- numastat: Update system hugepages memory info from sysfs/node/hugepages directory