forked from pool/numactl
This commit is contained in:
parent
bb1e2e3461
commit
8b2da7fd6e
136
numactl-fix-for-ppc64.patch
Normal file
136
numactl-fix-for-ppc64.patch
Normal file
@ -0,0 +1,136 @@
|
||||
From: Bernhard Walle <bwalle@suse.de>
|
||||
Subject: [PATCH] Fix "memset fails with 'mbind: Invalid argument'" on PPC64
|
||||
References: bnc #455977
|
||||
|
||||
Backport of
|
||||
https://bugzilla.novell.com/attachment.cgi?id=264645
|
||||
|
||||
|
||||
Signed-off-by: Bernhard Walle <bwalle@suse.de>
|
||||
|
||||
---
|
||||
libnuma.c | 56 +++++++++++++++++++++++++++++++++++++++++++++-----------
|
||||
numaint.h | 1 +
|
||||
2 files changed, 46 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/libnuma.c
|
||||
+++ b/libnuma.c
|
||||
@@ -69,12 +69,37 @@ static int maxprocnode = -1;
|
||||
static int maxproccpu = -1;
|
||||
static int nodemask_sz = 0;
|
||||
static int cpumask_sz = 0;
|
||||
+static int is_bigendian_64;
|
||||
|
||||
int numa_exit_on_error = 0;
|
||||
int numa_exit_on_warn = 0;
|
||||
static void set_sizes(void);
|
||||
|
||||
/*
|
||||
+ * return 1 if this machine is big-endian 64-bit
|
||||
+ */
|
||||
+int
|
||||
+big_endian64()
|
||||
+{
|
||||
+ union {
|
||||
+ struct {
|
||||
+ int a;
|
||||
+ int b;
|
||||
+ } ints;
|
||||
+ struct {
|
||||
+ long a;
|
||||
+ } lng;
|
||||
+ } ua;
|
||||
+ if (sizeof(long) != 8)
|
||||
+ return 0;
|
||||
+ ua.ints.a = 0;
|
||||
+ ua.ints.b = 3;
|
||||
+ if (ua.lng.a == 3)
|
||||
+ return 1;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
* There are two special functions, _init(void) and _fini(void), which
|
||||
* are called automatically by the dynamic loader whenever a library is loaded.
|
||||
*
|
||||
@@ -91,6 +116,7 @@ numa_init(void)
|
||||
for (i = 0; i < max; i++)
|
||||
nodemask_set_compat((nodemask_t *)&numa_all_nodes, i);
|
||||
memset(&numa_no_nodes, 0, sizeof(numa_no_nodes));
|
||||
+ is_bigendian_64 = big_endian64();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -103,10 +129,18 @@ numa_init(void)
|
||||
static unsigned int
|
||||
_getbit(const struct bitmask *bmp, unsigned int n)
|
||||
{
|
||||
- if (n < bmp->size)
|
||||
- return (bmp->maskp[n/bitsperlong] >> (n % bitsperlong)) & 1;
|
||||
- else
|
||||
- return 0;
|
||||
+ unsigned long *ip;
|
||||
+
|
||||
+ if (n < bmp->size) {
|
||||
+ if (is_bigendian_64) {
|
||||
+ ip = bmp->maskp;
|
||||
+ return (ip[n/bitsperlong] >>
|
||||
+ (n % bitsperlong)) & 1;
|
||||
+ } else
|
||||
+ return (bmp->maskp[n/bitsperlong] >>
|
||||
+ (n % bitsperlong)) & 1;
|
||||
+ } else
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -372,10 +406,10 @@ read_mask(char *s, struct bitmask *bmp)
|
||||
{
|
||||
char *end = s;
|
||||
char *prevend;
|
||||
- unsigned int *start = (unsigned int *)bmp->maskp;
|
||||
- unsigned int *p = start;
|
||||
- unsigned int *q;
|
||||
- unsigned int i;
|
||||
+ unsigned long *start = (unsigned long *)bmp->maskp;
|
||||
+ unsigned long *p = start;
|
||||
+ unsigned long *q;
|
||||
+ unsigned long i;
|
||||
unsigned int n = 0;
|
||||
|
||||
i = strtoul(s, &end, 16);
|
||||
@@ -404,21 +438,21 @@ read_mask(char *s, struct bitmask *bmp)
|
||||
* is the highest and we put it first because we read it first.
|
||||
*/
|
||||
for (q = start + n, p = start; p < q; q--, p++) {
|
||||
- unsigned int x = *q;
|
||||
+ unsigned long x = *q;
|
||||
|
||||
*q = *p;
|
||||
*p = x;
|
||||
}
|
||||
|
||||
/* Poor mans fls() */
|
||||
- for(i = 31; i >= 0; i--)
|
||||
+ for(i = sizeof(unsigned long)*8 - 1; i >= 0; i--)
|
||||
if (test_bit(i, start + n))
|
||||
break;
|
||||
|
||||
/*
|
||||
* Return the last bit set
|
||||
*/
|
||||
- return ((sizeof(unsigned int)*8) * n) + i;
|
||||
+ return ((sizeof(unsigned long)*8) * n) + i;
|
||||
}
|
||||
|
||||
/*
|
||||
--- a/numaint.h
|
||||
+++ b/numaint.h
|
||||
@@ -32,6 +32,7 @@ enum numa_warn {
|
||||
};
|
||||
|
||||
#define howmany(x,y) (((x)+((y)-1))/(y))
|
||||
+#define bitsperint (8 * sizeof(unsigned int))
|
||||
#define bitsperlong (8 * sizeof(unsigned long))
|
||||
#define longsperbits(n) howmany(n, bitsperlong)
|
||||
#define bytesperbits(x) ((x+7)/8)
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 13 09:48:27 CET 2009 - bwalle@suse.de
|
||||
|
||||
- Fix "memset fails with 'mbind: Invalid argument'" on PPC64
|
||||
(bnc #455977).
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Dec 8 16:46:29 CET 2008 - kukuk@suse.de
|
||||
|
||||
|
11
numactl.spec
11
numactl.spec
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package numactl (Version 2.0.2)
|
||||
#
|
||||
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -23,7 +23,7 @@ Name: numactl
|
||||
License: GPL v2 only; GPL v2 or later
|
||||
Summary: NUMA Policy Control
|
||||
Version: 2.0.2
|
||||
Release: 19
|
||||
Release: 21
|
||||
AutoReqProv: on
|
||||
Source: numactl-%{version}.tar.bz2
|
||||
Group: System/Management
|
||||
@ -31,6 +31,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
ExclusiveArch: ia64 x86_64 ppc64 ppc
|
||||
Requires: perl
|
||||
Patch0: %{name}-compat.diff
|
||||
Patch1: %{name}-fix-for-ppc64.patch
|
||||
|
||||
%description
|
||||
Control NUMA policy for individual processes. Offer libnuma for
|
||||
@ -81,6 +82,9 @@ Authors:
|
||||
%prep
|
||||
%setup
|
||||
%patch0 -p1
|
||||
%ifarch ppc ppc64
|
||||
%patch1 -p1
|
||||
%endif
|
||||
|
||||
%build
|
||||
make CFLAGS="${RPM_OPT_FLAGS}"
|
||||
@ -120,6 +124,9 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{_libdir}/lib*so
|
||||
|
||||
%changelog
|
||||
* Tue Jan 13 2009 bwalle@suse.de
|
||||
- Fix "memset fails with 'mbind: Invalid argument'" on PPC64
|
||||
(bnc #455977).
|
||||
* Mon Dec 08 2008 kukuk@suse.de
|
||||
- Fix baselibs.conf
|
||||
* Fri Dec 05 2008 bwalle@suse.de
|
||||
|
Loading…
Reference in New Issue
Block a user