Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
11048 need a way to disable SMT
Browse files Browse the repository at this point in the history
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Reviewed by: Gergo Doma <domag02@gmail.com>
Approved by: Gordon Ross <gwr@nexenta.com>
  • Loading branch information
John Levon authored and jjelinek committed May 22, 2019
1 parent 3f1d0a2 commit c3377ee
Show file tree
Hide file tree
Showing 56 changed files with 1,061 additions and 500 deletions.
29 changes: 15 additions & 14 deletions usr/src/cmd/auditrecord/audit_record_attr.txt
Expand Up @@ -3,6 +3,7 @@
# other comments are removed.
##
## Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
## Copyright 2019 Joyent, Inc.
##
## CDDL HEADER START
##
Expand Down Expand Up @@ -72,9 +73,9 @@ token=exit:exit

# note names -- certain notes show up repeatedly; collected here
#
# To achieve the maximum line length to be less than 80 characters, the
# To achieve the maximum line length to be less than 80 characters, the
# note names (message=) can be defined as a multi line, each line except the
# last one finished with the backslash character.
# last one finished with the backslash character.

message=ipc_perm:The ipc and ipc_perm tokens are not included if \
the message ID is not valid.
Expand Down Expand Up @@ -108,15 +109,15 @@ user=head:subj:insert:ret
#
# comment is an array of strings separated by colons. If comments
# are listed on separate lines (recommended due to better
# readability/sustainability of the file), the preceding comment
# must end with a colon. The array starts at 1. (If the comment
# readability/sustainability of the file), the preceding comment
# must end with a colon. The array starts at 1. (If the comment
# contains a colon, use "&colon;" without the quotes.)
#
# case is used to generate alternate descriptions for a given
# record.
#
# Constraints - the string length; bear in mind, that any annotation of
# primitives below longer than is specified, will be silently truncated
# primitives below longer than is specified, will be silently truncated
# to given/defined amount of characters in the auditrecord(1M) runtime:
#
# primitive <= max (non-truncated) string length
Expand Down Expand Up @@ -825,7 +826,7 @@ label=AUE_FCHOWN
label=AUE_FCHOWNAT
# obsolete
see=openat(2)
case=With a valid absolute/relative file path
case=With a valid absolute/relative file path
format=path:[attr]
case=With an file path eq. NULL and valid file descriptor
format=kernel
Expand All @@ -852,14 +853,14 @@ label=AUE_FLOCK
label=AUE_FORKALL
format=[arg]1
comment=0, pid, "child PID"
note=The forkall(2) return values are undefined because the audit record
note=The forkall(2) return values are undefined because the audit record
note=is produced at the point that the child process is spawned.
# see audit.c

label=AUE_FORK1
format=[arg]1
comment=0, pid, "child PID"
note=The fork1(2) return values are undefined because the audit record
note=The fork1(2) return values are undefined because the audit record
note=is produced at the point that the child process is spawned.
# see audit.c

Expand Down Expand Up @@ -1254,7 +1255,7 @@ label=AUE_OPENAT_RW
# obsolete
see=openat(2)
format=path:[path_attr]:[attr]
# aui_fsat(): fm & O_RDWR
# aui_fsat(): fm & O_RDWR

label=AUE_OPEN_RWC
format=path:[path_attr]:[attr]
Expand Down Expand Up @@ -1385,15 +1386,15 @@ label=AUE_PUTPMSG
see=putpmsg(2)
format=arg1:[path]:[attr]:arg2:arg3
comment=1, file descriptor, "fd":
comment=4, priority, "pri":
comment=4, priority, "pri":
comment=5, flags, "flags"

label=AUE_P_ONLINE
format=arg1:arg2:text3
comment=1, processor ID, "processor ID":
comment=2, flags value, "flags":
comment=text form of flags. Values&colon; \
P_ONLINE, P_OFFLINE, P_NOINTR, P_SPARE, P_FAULTED, P_STATUS
P_ONLINE, P_OFFLINE, P_NOINTR, P_SPARE, P_FAULTED, P_STATUS, P_DISABLED

label=AUE_QUOTACTL
skip=Not used.
Expand Down Expand Up @@ -1441,7 +1442,7 @@ label=AUE_RECVFROM
comment=4, flags, "flags":
comment=from address:
comment=6, address length, "tolen"
note=The socket token for a bad socket is reported as "argument
note=The socket token for a bad socket is reported as "argument
note=token (1, socket descriptor, "fd")"

label=AUE_RECVMSG
Expand Down Expand Up @@ -1976,7 +1977,7 @@ label=AUE_SWAPON

label=AUE_SYMLINK
format=path:text1:[attr]
comment=symbolic link string
comment=symbolic link string

