tech-kern archive

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

Avoiding ci_cpuid in MI code



This is cosmetical only, but I think MI code should not use the ci_cpuid
member of struct cpu_info to display a cpu identification. Instead, ci_index
should be used.

What we have now might display (vmstat -e):

softint net/0                                     1        0 intr
softint bio/0                                   167        3 intr
softint clk/0                                   914       21 intr
softint ser/0                                    63        1 intr
[..]
softint net/2                                     1        0 intr
softint bio/2                                     1        0 intr
softint clk/2                                     1        0 intr
softint ser/2                                     1        0 intr

where "2" is the internal hardware identification of the second CPU -
probably something the user does not know about or is not interested in. This
ID is arbitrary, it could be something like 0x1000 for the first, and 0x2000
for the second cpu.

With the attached patch, the index of the cpu is used instead (i.e. cpu0 -> 0,
cpu1 -> 1).

softint net/0                                     1        0 intr
softint bio/0                                   167        3 intr
softint clk/0                                   914       21 intr
softint ser/0                                    63        1 intr
[..]
softint net/1                                     1        0 intr
softint bio/1                                     1        0 intr
softint clk/1                                     1        0 intr
softint ser/1                                     1        0 intr

This matches top(1) display and seems less confusing to me.

Comments?

Martin
Index: kern_cctr.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_cctr.c,v
retrieving revision 1.3
diff -c -u -r1.3 kern_cctr.c
--- kern_cctr.c 8 Nov 2007 20:10:26 -0000       1.3
+++ kern_cctr.c 2 Mar 2008 22:37:05 -0000
@@ -294,9 +294,9 @@
                factor = -factor;
 
        if (factor > old_factor / 10)
-               printf("cc_calibrate_cpu[%lu]: 10%% exceeded - delta %"
+               printf("cc_calibrate_cpu[%u]: 10%% exceeded - delta %"
                    PRId64 ", denom %" PRId64 ", factor %" PRId64
-                   ", old factor %" PRId64"\n", ci->ci_cpuid,
+                   ", old factor %" PRId64"\n", ci->ci_index,
                    delta, denom, (delta * 1000) / denom, old_factor);
 #endif /* TIMECOUNTER_DEBUG */
 }
Index: kern_idle.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_idle.c,v
retrieving revision 1.11
diff -c -u -r1.11 kern_idle.c
--- kern_idle.c 14 Feb 2008 14:26:57 -0000      1.11
+++ kern_idle.c 2 Mar 2008 22:37:05 -0000
@@ -92,7 +92,7 @@
 
        KASSERT(ci->ci_data.cpu_idlelwp == NULL);
        error = kthread_create(PRI_IDLE, KTHREAD_MPSAFE | KTHREAD_IDLE,
-           ci, idle_loop, NULL, &l, "idle/%d", (int)ci->ci_cpuid);
+           ci, idle_loop, NULL, &l, "idle/%u", ci->ci_index);
        if (error != 0)
                panic("create_idle_lwp: error %d", error);
        lwp_lock(l);
Index: kern_softint.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_softint.c,v
retrieving revision 1.11
diff -c -u -r1.11 kern_softint.c
--- kern_softint.c      6 Feb 2008 15:34:36 -0000       1.11
+++ kern_softint.c      2 Mar 2008 22:37:05 -0000
@@ -254,16 +254,16 @@
 
        error = kthread_create(pri, KTHREAD_MPSAFE | KTHREAD_INTR |
            KTHREAD_IDLE, ci, softint_thread, si, &si->si_lwp,
-           "soft%s/%d", desc, (int)ci->ci_cpuid);
+           "soft%s/%u", desc, ci->ci_index);
        if (error != 0)
                panic("softint_init_isr: error %d", error);
 
-       snprintf(si->si_name, sizeof(si->si_name), "%s/%d", desc,
-           (int)ci->ci_cpuid);
+       snprintf(si->si_name, sizeof(si->si_name), "%s/%u", desc,
+           ci->ci_index);
        evcnt_attach_dynamic(&si->si_evcnt, EVCNT_TYPE_INTR, NULL,
           "softint", si->si_name);
-       snprintf(si->si_name_block, sizeof(si->si_name_block), "%s block/%d",
-           desc, (int)ci->ci_cpuid);
+       snprintf(si->si_name_block, sizeof(si->si_name_block), "%s block/%u",
+           desc, ci->ci_index);
        evcnt_attach_dynamic(&si->si_evcnt_block, EVCNT_TYPE_INTR, NULL,
           "softint", si->si_name_block);
 
