[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.145 and 1.151.6.1

version 1.145, 2007/12/26 16:01:36 version 1.151.6.1, 2008/04/03 12:43:03
Line 52  __KERNEL_RCSID(0, "$NetBSD$");
Line 52  __KERNEL_RCSID(0, "$NetBSD$");
 #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 123  struct pool_item_header {
Line 122  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 */
         struct timeval          ph_time;        /* last referenced */          uint32_t                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 613  pool_subsystem_init(void)
Line 612  pool_subsystem_init(void)
                 pa_reclaim_register(pa);                  pa_reclaim_register(pa);
         }          }
   
         pool_init(&cache_pool, sizeof(struct pool_cache), CACHE_LINE_SIZE,          pool_init(&cache_pool, sizeof(struct pool_cache), coherency_unit,
             0, 0, "pcache", &pool_allocator_nointr, IPL_NONE);              0, 0, "pcache", &pool_allocator_nointr, IPL_NONE);
   
         pool_init(&cache_cpu_pool, sizeof(pool_cache_cpu_t), CACHE_LINE_SIZE,          pool_init(&cache_cpu_pool, sizeof(pool_cache_cpu_t), coherency_unit,
             0, 0, "pcachecpu", &pool_allocator_nointr, IPL_NONE);              0, 0, "pcachecpu", &pool_allocator_nointr, IPL_NONE);
 }  }
   
Line 856  pool_init(struct pool *pp, size_t size, 
Line 855  pool_init(struct pool *pp, size_t size, 
   
                 size = sizeof(pcg_t) +                  size = sizeof(pcg_t) +
                     (PCG_NOBJECTS_NORMAL - 1) * sizeof(pcgpair_t);                      (PCG_NOBJECTS_NORMAL - 1) * sizeof(pcgpair_t);
                 pool_init(&pcg_normal_pool, size, CACHE_LINE_SIZE, 0, 0,                  pool_init(&pcg_normal_pool, size, coherency_unit, 0, 0,
                     "pcgnormal", &pool_allocator_meta, IPL_VM);                      "pcgnormal", &pool_allocator_meta, IPL_VM);
   
                 size = sizeof(pcg_t) +                  size = sizeof(pcg_t) +
                     (PCG_NOBJECTS_LARGE - 1) * sizeof(pcgpair_t);                      (PCG_NOBJECTS_LARGE - 1) * sizeof(pcgpair_t);
                 pool_init(&pcg_large_pool, size, CACHE_LINE_SIZE, 0, 0,                  pool_init(&pcg_large_pool, size, coherency_unit, 0, 0,
                     "pcglarge", &pool_allocator_meta, IPL_VM);                      "pcglarge", &pool_allocator_meta, IPL_VM);
         }          }
   
Line 996  pool_get(struct pool *pp, int flags)
Line 995  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(NULL, "pool_get(PR_WAITOK)");                  ASSERT_SLEEPABLE();
           }
 #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 1301  pool_do_put(struct pool *pp, void *v, st
Line 1300  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.
                          */                           */
                         getmicrotime(&ph->ph_time);                          ph->ph_time = time_uptime;
                 }                  }
                 pool_update_curpage(pp);                  pool_update_curpage(pp);
         }          }
Line 1454  pool_prime_page(struct pool *pp, void *s
Line 1456  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;
         getmicrotime(&ph->ph_time);          ph->ph_time = time_uptime;
         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 1615  pool_reclaim(struct pool *pp)
Line 1617  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;
         struct timeval curtime, diff;          uint32_t curtime;
         bool klock;          bool klock;
         int rv;          int rv;
   
Line 1652  pool_reclaim(struct pool *pp)
Line 1654  pool_reclaim(struct pool *pp)
   
         LIST_INIT(&pq);          LIST_INIT(&pq);
   
         getmicrotime(&curtime);          curtime = time_uptime;
   
         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 1662  pool_reclaim(struct pool *pp)
Line 1664  pool_reclaim(struct pool *pp)
                         break;                          break;
   
                 KASSERT(ph->ph_nmissing == 0);                  KASSERT(ph->ph_nmissing == 0);
                 timersub(&curtime, &ph->ph_time, &diff);                  if (curtime - ph->ph_time < pool_inactive_time
                 if (diff.tv_sec < pool_inactive_time  
                     && !pa_starved_p(pp->pr_alloc))                      && !pa_starved_p(pp->pr_alloc))
                         continue;                          continue;
   
Line 1804  pool_print_pagelist(struct pool *pp, str
Line 1805  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 %lu,%lu\n",                  (*pr)("\t\tpage %p, nmissing %d, time %" PRIu32 "\n",
                     ph->ph_page, ph->ph_nmissing,                      ph->ph_page, ph->ph_nmissing, ph->ph_time);
                     (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 2207  pool_cache_cpu_init1(struct cpu_info *ci
Line 2206  pool_cache_cpu_init1(struct cpu_info *ci
         index = ci->ci_index;          index = ci->ci_index;
   
         KASSERT(index < MAXCPUS);          KASSERT(index < MAXCPUS);
         KASSERT(((uintptr_t)pc->pc_cpus & (CACHE_LINE_SIZE - 1)) == 0);  
   
         if ((cc = pc->pc_cpus[index]) != NULL) {          if ((cc = pc->pc_cpus[index]) != NULL) {
                 KASSERT(cc->cc_cpuindex == index);                  KASSERT(cc->cc_cpuindex == index);
Line 2400  pool_cache_cpu_enter(pool_cache_t pc, in
Line 2398  pool_cache_cpu_enter(pool_cache_t pc, in
         if (cc->cc_ipl != IPL_NONE) {          if (cc->cc_ipl != IPL_NONE) {
                 *s = splraiseipl(cc->cc_iplcookie);                  *s = splraiseipl(cc->cc_iplcookie);
         }          }
         KASSERT(((uintptr_t)cc & (CACHE_LINE_SIZE - 1)) == 0);  
   
         return cc;          return cc;
 }  }
Line 2523  pool_cache_get_paddr(pool_cache_t pc, in
Line 2520  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(NULL, "pool_cache_get(PR_WAITOK)");                  ASSERT_SLEEPABLE();
           }
 #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 2533  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 2606  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 as cc_current and return.                   * group 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 2637  pool_cache_put_slow(pool_cache_cpu_t *cc
Line 2641  pool_cache_put_slow(pool_cache_cpu_t *cc
          * object away.           * object away.
          */           */
         nobj = pc->pc_pcgsize;          nobj = pc->pc_pcgsize;
         if (nobj == PCG_NOBJECTS_LARGE) {          if (pool_cache_disable) {
                   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 3056  found:
Line 3062  found:
                                         snprintf(cpucachestr,                                          snprintf(cpucachestr,
                                             sizeof(cpucachestr),                                              sizeof(cpucachestr),
                                             "cached by CPU %u",                                              "cached by CPU %u",
                                             (u_int)ci->ci_cpuid);                                              ci->ci_index);
                                         goto print;                                          goto print;
                                 }                                  }
                         }                          }

Legend:
Removed from v.1.145  
changed lines
  Added in v.1.151.6.1

CVSweb <webmaster@jp.NetBSD.org>