From owner-cvs-all Fri Feb 23 21:10:52 2001 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 2DF6C37B503; Fri, 23 Feb 2001 21:10:45 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id QAA31228; Sat, 24 Feb 2001 16:10:41 +1100 Date: Sat, 24 Feb 2001 16:01:40 +1100 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: John Baldwin Cc: Tor Egge , cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org Subject: RE: cvs commit: src/sys/kern kern_exit.c kern_resource.c In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 22 Feb 2001, John Baldwin wrote: > On 22-Feb-01 Tor Egge wrote: > > tegge 2001/02/22 11:50:37 PST > > > > Modified files: > > sys/kern kern_exit.c kern_resource.c > > Log: > > Protect update of the per processor switchtime variable against > > interrupts. > > Why not do this instead: > > mtx_lock_spin(&sched_lock); > microuptime(PCPU_PTR(switchtime)); > PCPU_SET(switchticks, ticks); > mtx_unlock_spin(&sched_lock); This seems to be sub-optimal too. The new switchtime should be set as soon as possible after after reading the old one in calcru(), but we do extra work to open a window for interrupts. Fix (except for adjustments to comments) relative to version that does this: Index: kern_exit.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_exit.c,v retrieving revision 1.120 diff -c -2 -r1.120 kern_exit.c *** kern_exit.c 2001/02/22 20:16:51 1.120 --- kern_exit.c 2001/02/24 04:41:16 *************** *** 317,321 **** mtx_lock_spin(&sched_lock); calcru(p, &p->p_ru->ru_utime, &p->p_ru->ru_stime, NULL); - mtx_unlock_spin(&sched_lock); ruadd(p->p_ru, &p->p_stats->p_cru); --- 316,319 ---- *************** *** 326,330 **** * counted somewhere if possible. */ - mtx_lock_spin(&sched_lock); microuptime(PCPU_PTR(switchtime)); PCPU_SET(switchticks, ticks); --- 324,327 ---- Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message