[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.133.2.1 and 1.133.2.2

version 1.133.2.1, 2007/11/13 16:02:21 version 1.133.2.2, 2007/11/18 19:35:50
Line 2062  pool_cache_bootstrap(pool_cache_t pc, si
Line 2062  pool_cache_bootstrap(pool_cache_t pc, si
         pc->pc_nfull = 0;          pc->pc_nfull = 0;
         pc->pc_contended = 0;          pc->pc_contended = 0;
         pc->pc_refcnt = 0;          pc->pc_refcnt = 0;
           pc->pc_freecheck = NULL;
   
         /* Allocate per-CPU caches. */          /* Allocate per-CPU caches. */
         memset(pc->pc_cpus, 0, sizeof(pc->pc_cpus));          memset(pc->pc_cpus, 0, sizeof(pc->pc_cpus));
         pc->pc_ncpu = 0;          pc->pc_ncpu = 0;
         for (CPU_INFO_FOREACH(cii, ci)) {          if (ncpu == 0) {
                 pool_cache_cpu_init1(ci, pc);                  /* XXX For sparc: boot CPU is not attached yet. */
                   pool_cache_cpu_init1(curcpu(), pc);
           } else {
                   for (CPU_INFO_FOREACH(cii, ci)) {
                           pool_cache_cpu_init1(ci, pc);
                   }
         }          }
   
         if (__predict_true(!cold)) {          if (__predict_true(!cold)) {
Line 2142  static void
Line 2148  static void
 pool_cache_cpu_init1(struct cpu_info *ci, pool_cache_t pc)  pool_cache_cpu_init1(struct cpu_info *ci, pool_cache_t pc)
 {  {
         pool_cache_cpu_t *cc;          pool_cache_cpu_t *cc;
           int index;
   
           index = ci->ci_index;
   
           KASSERT(index < MAXCPUS);
         KASSERT(((uintptr_t)pc->pc_cpus & (CACHE_LINE_SIZE - 1)) == 0);          KASSERT(((uintptr_t)pc->pc_cpus & (CACHE_LINE_SIZE - 1)) == 0);
   
         if ((cc = pc->pc_cpus[ci->ci_index]) != NULL) {          if ((cc = pc->pc_cpus[index]) != NULL) {
                 KASSERT(cc->cc_cpu = ci);                  KASSERT(cc->cc_cpuindex == index);
                 return;                  return;
         }          }
   
Line 2167  pool_cache_cpu_init1(struct cpu_info *ci
Line 2177  pool_cache_cpu_init1(struct cpu_info *ci
         cc->cc_ipl = pc->pc_pool.pr_ipl;          cc->cc_ipl = pc->pc_pool.pr_ipl;
         cc->cc_iplcookie = makeiplcookie(cc->cc_ipl);          cc->cc_iplcookie = makeiplcookie(cc->cc_ipl);
         cc->cc_cache = pc;          cc->cc_cache = pc;
         cc->cc_cpu = ci;          cc->cc_cpuindex = index;
         cc->cc_hits = 0;          cc->cc_hits = 0;
         cc->cc_misses = 0;          cc->cc_misses = 0;
         cc->cc_current = NULL;          cc->cc_current = NULL;
         cc->cc_previous = NULL;          cc->cc_previous = NULL;
   
         pc->pc_cpus[ci->ci_index] = cc;          pc->pc_cpus[index] = cc;
 }  }
   
 /*  /*
Line 2212  pool_cache_reclaim(pool_cache_t pc)
Line 2222  pool_cache_reclaim(pool_cache_t pc)
         return pool_reclaim(&pc->pc_pool);          return pool_reclaim(&pc->pc_pool);
 }  }
   
   static void
   pool_cache_destruct_object1(pool_cache_t pc, void *object)
   {
   
           (*pc->pc_dtor)(pc->pc_arg, object);
           pool_put(&pc->pc_pool, object);
   }
   
 /*  /*
  * pool_cache_destruct_object:   * pool_cache_destruct_object:
  *   *
Line 2222  void
Line 2240  void
 pool_cache_destruct_object(pool_cache_t pc, void *object)  pool_cache_destruct_object(pool_cache_t pc, void *object)
 {  {
   
         (*pc->pc_dtor)(pc->pc_arg, object);          FREECHECK_IN(&pc->pc_freecheck, object);
         pool_put(&pc->pc_pool, object);  
           pool_cache_destruct_object1(pc, object);
 }  }
   
 /*  /*
Line 2243  pool_cache_invalidate_groups(pool_cache_
Line 2262  pool_cache_invalidate_groups(pool_cache_
   
                 for (i = 0; i < pcg->pcg_avail; i++) {                  for (i = 0; i < pcg->pcg_avail; i++) {
                         object = pcg->pcg_objects[i].pcgo_va;                          object = pcg->pcg_objects[i].pcgo_va;
                         pool_cache_destruct_object(pc, object);                          pool_cache_destruct_object1(pc, object);
                 }                  }
   
                 pool_put(&pcgpool, pcg);                  pool_put(&pcgpool, pcg);
Line 2310  static inline pool_cache_cpu_t *
Line 2329  static inline pool_cache_cpu_t *
 pool_cache_cpu_enter(pool_cache_t pc, int *s)  pool_cache_cpu_enter(pool_cache_t pc, int *s)
 {  {
         pool_cache_cpu_t *cc;          pool_cache_cpu_t *cc;
         struct cpu_info *ci;  
   
         /*          /*
          * Prevent other users of the cache from accessing our           * Prevent other users of the cache from accessing our
          * CPU-local data.  To avoid touching shared state, we           * CPU-local data.  To avoid touching shared state, we
          * pull the neccessary information from CPU local data.           * pull the neccessary information from CPU local data.
          */           */
         ci = curcpu();          crit_enter();
         KASSERT(ci->ci_data.cpu_index < MAXCPUS);          cc = pc->pc_cpus[curcpu()->ci_index];
         cc = pc->pc_cpus[ci->ci_data.cpu_index];  
         KASSERT(cc->cc_cache == pc);          KASSERT(cc->cc_cache == pc);
         if (cc->cc_ipl == IPL_NONE) {          if (cc->cc_ipl != IPL_NONE) {
                 crit_enter();  
         } else {  
                 *s = splraiseipl(cc->cc_iplcookie);                  *s = splraiseipl(cc->cc_iplcookie);
         }          }
   
         /* Moved to another CPU before disabling preemption? */  
         if (__predict_false(ci != curcpu())) {  
                 ci = curcpu();  
                 cc = pc->pc_cpus[ci->ci_data.cpu_index];  
         }  
   
 #ifdef DIAGNOSTIC  
         KASSERT(cc->cc_cpu == ci);  
         KASSERT(((uintptr_t)cc & (CACHE_LINE_SIZE - 1)) == 0);          KASSERT(((uintptr_t)cc & (CACHE_LINE_SIZE - 1)) == 0);
 #endif  
   
         return cc;          return cc;
 }  }
Line 2346  pool_cache_cpu_exit(pool_cache_cpu_t *cc
Line 2351  pool_cache_cpu_exit(pool_cache_cpu_t *cc
 {  {
   
         /* No longer need exclusive access to the per-CPU data. */          /* No longer need exclusive access to the per-CPU data. */
         if (cc->cc_ipl == IPL_NONE) {          if (cc->cc_ipl != IPL_NONE) {
                 crit_exit();  
         } else {  
                 splx(*s);                  splx(*s);
         }          }
           crit_exit();
 }  }
   
 #if __GNUC_PREREQ__(3, 0)  #if __GNUC_PREREQ__(3, 0)

Legend:
Removed from v.1.133.2.1  
changed lines
  Added in v.1.133.2.2

CVSweb <webmaster@jp.NetBSD.org>