From owner-freebsd-bugs@FreeBSD.ORG Fri Sep 2 18:00:41 2005 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E24CA16A441 for ; Fri, 2 Sep 2005 18:00:40 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6EE6143D67 for ; Fri, 2 Sep 2005 18:00:38 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j82I0bcZ055290 for ; Fri, 2 Sep 2005 18:00:37 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j82I0bio055289; Fri, 2 Sep 2005 18:00:37 GMT (envelope-from gnats) Resent-Date: Fri, 2 Sep 2005 18:00:37 GMT Resent-Message-Id: <200509021800.j82I0bio055289@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Ben Thomas Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9694416A41F for ; Fri, 2 Sep 2005 18:00:05 +0000 (GMT) (envelope-from bthomas@virtualiron.com) Received: from mail.virtualiron.com (mail.virtualiron.com [209.213.88.114]) by mx1.FreeBSD.org (Postfix) with ESMTP id 37CFD43D49 for ; Fri, 2 Sep 2005 18:00:05 +0000 (GMT) (envelope-from bthomas@virtualiron.com) Received: from [10.1.2.26] ([10.1.2.26]) by mail.virtualiron.com with Microsoft SMTPSVC(6.0.3790.1830); Fri, 2 Sep 2005 14:00:41 -0400 Message-Id: <43189324.5090804@virtualiron.com> Date: Fri, 02 Sep 2005 14:00:04 -0400 From: Ben Thomas To: FreeBSD-gnats-submit@FreeBSD.org Cc: Subject: kern/85657: [patch] capture and expose per-CPU time accounting X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2005 18:00:41 -0000 >Number: 85657 >Category: kern >Synopsis: [patch] capture and expose per-CPU time accounting >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Sep 02 18:00:37 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Ben Thomas >Release: FreeBSD 5.4-RELEASE i386 >Organization: Virtual Iron Software >Environment: System: FreeBSD bthomas4.katana-technology.com 5.4-RELEASE FreeBSD 5.4-RELEASE #10: Sun Aug 28 13:48:00 EDT 2005 ben@bthomas4.katana-technology.com:/usr/obj/usr/home/ben/BSD/RELENG_5_4_0_RELEASE/src/sys/BEN i386 >Description: The kernel maintains time accounting information on a global basis and exposes it via kern.cp_time. There are situations in which the per-CPU information is useful. Add this accounting and expose it via kern.cp_time_percpu. This patch is against 5_4_0_RELEASE code >How-To-Repeat: >Fix: --- kern_clock.c-DIFF begins here --- --- /usr/src.original/sys/kern/kern_clock.c Tue Mar 1 04:30:16 2005 +++ /usr/src/sys/kern/kern_clock.c Sun Aug 28 13:29:56 2005 @@ -82,6 +82,11 @@ SYSCTL_OPAQUE(_kern, OID_AUTO, cp_time, CTLFLAG_RD, &cp_time, sizeof(cp_time), "LU", "CPU time statistics"); +long cp_time_percpu[MAXCPU][CPUSTATES]; + +SYSCTL_OPAQUE(_kern, OID_AUTO, cp_time_percpu, CTLFLAG_RD, &cp_time_percpu, sizeof(cp_time_percpu), + "LU", "CPU time statistics per CPU"); + #ifdef SW_WATCHDOG #include @@ -375,6 +380,7 @@ struct thread *td; struct proc *p; long rss; + int cpu = PCPU_GET(cpuid); td = curthread; p = td->td_proc; @@ -387,10 +393,13 @@ if (p->p_flag & P_SA) thread_statclock(1); p->p_uticks++; - if (p->p_nice > NZERO) + if (p->p_nice > NZERO) { cp_time[CP_NICE]++; - else + cp_time_percpu[cpu][CP_NICE]++; + } else { cp_time[CP_USER]++; + cp_time_percpu[cpu][CP_USER]++; + } } else { /* * Came from kernel mode, so we were: @@ -407,15 +416,19 @@ if ((td->td_ithd != NULL) || td->td_intr_nesting_level >= 2) { p->p_iticks++; cp_time[CP_INTR]++; + cp_time_percpu[cpu][CP_INTR]++; } else { if (p->p_flag & P_SA) thread_statclock(0); td->td_sticks++; p->p_sticks++; - if (p != PCPU_GET(idlethread)->td_proc) + if (p != PCPU_GET(idlethread)->td_proc) { cp_time[CP_SYS]++; - else + cp_time_percpu[cpu][CP_SYS]++; + } else { cp_time[CP_IDLE]++; + cp_time_percpu[cpu][CP_IDLE]++; + } } } CTR4(KTR_SCHED, "statclock: %p(%s) prio %d stathz %d", --- kern_clock.c-DIFF ends here --- >Release-Note: >Audit-Trail: >Unformatted: