summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/os/cpu.c
diff options
context:
space:
mode:
authormh27603 <none@none>2007-08-16 16:52:20 -0700
committermh27603 <none@none>2007-08-16 16:52:20 -0700
commit68afbec1fabe0d352bb5ab4ed82c44b58ec651fb (patch)
tree32317f52d74b2c7615c7cb023fc46bc7c5d40998 /usr/src/uts/common/os/cpu.c
parent8d483882aa3390058094b043f3d62187b5d1de03 (diff)
downloadillumos-joyent-68afbec1fabe0d352bb5ab4ed82c44b58ec651fb.tar.gz
6587576 cpu_info kstat is returning garbage in supported_frequencies_Hz
Diffstat (limited to 'usr/src/uts/common/os/cpu.c')
-rw-r--r--usr/src/uts/common/os/cpu.c54
1 files changed, 45 insertions, 9 deletions
diff --git a/usr/src/uts/common/os/cpu.c b/usr/src/uts/common/os/cpu.c
index 6a36b662e0..1eaeb22d02 100644
--- a/usr/src/uts/common/os/cpu.c
+++ b/usr/src/uts/common/os/cpu.c
@@ -2163,15 +2163,8 @@ cpu_info_kstat_update(kstat_t *ksp, int rw)
cpu_info_template.ci_core_id.value.l = pg_plat_get_core_id(cp);
cpu_info_template.ci_curr_clock_Hz.value.ui64 =
cp->cpu_curr_clock;
- if (cp->cpu_supp_freqs == NULL) {
- char clkstr[sizeof ("18446744073709551615") + 1]; /* ui64 MAX */
- (void) snprintf(clkstr, sizeof (clkstr), "%"PRIu64,
- cpu_info_template.ci_curr_clock_Hz.value.ui64);
- kstat_named_setstr(&cpu_info_template.ci_supp_freq_Hz, clkstr);
- } else {
- kstat_named_setstr(&cpu_info_template.ci_supp_freq_Hz,
- cp->cpu_supp_freqs);
- }
+ kstat_named_setstr(&cpu_info_template.ci_supp_freq_Hz,
+ cp->cpu_supp_freqs);
#if defined(__sparcv9)
cpu_info_template.ci_device_ID.value.ui64 =
cpunodes[cp->cpu_id].device_id;
@@ -2784,6 +2777,49 @@ cpu_destroy_bound_threads(cpu_t *cp)
}
/*
+ * Update the cpu_supp_freqs of this cpu. This information is returned
+ * as part of cpu_info kstats.
+ */
+void
+cpu_set_supp_freqs(cpu_t *cp, const char *freqs)
+{
+ char clkstr[sizeof ("18446744073709551615") + 1]; /* ui64 MAX */
+ const char *lfreqs = clkstr;
+
+ /*
+ * A NULL pointer means we only support one speed.
+ */
+ if (freqs == NULL)
+ (void) snprintf(clkstr, sizeof (clkstr), "%"PRIu64,
+ cp->cpu_curr_clock);
+ else
+ lfreqs = freqs;
+
+ /*
+ * Make sure the frequency doesn't change while a snapshot is
+ * going on.
+ */
+ mutex_enter(cp->cpu_info_kstat->ks_lock);
+
+ /*
+ * Free any previously allocated string.
+ */
+ if (cp->cpu_supp_freqs != NULL)
+ kmem_free(cp->cpu_supp_freqs, strlen(cp->cpu_supp_freqs) + 1);
+
+ /*
+ * Allocate the new string and set the pointer.
+ */
+ cp->cpu_supp_freqs = kmem_alloc(strlen(lfreqs) + 1, KM_SLEEP);
+ (void) strcpy(cp->cpu_supp_freqs, lfreqs);
+
+ /*
+ * kstat is free to take a snapshot once again.
+ */
+ mutex_exit(cp->cpu_info_kstat->ks_lock);
+}
+
+/*
* processor_info(2) and p_online(2) status support functions
* The constants returned by the cpu_get_state() and cpu_get_state_str() are
* for use in communicating processor state information to userland. Kernel