label=AUE_SYSINFO
note=Only SI_SET_HOSTNAME and SI_SET_SRPC_DOMAIN commands
Expand Down Expand Up @@ -2031,7 +2032,7 @@ label=AUE_UTIMES
label=AUE_VFORK
format=arg1
comment=0, pid, "child PID"
note=The vfork(2) return values are undefined because the audit record is
note=The vfork(2) return values are undefined because the audit record is
note=produced at the point that the child process is spawned.

label=AUE_VPIXSYS
Expand Down
3 changes: 2 additions & 1 deletion usr/src/cmd/cpc/common/cpustat.c
Expand Up @@ -24,7 +24,7 @@
*/

/*
* Copyright 2018 Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

#include <sys/types.h>
Expand Down Expand Up @@ -689,6 +689,7 @@ cpustat(void)
case P_POWEROFF:
case P_FAULTED:
case P_SPARE:
case P_DISABLED:
gstate[i++].cpuid = -1;
break;
default:
Expand Down
4 changes: 4 additions & 0 deletions usr/src/cmd/fm/modules/common/cpumem-retire/cma_cpu.c
Expand Up @@ -21,6 +21,8 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2019 Joyent, Inc.
*/

#include <cma.h>
Expand Down Expand Up @@ -302,6 +304,8 @@ p_online_state_fmt(int state)
return (PS_NOINTR);
case P_SPARE:
return (PS_SPARE);
case P_DISABLED:
return (PS_DISABLED);
default:
return ("unknown");
}
Expand Down
3 changes: 0 additions & 3 deletions usr/src/cmd/lp/cmd/lpadmin/do_printer.c
Expand Up @@ -40,9 +40,6 @@
#include <bsm/devices.h>
#include "lp.h"
#include "class.h"
#if defined PS_FAULTED
#undef PS_FAULTED
#endif
#include "printers.h"
#include "msgs.h"

Expand Down
3 changes: 0 additions & 3 deletions usr/src/cmd/lp/cmd/lpsched/exec.c
Expand Up @@ -29,9 +29,6 @@

#include <pwd.h>
#include <zone.h>
#if defined PS_FAULTED
#undef PS_FAULTED
#endif /* PS_FAULTED */
#include <dial.h>

#include <stdlib.h>
Expand Down
13 changes: 11 additions & 2 deletions usr/src/cmd/lp/include/printers.h
Expand Up @@ -25,13 +25,22 @@
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2019 Joyent, Inc.
*/

#pragma ident "%Z%%M% %I% %E% SMI"

#if !defined(_LP_PRINTERS_H)
#define _LP_PRINTERS_H

/*
* The following conflicts are also defined in sys/processor.h.
*/
#if defined PS_FAULTED
#undef PS_FAULTED
#endif
#if defined PS_DISABLED
#undef PS_DISABLED
#endif

/*
* Define the following to support administrator configurable
* streams modules:
Expand Down
4 changes: 3 additions & 1 deletion usr/src/cmd/mdb/common/modules/dtrace/dtrace.c
Expand Up @@ -22,7 +22,7 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2018, Joyent, Inc. All rights reserved.
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -824,6 +824,8 @@ dtracemdb_stat(void *varg, processorid_t cpu)
return (P_SPARE);
} else if (c.cpu_flags & CPU_FAULTED) {
return (P_FAULTED);
} else if (c.cpu_flags & CPU_DISABLED) {
return (P_DISABLED);
} else if ((c.cpu_flags & (CPU_READY | CPU_OFFLINE)) != CPU_READY) {
return (P_OFFLINE);
} else if (c.cpu_flags & CPU_ENABLE) {
Expand Down
4 changes: 2 additions & 2 deletions usr/src/cmd/mdb/common/modules/genunix/genunix.c
Expand Up @@ -21,7 +21,7 @@
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2019 Joyent, Inc.
* Copyright (c) 2013 by Delphix. All rights reserved.
*/

Expand Down Expand Up @@ -3098,7 +3098,7 @@ cpuinfo_walk_cpu(uintptr_t addr, const cpu_t *cpu, cpuinfo_data_t *cid)
const char *flags[] = {
"RUNNING", "READY", "QUIESCED", "EXISTS",
"ENABLE", "OFFLINE", "POWEROFF", "FROZEN",
"SPARE", "FAULTED", NULL
"SPARE", "FAULTED", "DISABLED", NULL
};

