[BACK]Return to subr_pool.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / kern

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/kern/subr_pool.c between version 1.131.2.4 and 1.137.2.5

version 1.131.2.4, 2008/03/23 02:05:00 version 1.137.2.5, 2007/12/26 21:39:42
Line 1 
Line 1 
 /*      subr_pool.c,v 1.131.2.3 2008/01/09 01:56:18 matt Exp    */  /*      $NetBSD$        */
   
 /*-  /*-
  * Copyright (c) 1997, 1999, 2000, 2002, 2007 The NetBSD Foundation, Inc.   * Copyright (c) 1997, 1999, 2000, 2002, 2007 The NetBSD Foundation, Inc.
Line 38 
Line 38 
  */   */
   
 #include <sys/cdefs.h>  #include <sys/cdefs.h>
 __KERNEL_RCSID(0, "subr_pool.c,v 1.131.2.3 2008/01/09 01:56:18 matt Exp");  __KERNEL_RCSID(0, "$NetBSD$");
   
 #include "opt_ddb.h"  #include "opt_ddb.h"
 #include "opt_pool.h"  #include "opt_pool.h"
Line 52  __KERNEL_RCSID(0, "subr_pool.c,v 1.131.2
Line 52  __KERNEL_RCSID(0, "subr_pool.c,v 1.131.2
 #include <sys/errno.h>  #include <sys/errno.h>
 #include <sys/kernel.h>  #include <sys/kernel.h>
 #include <sys/malloc.h>  #include <sys/malloc.h>
   #include <sys/lock.h>
 #include <sys/pool.h>  #include <sys/pool.h>
 #include <sys/syslog.h>  #include <sys/syslog.h>
 #include <sys/debug.h>  #include <sys/debug.h>
Line 122  struct pool_item_header {
Line 123  struct pool_item_header {
         SPLAY_ENTRY(pool_item_header)          SPLAY_ENTRY(pool_item_header)
                                 ph_node;        /* Off-page page headers */                                  ph_node;        /* Off-page page headers */
         void *                  ph_page;        /* this page's address */          void *                  ph_page;        /* this page's address */
         uint32_t                ph_time;        /* last referenced */          struct timeval          ph_time;        /* last referenced */
         uint16_t                ph_nmissing;    /* # of chunks in use */          uint16_t                ph_nmissing;    /* # of chunks in use */
         uint16_t                ph_off;         /* start offset in page */          uint16_t                ph_off;         /* start offset in page */
         union {          union {
Line 995  pool_get(struct pool *pp, int flags)
Line 996  pool_get(struct pool *pp, int flags)
   
 #endif /* DIAGNOSTIC */  #endif /* DIAGNOSTIC */
 #ifdef LOCKDEBUG  #ifdef LOCKDEBUG
         if (flags & PR_WAITOK) {          if (flags & PR_WAITOK)
                 ASSERT_SLEEPABLE();                  ASSERT_SLEEPABLE(NULL, "pool_get(PR_WAITOK)");
         }  
 #endif  #endif
   
         mutex_enter(&pp->pr_lock);          mutex_enter(&pp->pr_lock);
Line 1289  pool_do_put(struct pool *pp, void *v, st
Line 1289  pool_do_put(struct pool *pp, void *v, st
         if (ph->ph_nmissing == 0) {          if (ph->ph_nmissing == 0) {
                 pp->pr_nidle++;                  pp->pr_nidle++;
                 if (pp->pr_npages > pp->pr_minpages &&                  if (pp->pr_npages > pp->pr_minpages &&
                     pp->pr_npages > pp->pr_maxpages) {                      (pp->pr_npages > pp->pr_maxpages ||
                        pa_starved_p(pp->pr_alloc))) {
                         pr_rmpage(pp, ph, pq);                          pr_rmpage(pp, ph, pq);
                 } else {                  } else {
                         LIST_REMOVE(ph, ph_pagelist);                          LIST_REMOVE(ph, ph_pagelist);
Line 1300  pool_do_put(struct pool *pp, void *v, st
Line 1301  pool_do_put(struct pool *pp, void *v, st
                          * be idle for some period of time before it can                           * be idle for some period of time before it can
                          * be reclaimed by the pagedaemon.  This minimizes                           * be reclaimed by the pagedaemon.  This minimizes
                          * ping-pong'ing for memory.                           * ping-pong'ing for memory.
                          *  
                          * note for 64-bit time_t: truncating to 32-bit is not  
                          * a problem for our usage.  
                          */                           */
                         ph->ph_time = time_uptime;                          getmicrotime(&ph->ph_time);
                 }                  }
                 pool_update_curpage(pp);                  pool_update_curpage(pp);
         }          }
Line 1456  pool_prime_page(struct pool *pp, void *s
Line 1454  pool_prime_page(struct pool *pp, void *s
         LIST_INIT(&ph->ph_itemlist);          LIST_INIT(&ph->ph_itemlist);
         ph->ph_page = storage;          ph->ph_page = storage;
         ph->ph_nmissing = 0;          ph->ph_nmissing = 0;
         ph->ph_time = time_uptime;          getmicrotime(&ph->ph_time);
         if ((pp->pr_roflags & PR_PHINPAGE) == 0)          if ((pp->pr_roflags & PR_PHINPAGE) == 0)
                 SPLAY_INSERT(phtree, &pp->pr_phtree, ph);                  SPLAY_INSERT(phtree, &pp->pr_phtree, ph);
   
Line 1617  pool_reclaim(struct pool *pp)
Line 1615  pool_reclaim(struct pool *pp)
 {  {
         struct pool_item_header *ph, *phnext;          struct pool_item_header *ph, *phnext;
         struct pool_pagelist pq;          struct pool_pagelist pq;
         uint32_t curtime;          struct timeval curtime, diff;
         bool klock;          bool klock;
         int rv;          int rv;
   
Line 1654  pool_reclaim(struct pool *pp)
Line 1652  pool_reclaim(struct pool *pp)
   
         LIST_INIT(&pq);          LIST_INIT(&pq);
   
         curtime = time_uptime;          getmicrotime(&curtime);
   
         for (ph = LIST_FIRST(&pp->pr_emptypages); ph != NULL; ph = phnext) {          for (ph = LIST_FIRST(&pp->pr_emptypages); ph != NULL; ph = phnext) {
                 phnext = LIST_NEXT(ph, ph_pagelist);                  phnext = LIST_NEXT(ph, ph_pagelist);
Line 1664  pool_reclaim(struct pool *pp)
Line 1662  pool_reclaim(struct pool *pp)
                         break;                          break;
   
                 KASSERT(ph->ph_nmissing == 0);                  KASSERT(ph->ph_nmissing == 0);
                 if (curtime - ph->ph_time < pool_inactive_time                  timersub(&curtime, &ph->ph_time, &diff);
                   if (diff.tv_sec < pool_inactive_time
                     && !pa_starved_p(pp->pr_alloc))                      && !pa_starved_p(pp->pr_alloc))
                         continue;                          continue;
   
Line 1805  pool_print_pagelist(struct pool *pp, str
Line 1804  pool_print_pagelist(struct pool *pp, str
 #endif  #endif
   
         LIST_FOREACH(ph, pl, ph_pagelist) {          LIST_FOREACH(ph, pl, ph_pagelist) {
                 (*pr)("\t\tpage %p, nmissing %d, time %" PRIu32 "\n",                  (*pr)("\t\tpage %p, nmissing %d, time %lu,%lu\n",
                     ph->ph_page, ph->ph_nmissing, ph->ph_time);                      ph->ph_page, ph->ph_nmissing,
                       (u_long)ph->ph_time.tv_sec,
                       (u_long)ph->ph_time.tv_usec);
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
                 if (!(pp->pr_roflags & PR_NOTOUCH)) {                  if (!(pp->pr_roflags & PR_NOTOUCH)) {
                         LIST_FOREACH(pi, &ph->ph_itemlist, pi_list) {                          LIST_FOREACH(pi, &ph->ph_itemlist, pi_list) {
Line 2522  pool_cache_get_paddr(pool_cache_t pc, in
Line 2523  pool_cache_get_paddr(pool_cache_t pc, in
         int s;          int s;
   
 #ifdef LOCKDEBUG  #ifdef LOCKDEBUG
         if (flags & PR_WAITOK) {          if (flags & PR_WAITOK)
                 ASSERT_SLEEPABLE();                  ASSERT_SLEEPABLE(NULL, "pool_cache_get(PR_WAITOK)");
         }  
 #endif  #endif
   
         cc = pool_cache_cpu_enter(pc, &s);          cc = pool_cache_cpu_enter(pc, &s);
Line 2535  pool_cache_get_paddr(pool_cache_t pc, in
Line 2535  pool_cache_get_paddr(pool_cache_t pc, in
                         object = pcg->pcg_objects[--pcg->pcg_avail].pcgo_va;                          object = pcg->pcg_objects[--pcg->pcg_avail].pcgo_va;
                         if (pap != NULL)                          if (pap != NULL)
                                 *pap = pcg->pcg_objects[pcg->pcg_avail].pcgo_pa;                                  *pap = pcg->pcg_objects[pcg->pcg_avail].pcgo_pa;
 #if defined(DIAGNOSTIC)  
                         pcg->pcg_objects[pcg->pcg_avail].pcgo_va = NULL;                          pcg->pcg_objects[pcg->pcg_avail].pcgo_va = NULL;
 #endif /* defined(DIAGNOSTIC) */  
                         KASSERT(pcg->pcg_avail <= pcg->pcg_size);                          KASSERT(pcg->pcg_avail <= pcg->pcg_size);
                         KASSERT(object != NULL);                          KASSERT(object != NULL);
                         cc->cc_hits++;                          cc->cc_hits++;
Line 2608  pool_cache_put_slow(pool_cache_cpu_t *cc
Line 2606  pool_cache_put_slow(pool_cache_cpu_t *cc
                 /*                  /*
                  * If there's a empty group, release our full                   * If there's a empty group, release our full
                  * group back to the cache.  Install the empty                   * group back to the cache.  Install the empty
                  * group and return.                   * group as cc_current and return.
                  */                   */
                   if ((cur = cc->cc_current) != NULL) {
                           KASSERT(cur->pcg_avail == pcg->pcg_size);
                           cur->pcg_next = pc->pc_fullgroups;
                           pc->pc_fullgroups = cur;
                           pc->pc_nfull++;
                   }
                 KASSERT(pcg->pcg_avail == 0);                  KASSERT(pcg->pcg_avail == 0);
                   cc->cc_current = pcg;
                 pc->pc_emptygroups = pcg->pcg_next;                  pc->pc_emptygroups = pcg->pcg_next;
                 if (cc->cc_previous == NULL) {  
                         cc->cc_previous = pcg;  
                 } else {  
                         if ((cur = cc->cc_current) != NULL) {  
                                 KASSERT(cur->pcg_avail == pcg->pcg_size);  
                                 cur->pcg_next = pc->pc_fullgroups;  
                                 pc->pc_fullgroups = cur;  
                                 pc->pc_nfull++;  
                         }  
                         cc->cc_current = pcg;  
                 }  
                 pc->pc_hits++;                  pc->pc_hits++;
                 pc->pc_nempty--;                  pc->pc_nempty--;
                 mutex_exit(&pc->pc_lock);                  mutex_exit(&pc->pc_lock);
Line 2643  pool_cache_put_slow(pool_cache_cpu_t *cc
Line 2637  pool_cache_put_slow(pool_cache_cpu_t *cc
          * object away.           * object away.
          */           */
         nobj = pc->pc_pcgsize;          nobj = pc->pc_pcgsize;
         if (pool_cache_disable) {          if (nobj == PCG_NOBJECTS_LARGE) {
                 pcg = NULL;  
         } else if (nobj == PCG_NOBJECTS_LARGE) {  
                 pcg = pool_get(&pcg_large_pool, PR_NOWAIT);                  pcg = pool_get(&pcg_large_pool, PR_NOWAIT);
         } else {          } else {
                 pcg = pool_get(&pcg_normal_pool, PR_NOWAIT);                  pcg = pool_get(&pcg_normal_pool, PR_NOWAIT);
Line 3064  found:
Line 3056  found:
                                         snprintf(cpucachestr,                                          snprintf(cpucachestr,
                                             sizeof(cpucachestr),                                              sizeof(cpucachestr),
                                             "cached by CPU %u",                                              "cached by CPU %u",
                                             ci->ci_index);                                              (u_int)ci->ci_cpuid);
                                         goto print;                                          goto print;
                                 }                                  }
                         }                          }

Legend:
Removed from v.1.131.2.4  
changed lines
  Added in v.1.137.2.5

CVSweb <webmaster@jp.NetBSD.org>