Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src Pull up following revision(s) (requested by maxv in ticke...



details:   https://anonhg.NetBSD.org/src/rev/5f86188de515
branches:  netbsd-8
changeset: 451258:5f86188de515
user:      martin <martin%NetBSD.org@localhost>
date:      Sun May 12 09:21:12 2019 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #1260):

        common/lib/libc/sys/cpuset.c: revision 1.21
        usr.sbin/cpuctl/cpuctl.c: revision 1.30

Fix bug, the computation of cpuset_nentries was incorrect, we must do +1
to be able to address the last 32 bits.

On a machine with 80 CPUs, this caused "cpuctl identify >64" to return
garbage.

Check the return value of cpuset_set(), to prevent future surprises.

diffstat:

 common/lib/libc/sys/cpuset.c |   6 +++---
 usr.sbin/cpuctl/cpuctl.c     |  10 ++++++----
 2 files changed, 9 insertions(+), 7 deletions(-)

diffs (65 lines):

diff -r 102fa1b610ee -r 5f86188de515 common/lib/libc/sys/cpuset.c
--- a/common/lib/libc/sys/cpuset.c      Sun May 12 09:19:07 2019 +0000
+++ b/common/lib/libc/sys/cpuset.c      Sun May 12 09:21:12 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuset.c,v 1.18 2012/03/09 15:41:16 christos Exp $     */
+/*     $NetBSD: cpuset.c,v 1.18.26.1 2019/05/12 09:21:12 martin Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #ifndef _STANDALONE
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: cpuset.c,v 1.18 2012/03/09 15:41:16 christos Exp $");
+__RCSID("$NetBSD: cpuset.c,v 1.18.26.1 2019/05/12 09:21:12 martin Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -50,7 +50,7 @@
 
 #define        CPUSET_SHIFT    5
 #define        CPUSET_MASK     31
-#define CPUSET_NENTRIES(nc)    ((nc) > 32 ? ((nc) >> CPUSET_SHIFT) : 1)
+#define        CPUSET_NENTRIES(nc)     (((nc) >> CPUSET_SHIFT) + 1)
 #ifndef __lint__
 #define CPUSET_SIZE(n) (sizeof( \
        struct {  \
diff -r 102fa1b610ee -r 5f86188de515 usr.sbin/cpuctl/cpuctl.c
--- a/usr.sbin/cpuctl/cpuctl.c  Sun May 12 09:19:07 2019 +0000
+++ b/usr.sbin/cpuctl/cpuctl.c  Sun May 12 09:21:12 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuctl.c,v 1.28 2015/11/16 03:34:50 mrg Exp $  */
+/*     $NetBSD: cpuctl.c,v 1.28.8.1 2019/05/12 09:21:12 martin Exp $   */
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2012, 2015 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #ifndef lint
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: cpuctl.c,v 1.28 2015/11/16 03:34:50 mrg Exp $");
+__RCSID("$NetBSD: cpuctl.c,v 1.28.8.1 2019/05/12 09:21:12 martin Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -239,7 +239,8 @@
                if (cpuset == NULL)
                        err(EXIT_FAILURE, "cpuset_create");
                cpuset_zero(cpuset);
-               cpuset_set(id, cpuset);
+               if (cpuset_set(id, cpuset) < 0)
+                       err(EXIT_FAILURE, "cpuset_set");
                if (_sched_setaffinity(0, 0, cpuset_size(cpuset), cpuset) < 0) {
                        err(EXIT_FAILURE, "_sched_setaffinity");
                }
@@ -272,7 +273,8 @@
                        if (cpuset == NULL)
                                err(EXIT_FAILURE, "cpuset_create");
                        cpuset_zero(cpuset);
-                       cpuset_set(id, cpuset);
+                       if (cpuset_set(id, cpuset) < 0)
+                               err(EXIT_FAILURE, "cpuset_set");
                        if (_sched_setaffinity(0, 0, cpuset_size(cpuset), cpuset) < 0) {
                                if (errno == EPERM) {
                                        printf("Cannot bind to target CPU.  Output "



Home | Main Index | Thread Index | Old Index