Index: sched_m2.c
===================================================================
RCS file: /cvsroot/src/sys/kern/sched_m2.c,v
retrieving revision 1.20
diff -c -u -r1.20 sched_m2.c
--- sched_m2.c  14 Feb 2008 14:26:57 -0000      1.20
+++ sched_m2.c  2 Mar 2008 22:37:06 -0000
@@ -1045,7 +1045,7 @@
        for (CPU_INFO_FOREACH(cii, ci)) {
                ci_rq = ci->ci_schedstate.spc_sched_info;
 
-               (*pr)("Run-queue (CPU = %d):\n", ci->ci_cpuid);
+               (*pr)("Run-queue (CPU = %u):\n", ci->ci_index);
                (*pr)(" pid.lid = %d.%d, threads count = %u, "
                    "avgcount = %u, highest pri = %d\n",
                    ci->ci_curlwp->l_proc->p_pid, ci->ci_curlwp->l_lid,
@@ -1066,12 +1066,12 @@
                LIST_FOREACH(l, &p->p_lwps, l_sibling) {
                        sil = l->l_sched_info;
                        ci = l->l_cpu;
-                       (*pr)(" | %5d %4u %4u 0x%8.8x %3s %4u %11p %3d "
+                       (*pr)(" | %5d %4u %4u 0x%8.8x %3s %4u %11p %3u "
                            "%u ST=%d RT=%d %d\n",
                            (int)l->l_lid, l->l_priority, lwp_eprio(l),
                            l->l_flag, l->l_stat == LSRUN ? "RQ" :
                            (l->l_stat == LSSLEEP ? "SQ" : "-"),
-                           sil->sl_timeslice, l, ci->ci_cpuid,
+                           sil->sl_timeslice, l, ci->ci_index,
                            (u_int)(hardclock_ticks - sil->sl_lrtime),
                            sil->sl_slpsum, sil->sl_rtsum, sil->sl_flags);
                }
Index: subr_pool.c
===================================================================
RCS file: /cvsroot/src/sys/kern/subr_pool.c,v
retrieving revision 1.152
diff -c -u -r1.152 subr_pool.c
--- subr_pool.c 2 Mar 2008 12:19:58 -0000       1.152
+++ subr_pool.c 2 Mar 2008 22:37:06 -0000
@@ -3062,7 +3062,7 @@
                                        snprintf(cpucachestr,
                                            sizeof(cpucachestr),
                                            "cached by CPU %u",
-                                           (u_int)ci->ci_cpuid);
+                                           ci->ci_index);
                                        goto print;
                                }
                        }
Index: subr_workqueue.c
===================================================================
RCS file: /cvsroot/src/sys/kern/subr_workqueue.c,v
retrieving revision 1.22
diff -c -u -r1.22 subr_workqueue.c
--- subr_workqueue.c    5 Dec 2007 07:06:54 -0000       1.22
+++ subr_workqueue.c    2 Mar 2008 22:37:06 -0000
@@ -168,7 +168,7 @@
        ktf = ((wq->wq_flags & WQ_MPSAFE) != 0 ? KTHREAD_MPSAFE : 0);
        if (ci) {
                error = kthread_create(wq->wq_prio, ktf, ci, workqueue_worker,
-                   wq, &q->q_worker, "%s/%u", wq->wq_name, 
(u_int)ci->ci_cpuid);
+                   wq, &q->q_worker, "%s/%u", wq->wq_name, ci->ci_index);
        } else {
                error = kthread_create(wq->wq_prio, ktf, ci, workqueue_worker,
                    wq, &q->q_worker, "%s", wq->wq_name);
Index: subr_xcall.c
===================================================================
RCS file: /cvsroot/src/sys/kern/subr_xcall.c,v
retrieving revision 1.5
diff -c -u -r1.5 subr_xcall.c
--- subr_xcall.c        6 Nov 2007 00:42:44 -0000       1.5
+++ subr_xcall.c        2 Mar 2008 22:37:06 -0000
@@ -131,7 +131,7 @@
 
        cv_init(&ci->ci_data.cpu_xcall, "xcall");
        error = kthread_create(PRI_XCALL, KTHREAD_MPSAFE, ci, xc_thread,
-           NULL, NULL, "xcall/%d", (int)ci->ci_cpuid);
+           NULL, NULL, "xcall/%u", ci->ci_index);
        if (error != 0)
                panic("xc_init_cpu: error %d", error);
 }


Home | Main Index | Thread Index | Old Index