NetBSD-Bugs archive

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

Re: kern/45634: hardclock_ticks corner cases in vflushnext() et al



The following reply was made to PR kern/45634; it has been noted by GNATS.

From: Christian Biere <christianbiere%gmx.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/45634: hardclock_ticks corner cases in vflushnext() et al
Date: Thu, 24 Nov 2011 22:29:25 +0100

 This is a multi-part message in MIME format.
 
 --Multipart=_Thu__24_Nov_2011_22_29_25_+0100_PqbLoL6DawYb392d
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 
 The following patch should fix a related issue in sys/kern/vfs_cache.c.
 
 --Multipart=_Thu__24_Nov_2011_22_29_25_+0100_PqbLoL6DawYb392d
 Content-Type: text/x-diff;
  name="vfs_cache.c.diff"
 Content-Disposition: attachment;
  filename="vfs_cache.c.diff"
 Content-Transfer-Encoding: 7bit
 
 --- vfs_cache.c.orig   2011-11-24 21:59:03.670963953 +0100
 +++ vfs_cache.c        2011-11-24 22:17:24.560964607 +0100
 @@ -133,7 +133,7 @@ static pool_cache_t namecache_cache;
  
  int cache_lowat = 95;
  int cache_hiwat = 98;
 -int cache_hottime = 5;                        /* number of seconds */
 +unsigned cache_hottime = 5;           /* number of seconds */
  int doingcache = 1;                   /* 1 => enable the cache */
  
  static struct evcnt cache_ev_scan;
 @@ -619,7 +619,7 @@ cache_enter(struct vnode *dvp, struct vn
        mutex_enter(&ncp->nc_lock);
        ncp->nc_vp = vp;
        ncp->nc_flags = 0;
 -      ncp->nc_hittime = 0;
 +      ncp->nc_hittime = hardclock_ticks;
        ncp->nc_gcqueue = NULL;
        if (vp == NULL) {
                /*
 @@ -874,13 +874,15 @@ static void
  cache_prune(int incache, int target)
  {
        struct namecache *ncp, *nxtcp, *sentinel;
 -      int items, recent, tryharder;
 +      int items, tryharder;
 +      unsigned now, hottime;
  
        KASSERT(mutex_owned(namecache_lock));
  
        items = 0;
        tryharder = 0;
 -      recent = hardclock_ticks - hz * cache_hottime;
 +      now = hardclock_ticks;
 +      hottime = cache_hottime * hz;
        sentinel = NULL;
        for (ncp = TAILQ_FIRST(&nclruhead); ncp != NULL; ncp = nxtcp) {
                if (incache <= target)
 @@ -896,7 +898,7 @@ cache_prune(int incache, int target)
                         */
                        tryharder = 1;
                }
 -              if (!tryharder && (ncp->nc_hittime - recent) > 0) {
 +              if (!tryharder && (now - ncp->nc_hittime) <= hottime) {
                        if (sentinel == NULL)
                                sentinel = ncp;
                        TAILQ_REMOVE(&nclruhead, ncp, nc_lru);
 
 --Multipart=_Thu__24_Nov_2011_22_29_25_+0100_PqbLoL6DawYb392d--
 


Home | Main Index | Thread Index | Old Index