Module Name: src Committed By: martin Date: Sun May 12 09:21:12 UTC 2019
Modified Files: src/common/lib/libc/sys [netbsd-8]: cpuset.c src/usr.sbin/cpuctl [netbsd-8]: cpuctl.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.18.26.1 src/common/lib/libc/sys/cpuset.c cvs rdiff -u -r1.28 -r1.28.8.1 src/usr.sbin/cpuctl/cpuctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/common/lib/libc/sys/cpuset.c diff -u src/common/lib/libc/sys/cpuset.c:1.18 src/common/lib/libc/sys/cpuset.c:1.18.26.1 --- src/common/lib/libc/sys/cpuset.c:1.18 Fri Mar 9 15:41:16 2012 +++ src/common/lib/libc/sys/cpuset.c Sun May 12 09:21:12 2019 @@ -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 @@ __RCSID("$NetBSD: cpuset.c,v 1.18 2012/0 #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 { \ Index: src/usr.sbin/cpuctl/cpuctl.c diff -u src/usr.sbin/cpuctl/cpuctl.c:1.28 src/usr.sbin/cpuctl/cpuctl.c:1.28.8.1 --- src/usr.sbin/cpuctl/cpuctl.c:1.28 Mon Nov 16 03:34:50 2015 +++ src/usr.sbin/cpuctl/cpuctl.c Sun May 12 09:21:12 2019 @@ -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 @@ cpu_ucode(char **argv) 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 @@ cpu_identify(char **argv) 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 "