From ee18d3b1096f35e712a4af904e7307e2ab71c330 Mon Sep 17 00:00:00 2001 From: pstef Date: Sat, 27 Jun 2020 20:01:56 +0000 Subject: [PATCH] ps(1): don't try to handle non-SMP systems As reported by kib, sysctl machdep.smp_active doesn't exist and on UP we return CPU 0 for all threads anyway. Reported by: kib --- bin/ps/extern.h | 2 +- bin/ps/print.c | 3 --- bin/ps/ps.c | 15 --------------- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/bin/ps/extern.h b/bin/ps/extern.h index 2e72632b6542..723d7fcb85dd 100644 --- a/bin/ps/extern.h +++ b/bin/ps/extern.h @@ -41,7 +41,7 @@ extern fixpt_t ccpu; extern int cflag, eval, fscale, nlistread, rawcpu; extern unsigned long mempages; extern time_t now; -extern int showthreads, sumrusage, termwidth, smp; +extern int showthreads, sumrusage, termwidth; extern STAILQ_HEAD(velisthead, varent) varlist; __BEGIN_DECLS diff --git a/bin/ps/print.c b/bin/ps/print.c index d137056aa580..b4458b453cdd 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -555,9 +555,6 @@ cpunum(KINFO *k, VARENT *ve __unused) { char *cpu; - if (!smp) - return (NULL); - if (k->ki_p->ki_stat == SRUN && k->ki_p->ki_oncpu != NOCPU) { asprintf(&cpu, "%d", k->ki_p->ki_oncpu); } else { diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 0bc388c25260..f6d32e5411fe 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -105,7 +105,6 @@ int rawcpu; /* -C */ int sumrusage; /* -S */ int termwidth; /* Width of the screen (0 == infinity). */ int showthreads; /* will threads be shown? */ -int smp; /* multi-processor support */ struct velisthead varlist = STAILQ_HEAD_INITIALIZER(varlist); @@ -158,7 +157,6 @@ static void saveuser(KINFO *); static void scanvars(void); static void sizevars(void); static void pidmax_init(void); -static void smp_init(void); static void usage(void); static char dfmt[] = "pid,tt,state,time,command"; @@ -228,7 +226,6 @@ main(int argc, char *argv[]) argv[1] = kludge_oldps_options(PS_ARGS, argv[1], argv[2]); pidmax_init(); - smp_init(); all = descendancy = _fmt = nselectors = optfatal = 0; prtheader = showthreads = wflag = xkeep_implied = 0; @@ -1459,18 +1456,6 @@ pidmax_init(void) } } -static void -smp_init(void) -{ - size_t size; - - size = sizeof(smp); - if ((sysctlbyname("machdep.smp_active", &smp, &size, NULL, 0) != 0 && - sysctlbyname("kern.smp.active", &smp, &size, NULL, 0) != 0) || - size != sizeof(smp)) - smp = 0; -} - static void __dead2 usage(void) {