Merge ~paelzer/ubuntu/+source/numactl:lp1817258-cosmic into ubuntu/+source/numactl:ubuntu/cosmic-devel

Proposed by Christian Ehrhardt 
Status: Merged
Approved by: Robie Basak
Approved revision: 21a504195adff57cbc78c25af97656b7fa32b39c
Merged at revision: 21a504195adff57cbc78c25af97656b7fa32b39c
Proposed branch: ~paelzer/ubuntu/+source/numactl:lp1817258-cosmic
Merge into: ubuntu/+source/numactl:ubuntu/cosmic-devel
Diff against target: 302 lines (+269/-0)
5 files modified
debian/changelog (+10/-0)
debian/patches/FTBFS-deprecated-use-readdir-3-instead.patch (+75/-0)
debian/patches/FTBFS-include-sys-sysmacros.h-for-major-minor.patch (+45/-0)
debian/patches/lp1817258-Segment-fault-when-numa-nodes-not-sequential-or-cont.patch (+136/-0)
debian/patches/series (+3/-0)
Reviewer Review Type Date Requested Status
Robie Basak Approve
Canonical Server Pending
git-ubuntu developers Pending
Review via email: mp+363778@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robie Basak (racb) wrote :

lgtm with one minor comment inline.

review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

It was modified to their former upstreaming in the last bug - adapted the patch headers thanks!

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Fixed tagged and pushed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 3ab8d05..2c1683a 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,13 @@
6+numactl (2.0.11-2.2ubuntu0.1) cosmic; urgency=medium
7+
8+ * d/p/lp1817258-Segment-fault-when-numa-nodes-not-sequential-or-cont.patch:
9+ fix segfault on uncommon numa node setups (LP: #1817258)
10+ * Fix FTBFS in Cosmic (LP: #1818057)
11+ - d/p/FTBFS-deprecated-use-readdir-3-instead.patch
12+ - d/p/FTBFS-include-sys-sysmacros.h-for-major-minor.patch
13+
14+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Wed, 20 Jun 2018 16:36:20 +0200
15+
16 numactl (2.0.11-2.2) unstable; urgency=medium
17
18 * Non-maintainer upload.
19diff --git a/debian/patches/FTBFS-deprecated-use-readdir-3-instead.patch b/debian/patches/FTBFS-deprecated-use-readdir-3-instead.patch
20new file mode 100644
21index 0000000..29da826
22--- /dev/null
23+++ b/debian/patches/FTBFS-deprecated-use-readdir-3-instead.patch
24@@ -0,0 +1,75 @@
25+From b407601328732d92f3577e2c81a216a63b7db3c3 Mon Sep 17 00:00:00 2001
26+From: Ross Zwisler <ross.zwisler@linux.intel.com>
27+Date: Thu, 22 Mar 2018 10:59:52 -0600
28+Subject: [PATCH] readdir_r(3) is deprecated, use readdir(3) instead
29+MIME-Version: 1.0
30+Content-Type: text/plain; charset=UTF-8
31+Content-Transfer-Encoding: 8bit
32+
33+gcc 7.3.1 provides the following warning when compiling affinity.c:
34+
35+affinity.c: In function ‘affinity_file’:
36+affinity.c:158:2: warning: ‘readdir_r’ is deprecated [-Wdeprecated-declarations]
37+ while (readdir_r(dir, &de, &dep) == 0 && dep) {
38+ ^~~~~
39+In file included from affinity.c:39:0:
40+/usr/include/dirent.h:183:12: note: declared here
41+ extern int readdir_r (DIR *__restrict __dirp,
42+ ^~~~~~~~~
43+
44+According to the man page for readdir_r(3), calls this function should be
45+fixed to instead use readdir(3).
46+
47+One interesting note: I had to move the affinity_class() call above the
48+closedir(dir) call in affinity_file() because with readdir(3) the string
49+stored in 'name' is cleared on closedir(). This doesn't happen with
50+readdir_r() for some reason.
51+
52+Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
53+
54+Origin: upstream, https://github.com/numactl/numactl/commit/b407601328732d92f3577e2c81a216a63b7db3c3
55+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1711478
56+Last-Update: 2019-02-28
57+---
58+ affinity.c | 9 ++++++---
59+ 1 file changed, 6 insertions(+), 3 deletions(-)
60+
61+diff --git a/affinity.c b/affinity.c
62+index 85597fc..06784f7 100644
63+--- a/affinity.c
64++++ b/affinity.c
65+@@ -131,7 +131,7 @@ static int affinity_file(struct bitmask *mask, char *cls, const char *file)
66+ int n;
67+ unsigned maj = 0, min = 0;
68+ dev_t d;
69+- struct dirent de, *dep;
70++ struct dirent *dep;
71+
72+ cls = "block";
73+ char fn[sizeof("/sys/class/") + strlen(cls)];
74+@@ -155,8 +155,10 @@ static int affinity_file(struct bitmask *mask, char *cls, const char *file)
75+ cls);
76+ return -1;
77+ }
78+- while (readdir_r(dir, &de, &dep) == 0 && dep) {
79++ while ((dep = readdir(dir)) != NULL) {
80+ char *name = dep->d_name;
81++ int ret;
82++
83+ if (*name == '.')
84+ continue;
85+ char *dev;
86+@@ -179,8 +181,9 @@ static int affinity_file(struct bitmask *mask, char *cls, const char *file)
87+ if (major(d) != maj || minor(d) != min)
88+ continue;
89+
90++ ret = affinity_class(mask, "block", name);
91+ closedir(dir);
92+- return affinity_class(mask, "block", name);
93++ return ret;
94+ }
95+ closedir(dir);
96+ numa_warn(W_blockdev5, "Cannot find block device %x:%x in sysfs for `%s'",
97+--
98+2.17.1
99+
100diff --git a/debian/patches/FTBFS-include-sys-sysmacros.h-for-major-minor.patch b/debian/patches/FTBFS-include-sys-sysmacros.h-for-major-minor.patch
101new file mode 100644
102index 0000000..878c21c
103--- /dev/null
104+++ b/debian/patches/FTBFS-include-sys-sysmacros.h-for-major-minor.patch
105@@ -0,0 +1,45 @@
106+From 25691a084a2012a339395ade567dbae814e237e9 Mon Sep 17 00:00:00 2001
107+From: Mike Frysinger <vapier@gentoo.org>
108+Date: Mon, 18 Apr 2016 18:49:51 -0400
109+Subject: [PATCH] include sys/sysmacros.h for major/minor
110+
111+These functions are not part of any official spec, and glibc has always
112+kept them in sys/sysmacros.h. As glibc moves to conform to POSIX, and
113+more alternative C libraries come up, we need to include this header
114+explicitly to get the prototypes. Otherwise we fail to build like:
115+
116+affinity.c: In function 'affinity_file':
117+affinity.c:177:7: warning: implicit declaration of function 'major' [-Wimplicit-function-declaration]
118+ if (major(d) != maj || minor(d) != min)
119+ ^
120+affinity.c:177:26: warning: implicit declaration of function 'minor' [-Wimplicit-function-declaration]
121+ if (major(d) != maj || minor(d) != min)
122+ ^
123+./.libs/libnuma.so: undefined reference to 'minor'
124+./.libs/libnuma.so: undefined reference to 'major'
125+collect2: error: ld returned 1 exit status
126+
127+See downstream bug: https://bugs.gentoo.org/580098
128+
129+Origin: upstream, https://github.com/numactl/numactl/commit/25691a084a2012a339395ade567dbae814e237e9
130+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1711478
131+Last-Update: 2019-02-28
132+---
133+ affinity.c | 1 +
134+ 1 file changed, 1 insertion(+)
135+
136+diff --git a/affinity.c b/affinity.c
137+index c460acf..85597fc 100644
138+--- a/affinity.c
139++++ b/affinity.c
140+@@ -40,6 +40,7 @@
141+ #include <linux/rtnetlink.h>
142+ #include <linux/netlink.h>
143+ #include <sys/types.h>
144++#include <sys/sysmacros.h>
145+ #include <ctype.h>
146+ #include <assert.h>
147+ #include <regex.h>
148+--
149+2.17.1
150+
151diff --git a/debian/patches/lp1817258-Segment-fault-when-numa-nodes-not-sequential-or-cont.patch b/debian/patches/lp1817258-Segment-fault-when-numa-nodes-not-sequential-or-cont.patch
152new file mode 100644
153index 0000000..1f68a7b
154--- /dev/null
155+++ b/debian/patches/lp1817258-Segment-fault-when-numa-nodes-not-sequential-or-cont.patch
156@@ -0,0 +1,136 @@
157+From b608687037d873ad82d6318f231b3d6612e8601d Mon Sep 17 00:00:00 2001
158+From: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
159+Date: Wed, 21 Dec 2016 12:48:11 +0530
160+Subject: [PATCH] Segment fault when numa nodes not sequential or contiguous
161+
162+While trying to get stat of the guest process (configured with hugepages), numastat fails
163+
164+====================
165+Environment details
166+====================
167+Linux lep8b 4.8.0-30-generic #32-Ubuntu SMP Fri Dec 2 03:43:46 UTC 2016 ppc64le ppc64le ppc64le GNU/Linu
168+
169+=====
170+Issue
171+=====
172+2016-12-14 07:02:56,396 process L0368 INFO | Running 'numastat 61257'
173+2016-12-14 07:02:56,402 process L0462 DEBUG| [stderr] *** Error in `numastat': double free or corruption (out): 0x00000100265005a0 ***
174+2016-12-14 07:02:56,403 process L0462 DEBUG| [stdout]
175+2016-12-14 07:02:56,403 process L0482 INFO | Command 'numastat 61257' finished with -6 after 0.00309896469116s
176+2016-12-14 07:02:56,403 process L0462 DEBUG| [stdout] Per-node process memory usage (in MBs) for PID 61257 (qemu-system-ppc)
177+2016-12-14 07:02:56,404 process L0462 DEBUG| [stderr] ======= Backtrace: =========
178+2016-12-14 07:02:56,404 process L0462 DEBUG| [stderr] /lib/powerpc64le-linux-gnu/libc.so.6(+0x86d54)[0x3fff9a736d54]
179+2016-12-14 07:02:56,404 process L0462 DEBUG| [stderr] /lib/powerpc64le-linux-gnu/libc.so.6(+0x93c30)[0x3fff9a743c30]
180+2016-12-14 07:02:56,404 process L0462 DEBUG| [stderr] /lib/powerpc64le-linux-gnu/libc.so.6(cfree+0x68)[0x3fff9a748218]
181+2016-12-14 07:02:56,405 process L0462 DEBUG| [stderr] /lib/powerpc64le-linux-gnu/libc.so.6(fclose+0x1c8)[0x3fff9a727d68]
182+2016-12-14 07:02:56,405 process L0462 DEBUG| [stderr] numastat(+0x7aa4)[0x401d7aa4]
183+2016-12-14 07:02:56,405 process L0462 DEBUG| [stderr] numastat(+0x2388)[0x401d2388]
184+2016-12-14 07:02:56,405 process L0462 DEBUG| [stderr] /lib/powerpc64le-linux-gnu/libc.so.6(+0x2291c)[0x3fff9a6d291c]
185+2016-12-14 07:02:56,405 process L0462 DEBUG| [stderr] /lib/powerpc64le-linux-gnu/libc.so.6(__libc_start_main+0xb8)[0x3fff9a6d2b18]
186+2016-12-14 07:02:56,405 process L0462 DEBUG| [stderr] ======= Memory map: ========
187+2016-12-14 07:02:56,405 process L0462 DEBUG| [stderr] 401d0000-401e0000 r-xp 00000000 08:92 40325510 /usr/bin/numastat
188+2016-12-14 07:02:56,405 process L0462 DEBUG| [stderr] 401e0000-401f0000 r--p 00000000 08:92 40325510 /usr/bin/numastat
189+2016-12-14 07:02:56,406 process L0462 DEBUG| [stderr] 401f0000-40200000 rw-p 00010000 08:92 40325510 /usr/bin/numastat
190+2016-12-14 07:02:56,406 process L0462 DEBUG| [stderr] 10026500000-10026530000 rw-p 00000000 00:00 0 [heap]
191+2016-12-14 07:02:56,406 process L0462 DEBUG| [stderr] 3fff9a6b0000-3fff9a860000 r-xp 00000000 08:92 25745199 /lib/powerpc64le-linux-gnu/libc-2.24.so
192+2016-12-14 07:02:56,406 process L0462 DEBUG| [stderr] 3fff9a860000-3fff9a870000 ---p 001b0000 08:92 25745199 /lib/powerpc64le-linux-gnu/libc-2.24.so
193+2016-12-14 07:02:56,406 process L0462 DEBUG| [stderr] 3fff9a870000-3fff9a880000 r--p 001b0000 08:92 25745199 /lib/powerpc64le-linux-gnu/libc-2.24.so
194+2016-12-14 07:02:56,406 process L0462 DEBUG| [stderr] 3fff9a880000-3fff9a890000 rw-p 001c0000 08:92 25745199 /lib/powerpc64le-linux-gnu/libc-2.24.so
195+2016-12-14 07:02:56,406 process L0462 DEBUG| [stderr] 3fff9a8b0000-3fff9a8c0000 rw-p 00000000 00:00 0
196+2016-12-14 07:02:56,407 process L0462 DEBUG| [stderr] 3fff9a8c0000-3fff9a8e0000 r-xp 00000000 00:00 0 [vdso]
197+2016-12-14 07:02:56,407 process L0462 DEBUG| [stderr] 3fff9a8e0000-3fff9a920000 r-xp 00000000 08:92 25745195 /lib/powerpc64le-linux-gnu/ld-2.24.so
198+2016-12-14 07:02:56,407 process L0462 DEBUG| [stderr] 3fff9a920000-3fff9a930000 r--p 00030000 08:92 25745195 /lib/powerpc64le-linux-gnu/ld-2.24.so
199+2016-12-14 07:02:56,407 process L0462 DEBUG| [stderr] 3fff9a930000-3fff9a940000 rw-p 00040000 08:92 25745195 /lib/powerpc64le-linux-gnu/ld-2.24.so
200+2016-12-14 07:02:56,407 process L0462 DEBUG| [stderr] 3fffdd320000-3fffdd350000 rw-p 00000000 00:00 0 [stack]
201+
202+=============
203+Recreation Steps
204+=============
205+1. Configure host with hugepages
206+2. Start a guest and attach following memory device xml,
207+<?xml version='1.0' encoding='UTF-8'?>
208+<memory model="dimm"><target><size unit="KiB">8388608</size><node>0</node></target><source><pagesize unit="KiB">16384</pagesize><nodemask>0</nodemask></source></memory>
209+3. Set the rules in guest
210+4. execute numastat of guest pid
211+
212+Expected Result :
213+Provide PID numastat
214+
215+Per-node process memory usage (in MBs) for PID 55119 (qemu-system-ppc)
216+Node 0 Node 1 Node 16
217+--------------- --------------- ---------------
218+Huge 0.00 0.00 0.00
219+Heap 2.00 0.38 0.00
220+Stack 0.00 0.00 0.00
221+Private 31800.12 183.06 0.00
222+---------------- --------------- --------------- ---------------
223+Total 31802.12 183.44 0.00
224+
225+Node 17 Total
226+--------------- ---------------
227+Huge 0.00 0.00
228+Heap 0.00 15.25
229+Stack 0.00 0.06
230+Private 0.00 33169.31
231+---------------- --------------- ---------------
232+Total 0.00 34345.00
233+*** Error in `numastat': free(): invalid next size (fast): 0x000001003f2c0580 ***
234+======= Backtrace: =========
235+/lib/powerpc64le-linux-gnu/libc.so.6(+0x86d54)[0x3fff82866d54]
236+/lib/powerpc64le-linux-gnu/libc.so.6(+0x93c30)[0x3fff82873c30]
237+/lib/powerpc64le-linux-gnu/libc.so.6(cfree+0x68)[0x3fff82878218]
238+numastat(+0x4244)[0x5adc4244]
239+numastat(+0x7d24)[0x5adc7d24]
240+numastat(+0x2388)[0x5adc2388]
241+/lib/powerpc64le-linux-gnu/libc.so.6(+0x2291c)[0x3fff8280291c]
242+/lib/powerpc64le-linux-gnu/libc.so.6(__libc_start_main+0xb8)[0x3fff82802b18]
243+======= Memory map: ========
244+5adc0000-5add0000 r-xp 00000000 08:92 40325510 /usr/bin/numastat
245+5add0000-5ade0000 r--p 00000000 08:92 40325510 /usr/bin/numastat
246+5ade0000-5adf0000 rw-p 00010000 08:92 40325510 /usr/bin/numastat
247+1003f2c0000-1003f2f0000 rw-p 00000000 00:00 0 [heap]
248+3fff827e0000-3fff82990000 r-xp 00000000 08:92 25745199 /lib/powerpc64le-linux-gnu/libc-2.24.so
249+3fff82990000-3fff829a0000 ---p 001b0000 08:92 25745199 /lib/powerpc64le-linux-gnu/libc-2.24.so
250+3fff829a0000-3fff829b0000 r--p 001b0000 08:92 25745199 /lib/powerpc64le-linux-gnu/libc-2.24.so
251+3fff829b0000-3fff829c0000 rw-p 001c0000 08:92 25745199 /lib/powerpc64le-linux-gnu/libc-2.24.so
252+3fff829e0000-3fff829f0000 rw-p 00000000 00:00 0
253+3fff829f0000-3fff82a10000 r-xp 00000000 00:00 0 [vdso]
254+3fff82a10000-3fff82a50000 r-xp 00000000 08:92 25745195 /lib/powerpc64le-linux-gnu/ld-2.24.so
255+3fff82a50000-3fff82a60000 r--p 00030000 08:92 25745195 /lib/powerpc64le-linux-gnu/ld-2.24.so
256+3fff82a60000-3fff82a70000 rw-p 00040000 08:92 25745195 /lib/powerpc64le-linux-gnu/ld-2.24.so
257+3fffc3b90000-3fffc3bc0000 rw-p 00000000 00:00 0 [stack]
258+Aborted
259+
260+Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
261+Signed-off-by: Andi Kleen <ak@linux.intel.com>
262+
263+Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
264+Original-Author: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
265+Origin: backport, https://github.com/numactl/numactl/commit/b608687037d873ad82d6318f231b3d6612e8601d
266+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1817258
267+Last-Update: 2019-02-28
268+---
269+ numastat.c | 7 ++++++-
270+ 1 file changed, 6 insertions(+), 1 deletion(-)
271+
272+diff --git a/numastat.c b/numastat.c
273+index 1924dba..e0a5639 100644
274+--- a/numastat.c
275++++ b/numastat.c
276+@@ -1054,7 +1054,12 @@ void show_process_info() {
277+ } else {
278+ tmp_row = header_rows + pid_ix;
279+ }
280+- int tmp_col = header_cols + node_num;
281++ // Don't assume nodes are sequential or contiguous.
282++ // Need to find correct tmp_col from node_ix_map
283++ int i = 0;
284++ while(node_ix_map[i++] != node_num)
285++ ;
286++ int tmp_col = header_cols + i - 1;
287+ double_addto(&table, tmp_row, tmp_col, value);
288+ double_addto(&table, tmp_row, total_col_ix, value);
289+ double_addto(&table, total_row_ix, tmp_col, value);
290+--
291+2.17.1
292+
293diff --git a/debian/patches/series b/debian/patches/series
294index c3798c9..4fecd67 100644
295--- a/debian/patches/series
296+++ b/debian/patches/series
297@@ -1,2 +1,5 @@
298 Allow-building-on-ARM-systems.patch
299 Add-NAME-section-to-numastat-manpage.patch
300+lp1817258-Segment-fault-when-numa-nodes-not-sequential-or-cont.patch
301+FTBFS-deprecated-use-readdir-3-instead.patch
302+FTBFS-include-sys-sysmacros.h-for-major-minor.patch

Subscribers

People subscribed via source and target branches