summaryrefslogtreecommitdiff
path: root/usr/src/uts
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts')
-rw-r--r--usr/src/uts/common/fs/proc/prsubr.c2
-rw-r--r--usr/src/uts/common/os/lgrp.c14
-rw-r--r--usr/src/uts/common/sys/lgrp.h14
-rw-r--r--usr/src/uts/common/sys/procfs.h15
-rw-r--r--usr/src/uts/common/syscall/lgrpsys.c55
5 files changed, 51 insertions, 49 deletions
diff --git a/usr/src/uts/common/fs/proc/prsubr.c b/usr/src/uts/common/fs/proc/prsubr.c
index 2c26ee77f3..e1931414ec 100644
--- a/usr/src/uts/common/fs/proc/prsubr.c
+++ b/usr/src/uts/common/fs/proc/prsubr.c
@@ -2449,6 +2449,7 @@ prgetlwpsinfo(kthread_t *t, lwpsinfo_t *psp)
psp->pr_onpro = t->t_cpu->cpu_id;
psp->pr_bindpro = t->t_bind_cpu;
psp->pr_bindpset = t->t_bind_pset;
+ psp->pr_lgrp = t->t_lpl->lpl_lgrpid;
}
#ifdef _SYSCALL32_IMPL
@@ -2517,6 +2518,7 @@ prgetlwpsinfo32(kthread_t *t, lwpsinfo32_t *psp)
psp->pr_onpro = t->t_cpu->cpu_id;
psp->pr_bindpro = t->t_bind_cpu;
psp->pr_bindpset = t->t_bind_pset;
+ psp->pr_lgrp = t->t_lpl->lpl_lgrpid;
}
#endif /* _SYSCALL32_IMPL */
diff --git a/usr/src/uts/common/os/lgrp.c b/usr/src/uts/common/os/lgrp.c
index 3a2a6f0a17..315c0ac873 100644
--- a/usr/src/uts/common/os/lgrp.c
+++ b/usr/src/uts/common/os/lgrp.c
@@ -168,7 +168,6 @@ lpl_t *lpl_bootstrap;
static lgrp_t lroot;
-
/*
* Size, in bytes, beyond which random memory allocation policy is applied
* to non-shared memory. Default is the maximum size, so random memory
@@ -176,6 +175,12 @@ static lgrp_t lroot;
*/
size_t lgrp_privm_random_thresh = (size_t)(-1);
+/* the maximum effect that a single thread can have on it's lgroup's load */
+#define LGRP_LOADAVG_MAX_EFFECT(ncpu) \
+ ((lgrp_loadavg_max_effect) / (ncpu))
+uint32_t lgrp_loadavg_max_effect = LGRP_LOADAVG_THREAD_MAX;
+
+
/*
* Size, in bytes, beyond which random memory allocation policy is applied to
* shared memory. Default is 8MB (2 ISM pages).
@@ -1765,6 +1770,8 @@ lgrp_kstat_extract(kstat_t *ksp, int rw)
ksd[stat + LGRP_NUM_PG_FREE].value.i64 =
lgrp_mem_size(lgrpid, LGRP_MEM_SIZE_FREE);
ksd[stat + LGRP_LOADAVG].value.i64 = lgrp_sum_loadavgs(lgrp);
+ ksd[stat + LGRP_LOADAVG_SCALE].value.i64 =
+ lgrp_loadavg_max_effect;
} else {
lgrp_kstat_reset(lgrpid);
}
@@ -2945,11 +2952,6 @@ lpl_topo_bootstrap(lpl_t *target, int size)
bzero(lpl_bootstrap_list, sizeof (lpl_bootstrap_list));
}
-/* the maximum effect that a single thread can have on it's lgroup's load */
-#define LGRP_LOADAVG_MAX_EFFECT(ncpu) \
- ((lgrp_loadavg_max_effect) / (ncpu))
-uint32_t lgrp_loadavg_max_effect = LGRP_LOADAVG_THREAD_MAX;
-
/*
* If the lowest load among the lgroups a process' threads are currently
* spread across is greater than lgrp_expand_proc_thresh, we'll consider
diff --git a/usr/src/uts/common/sys/lgrp.h b/usr/src/uts/common/sys/lgrp.h
index d8f26f787c..840a2cb564 100644
--- a/usr/src/uts/common/sys/lgrp.h
+++ b/usr/src/uts/common/sys/lgrp.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -170,7 +170,8 @@ typedef enum lgrp_snap_stat_types {
LGRP_NUM_PG_FREE, /* # of free pages */
LGRP_NUM_PG_AVAIL, /* # of allocatable physical pages */
LGRP_NUM_PG_INSTALL, /* # of installed physical pages */
- LGRP_LOADAVG, /* "load average" of this lgrp */
+ LGRP_LOADAVG, /* unscaled load average of this lgrp */
+ LGRP_LOADAVG_SCALE, /* load unit of one CPU bound thread */
LGRP_NUM_SNAPSHOT_STATS /* always last */
} lgrp_snap_stat_t;
@@ -198,7 +199,8 @@ static char *lgrp_kstat_names[] = { \
"pages free", \
"pages avail", \
"pages installed", \
- "load average" \
+ "load average", \
+ "loadscale" \
}
#define LGRP_NUM_STATS ((int)LGRP_NUM_COUNTER_STATS + \
diff --git a/usr/src/uts/common/sys/procfs.h b/usr/src/uts/common/sys/procfs.h
index 995870f7fc..6f8e1a663d 100644
--- a/usr/src/uts/common/sys/procfs.h
+++ b/usr/src/uts/common/sys/procfs.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -61,6 +61,7 @@ extern "C" {
#include <sys/pset.h>
#include <sys/procfs_isa.h>
#include <sys/priv.h>
+#include <sys/lgrp.h>
#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
#error "Cannot use procfs in the large file compilation environment"
@@ -262,7 +263,8 @@ typedef struct lwpsinfo {
processorid_t pr_onpro; /* processor which last ran this lwp */
processorid_t pr_bindpro; /* processor to which lwp is bound */
psetid_t pr_bindpset; /* processor set to which lwp is bound */
- int pr_filler[5]; /* reserved for future use */
+ lgrp_id_t pr_lgrp; /* lwp home lgroup */
+ int pr_filler[4]; /* reserved for future use */
} lwpsinfo_t;
/*
@@ -633,7 +635,8 @@ typedef struct lwpsinfo32 {
processorid_t pr_onpro; /* processor which last ran this lwp */
processorid_t pr_bindpro; /* processor to which lwp is bound */
psetid_t pr_bindpset; /* processor set to which lwp is bound */
- int pr_filler[5]; /* reserved for future use */
+ lgrp_id_t pr_lgrp; /* lwp home lgroup */
+ int pr_filler[4]; /* reserved for future use */
} lwpsinfo32_t;
/*
diff --git a/usr/src/uts/common/syscall/lgrpsys.c b/usr/src/uts/common/syscall/lgrpsys.c
index 09b9818ad6..17fa2e1ff9 100644
--- a/usr/src/uts/common/syscall/lgrpsys.c
+++ b/usr/src/uts/common/syscall/lgrpsys.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -19,8 +18,9 @@
*
* CDDL HEADER END
*/
+
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -502,14 +502,13 @@ lgrp_affinity_best(kthread_t *t, struct cpupart *cpupart, lgrp_id_t start)
lgrpid = start;
/*
- * Begin with home as best lgroup if it's root or in this pset
- * Otherwise, use starting lgroup given above as best first.
+ * Use starting lgroup given above as best first
*/
home = t->t_lpl->lpl_lgrpid;
- if (LGRP_CPUS_IN_PART(home, cpupart))
- best_lpl = &cpupart->cp_lgrploads[home];
- else
+ if (LGRP_CPUS_IN_PART(lgrpid, cpupart))
best_lpl = &cpupart->cp_lgrploads[lgrpid];
+ else
+ best_lpl = &cpupart->cp_lgrploads[home];
best_aff = affs[best_lpl->lpl_lgrpid];
@@ -529,7 +528,7 @@ lgrp_affinity_best(kthread_t *t, struct cpupart *cpupart, lgrp_id_t start)
*/
lpl = &cpupart->cp_lgrploads[lgrpid];
if (affs[lgrpid] > best_aff) {
- best_aff = affs[lgrpid];
+ best_aff = affs[lgrpid];
best_lpl = lpl;
}
@@ -558,10 +557,11 @@ int
lgrp_affinity_set_thread(kthread_t *t, lgrp_id_t lgrp, lgrp_affinity_t aff,
lgrp_affinity_t **aff_buf)
{
+ lgrp_affinity_t *affs;
+ lgrp_id_t best;
lpl_t *best_lpl;
lgrp_id_t home;
int retval;
- lgrp_id_t start;
ASSERT(t != NULL);
ASSERT(MUTEX_HELD(&ttoproc(t)->p_lock));
@@ -589,33 +589,26 @@ lgrp_affinity_set_thread(kthread_t *t, lgrp_id_t lgrp, lgrp_affinity_t aff,
*aff_buf = NULL;
}
- t->t_lgrp_affinity[lgrp] = aff;
-
- /*
- * Select a new home if the thread's affinity is being cleared
- */
- if (aff == LGRP_AFF_NONE) {
- lgrp_move_thread(t, lgrp_choose(t, t->t_cpupart), 1);
- thread_unlock(t);
- return (retval);
- }
+ affs = t->t_lgrp_affinity;
+ affs[lgrp] = aff;
/*
* Find lgroup for which thread has most affinity,
- * starting after home
+ * starting with lgroup for which affinity being set
*/
- home = t->t_lpl->lpl_lgrpid;
- start = home + 1;
- if (start > lgrp_alloc_max)
- start = 0;
-
- best_lpl = lgrp_affinity_best(t, t->t_cpupart, start);
+ best_lpl = lgrp_affinity_best(t, t->t_cpupart, lgrp);
/*
- * Rehome if found lgroup with more affinity than home
+ * Rehome if found lgroup with more affinity than home or lgroup for
+ * which affinity is being set has same affinity as home
*/
- if (best_lpl != NULL && best_lpl != t->t_lpl)
- lgrp_move_thread(t, best_lpl, 1);
+ home = t->t_lpl->lpl_lgrpid;
+ if (best_lpl != NULL && best_lpl != t->t_lpl) {
+ best = best_lpl->lpl_lgrpid;
+ if (affs[best] > affs[home] || (affs[best] == affs[home] &&
+ best == lgrp))
+ lgrp_move_thread(t, best_lpl, 1);
+ }
thread_unlock(t);