Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Feb 2001 16:01:40 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        John Baldwin <jhb@FreeBSD.org>
Cc:        Tor Egge <tegge@FreeBSD.org>, cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org
Subject:   RE: cvs commit: src/sys/kern kern_exit.c kern_resource.c
Message-ID:  <Pine.BSF.4.21.0102241531510.26336-100000@besplex.bde.org>
In-Reply-To: <XFMail.010222120536.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0102241531510.26336-100000>