if (cid->cid_cpu != -1) {
Expand Down
10 changes: 7 additions & 3 deletions usr/src/cmd/picl/plugins/common/devtree/picldevtree.c
Expand Up @@ -24,7 +24,7 @@
*/

/*
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -1914,6 +1914,9 @@ get_pi_state(ptree_rarg_t *rarg, void *vbuf)
case P_POWEROFF:
(void) strlcpy(vbuf, PS_POWEROFF, MAX_STATE_SIZE);
break;
case P_DISABLED:
(void) strlcpy(vbuf, PS_DISABLED, MAX_STATE_SIZE);
break;
default:
(void) strlcpy(vbuf, "unknown", MAX_STATE_SIZE);
break;
Expand Down Expand Up @@ -2367,7 +2370,8 @@ process_devtree_conf_file(void)
static asr_conf_entries_t *conf_name_asr_map = NULL;

static void
free_asr_conf_entries(asr_conf_entries_t *list) {
free_asr_conf_entries(asr_conf_entries_t *list)
{
asr_conf_entries_t *el;
asr_conf_entries_t *del;

Expand Down Expand Up @@ -2606,7 +2610,7 @@ add_status_prop(picl_nodehdl_t chdh, char *status)

static void
create_asr_node(char *parent, char *child, char *unitaddr, char *class,
char *status, char *props)
char *status, char *props)
{
char ptreepath[PATH_MAX];
char nodename[PICL_PROPNAMELEN_MAX];
Expand Down
6 changes: 4 additions & 2 deletions usr/src/cmd/psradm/Makefile
Expand Up @@ -21,15 +21,17 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# cmd/psradm/Makefile
# Copyright 2019 Joyent, Inc.
#

PROG= psradm
PROG = psradm

include ../Makefile.cmd

.KEEP_STATE:

CSTD = $(CSTD_GNU99)

all: $(PROG)

install: all $(ROOTUSRSBINPROG)
Expand Down
43 changes: 38 additions & 5 deletions usr/src/cmd/psradm/psradm.c
Expand Up @@ -24,7 +24,9 @@
* Use is subject to license terms.
*/

#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright 2019 Joyent, Inc.
*/

#include <sys/types.h>
#include <sys/procset.h>
Expand All @@ -38,6 +40,7 @@
#include <time.h>
#include <utmpx.h>
#include <assert.h>
#include <stdbool.h>

static char *cmdname; /* command name for messages */

Expand All @@ -53,9 +56,11 @@ static char *basename(char *);
static void
usage(void)
{
(void) fprintf(stderr,
"usage: \n\t%s [-F] -f|-n|-i|-s [-v] processor_id ...\n"
"\t%s -a -f|-n|-i [-v]\n", cmdname, cmdname);
(void) fprintf(stderr, "usage:\n"
"\t%s [-F] -f|-n|-i|-s [-v] processor_id ...\n"
"\t%s -a -f|-n|-i [-v]\n"
"\t%s -aS [-v]\n",
cmdname, cmdname, cmdname);
}

/*
Expand Down Expand Up @@ -84,6 +89,7 @@ static psr_action_t psr_action[] = {
{ P_NOINTR, "no-intr", "set to", "ni" },
{ P_SPARE, "spare", "marked", "spr" },
{ P_FAULTED, "faulted", "marked", "flt" },
{ P_DISABLED, "disabled", "set as", "dis" },
};

static int psr_actions = sizeof (psr_action) / sizeof (psr_action_t);
Expand Down Expand Up @@ -218,10 +224,11 @@ main(int argc, char *argv[])
char *errptr;
int errors;
psr_action_t *pac;
bool disable_smt = 0;

cmdname = basename(argv[0]);

while ((c = getopt(argc, argv, "afFinsv")) != EOF) {
while ((c = getopt(argc, argv, "afFinsSv")) != EOF) {
switch (c) {

case 'a': /* applies to all possible CPUs */
Expand All @@ -232,6 +239,10 @@ main(int argc, char *argv[])
force = 1;
break;

case 'S':
disable_smt = 1;
break;

case 'f':
case 'i':
case 'n':
Expand All @@ -256,6 +267,28 @@ main(int argc, char *argv[])
}
}

if (disable_smt) {
if (!all_flag) {
fprintf(stderr, "%s: -S must be used with -a.\n",
cmdname);
usage();
return (2);
}

if (force || action != 0 || argc != optind) {
usage();
return (2);
}

if (p_online(P_ALL_SIBLINGS, P_DISABLED) == -1) {
fprintf(stderr, "Failed to disable simultaneous "
"multi-threading: %s\n", strerror(errno));
return (EXIT_FAILURE);
}

return (EXIT_SUCCESS);
}

switch (action) {
case 'f':
action = P_OFFLINE;
Expand Down

0 comments on commit c3377ee

Please sign in to comment.