Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/powerpc Don't waste space on likely unused sysmon s...



details:   https://anonhg.NetBSD.org/src/rev/7d4007970e33
branches:  trunk
changeset: 558581:7d4007970e33
user:      matt <matt%NetBSD.org@localhost>
date:      Tue Feb 17 22:03:52 2004 +0000

description:
Don't waste space on likely unused sysmon structure.
Instead malloc them as needed.

diffstat:

 sys/arch/powerpc/include/cpu.h  |   6 +---
 sys/arch/powerpc/oea/cpu_subr.c |  52 ++++++++++++++++++++--------------------
 2 files changed, 28 insertions(+), 30 deletions(-)

diffs (133 lines):

diff -r f7866b558fb5 -r 7d4007970e33 sys/arch/powerpc/include/cpu.h
--- a/sys/arch/powerpc/include/cpu.h    Tue Feb 17 21:20:55 2004 +0000
+++ b/sys/arch/powerpc/include/cpu.h    Tue Feb 17 22:03:52 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.39 2004/01/04 11:33:30 jdolecek Exp $        */
+/*     $NetBSD: cpu.h,v 1.40 2004/02/17 22:03:52 matt Exp $    */
 
 /*
  * Copyright (C) 1999 Wolfgang Solfrank.
@@ -55,7 +55,6 @@
 #include <sys/device.h>
 
 #include <sys/sched.h>
-#include <dev/sysmon/sysmonvar.h>
 
 struct cpu_info {
        struct schedstate_percpu ci_schedstate; /* scheduler state */
@@ -93,8 +92,7 @@
 #define        DISISAVE_LEN    4
        register_t ci_disisave[DISISAVE_LEN];
        struct cache_info ci_ci;                
-       struct sysmon_envsys ci_sysmon;
-       struct envsys_tre_data ci_tau_info;
+       void *ci_sysmon_cookie;
        struct evcnt ci_ev_clock;       /* clock intrs */
        struct evcnt ci_ev_softclock;   /* softclock intrs */
        struct evcnt ci_ev_softnet;     /* softnet intrs */
diff -r f7866b558fb5 -r 7d4007970e33 sys/arch/powerpc/oea/cpu_subr.c
--- a/sys/arch/powerpc/oea/cpu_subr.c   Tue Feb 17 21:20:55 2004 +0000
+++ b/sys/arch/powerpc/oea/cpu_subr.c   Tue Feb 17 22:03:52 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_subr.c,v 1.11 2003/10/09 20:49:06 matt Exp $       */
+/*     $NetBSD: cpu_subr.c,v 1.12 2004/02/17 22:03:52 matt Exp $       */
 
 /*-
  * Copyright (c) 2001 Matt Thomas.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.11 2003/10/09 20:49:06 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_subr.c,v 1.12 2004/02/17 22:03:52 matt Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -44,6 +44,7 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
+#include <sys/malloc.h>
 
 #include <uvm/uvm_extern.h>
 
@@ -767,24 +768,29 @@
 void
 cpu_tau_setup(struct cpu_info *ci)
 {
-       struct sysmon_envsys *sme;
+       struct {
+               struct sysmon_envsys sme;
+               struct envsys_tre_data tau_info;
+       } *datap;
        int error;
 
-       sme = &ci->ci_sysmon;
-       sme->sme_nsensors = 1;
-       sme->sme_envsys_version = 1000;
-       sme->sme_ranges = cpu_tau_ranges;
-       sme->sme_sensor_info = cpu_tau_info;
-       sme->sme_sensor_data = &ci->ci_tau_info;
+       datap = malloc(sizeof(*datap), M_DEVBUF, M_WAITOK);
+
+       ci->ci_sysmon_cookie = &datap->sme;
+       datap->sme.sme_nsensors = 1;
+       datap->sme.sme_envsys_version = 1000;
+       datap->sme.sme_ranges = cpu_tau_ranges;
+       datap->sme.sme_sensor_info = cpu_tau_info;
+       datap->sme.sme_sensor_data = &datap->tau_info;
        
-       sme->sme_sensor_data->sensor = 0;
-       sme->sme_sensor_data->warnflags = ENVSYS_WARN_OK;
-       sme->sme_sensor_data->validflags = ENVSYS_FVALID|ENVSYS_FCURVALID;
-       sme->sme_cookie = ci;
-       sme->sme_gtredata = cpu_tau_gtredata;
-       sme->sme_streinfo = cpu_tau_streinfo;
+       datap->sme.sme_sensor_data->sensor = 0;
+       datap->sme.sme_sensor_data->warnflags = ENVSYS_WARN_OK;
+       datap->sme.sme_sensor_data->validflags = ENVSYS_FVALID|ENVSYS_FCURVALID;
+       datap->sme.sme_cookie = ci;
+       datap->sme.sme_gtredata = cpu_tau_gtredata;
+       datap->sme.sme_streinfo = cpu_tau_streinfo;
 
-       if ((error = sysmon_envsys_register(sme)) != 0)
+       if ((error = sysmon_envsys_register(&datap->sme)) != 0)
                aprint_error("%s: unable to register with sysmon (%d)\n",
                    ci->ci_dev->dv_xname, error);
 }
@@ -792,11 +798,8 @@
 
 /* Find the temperature of the CPU. */
 int
-cpu_tau_gtredata(sme, tred)
-        struct sysmon_envsys *sme;
-        struct envsys_tre_data *tred;
+cpu_tau_gtredata(struct sysmon_envsys *sme, struct envsys_tre_data *tred)
 {
-       struct cpu_info *ci;
        int i, threshold, count;
 
        if (tred->sensor != 0) {
@@ -841,19 +844,16 @@
        }
        threshold += 2;
 
-       ci = (struct cpu_info *)sme->sme_cookie;
        /* Convert the temperature in degrees C to microkelvin */
-       ci->ci_tau_info.cur.data_us = (threshold * 1000000) + 273150000;
+       sme->sme_sensor_data->cur.data_us = (threshold * 1000000) + 273150000;
        
-       *tred = ci->ci_tau_info;
+       *tred = *sme->sme_sensor_data;
 
        return 0;
 }
 
 int
-cpu_tau_streinfo(sme, binfo)
-        struct sysmon_envsys *sme;
-        struct envsys_basic_info *binfo;
+cpu_tau_streinfo(struct sysmon_envsys *sme, struct envsys_basic_info *binfo)
 {
 
        /* There is nothing to set here. */



Home | Main Index | Thread Index | Old Index