[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.112.2.6 and 1.117

version 1.112.2.6, 2006/09/03 15:25:22 version 1.117, 2006/05/25 14:27:28
Line 364  pr_item_notouch_get(const struct pool *p
Line 364  pr_item_notouch_get(const struct pool *p
 static inline int  static inline int
 phtree_compare(struct pool_item_header *a, struct pool_item_header *b)  phtree_compare(struct pool_item_header *a, struct pool_item_header *b)
 {  {
   
         /*  
          * we consider pool_item_header with smaller ph_page bigger.  
          * (this unnatural ordering is for the benefit of pr_find_pagehead.)  
          */  
   
         if (a->ph_page < b->ph_page)          if (a->ph_page < b->ph_page)
                 return (1);  
         else if (a->ph_page > b->ph_page)  
                 return (-1);                  return (-1);
           else if (a->ph_page > b->ph_page)
                   return (1);
         else          else
                 return (0);                  return (0);
 }  }
Line 382  SPLAY_PROTOTYPE(phtree, pool_item_header
Line 376  SPLAY_PROTOTYPE(phtree, pool_item_header
 SPLAY_GENERATE(phtree, pool_item_header, ph_node, phtree_compare);  SPLAY_GENERATE(phtree, pool_item_header, ph_node, phtree_compare);
   
 /*  /*
  * Return the pool page header based on item address.   * Return the pool page header based on page address.
  */   */
 static inline struct pool_item_header *  static inline struct pool_item_header *
 pr_find_pagehead(struct pool *pp, void *v)  pr_find_pagehead(struct pool *pp, caddr_t page)
 {  {
         struct pool_item_header *ph, tmp;          struct pool_item_header *ph, tmp;
   
         if ((pp->pr_roflags & PR_NOALIGN) != 0) {          if ((pp->pr_roflags & PR_PHINPAGE) != 0)
                 tmp.ph_page = (caddr_t)(uintptr_t)v;                  return ((struct pool_item_header *)(page + pp->pr_phoffset));
                 ph = SPLAY_FIND(phtree, &pp->pr_phtree, &tmp);  
                 if (ph == NULL) {  
                         ph = SPLAY_ROOT(&pp->pr_phtree);  
                         if (ph != NULL && phtree_compare(&tmp, ph) >= 0) {  
                                 ph = SPLAY_NEXT(phtree, &pp->pr_phtree, ph);  
                         }  
                         KASSERT(ph == NULL || phtree_compare(&tmp, ph) < 0);  
                 }  
         } else {  
                 caddr_t page =  
                     (caddr_t)((uintptr_t)v & pp->pr_alloc->pa_pagemask);  
   
                 if ((pp->pr_roflags & PR_PHINPAGE) != 0) {  
                         ph = (void *)(page + pp->pr_phoffset);  
                 } else {  
                         tmp.ph_page = page;  
                         ph = SPLAY_FIND(phtree, &pp->pr_phtree, &tmp);  
                 }  
         }  
   
         KASSERT(ph == NULL || ((pp->pr_roflags & PR_PHINPAGE) != 0) ||          tmp.ph_page = page;
             (ph->ph_page <= (char *)v &&          ph = SPLAY_FIND(phtree, &pp->pr_phtree, &tmp);
             (char *)v < ph->ph_page + pp->pr_alloc->pa_pagesz));  
         return ph;          return ph;
 }  }
   
Line 637  pool_init(struct pool *pp, size_t size, 
Line 611  pool_init(struct pool *pp, size_t size, 
         if (align == 0)          if (align == 0)
                 align = ALIGN(1);                  align = ALIGN(1);
   
         if ((flags & PR_NOTOUCH) == 0 && size < sizeof(struct pool_item))          if (size < sizeof(struct pool_item))
                 size = sizeof(struct pool_item);                  size = sizeof(struct pool_item);
   
         size = roundup(size, align);          size = roundup(size, align);
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
         if (size > palloc->pa_pagesz)          if (size > palloc->pa_pagesz)
                 panic("pool_init: pool item size (%zu) too large", size);                  panic("pool_init: pool item size (%lu) too large",
                         (u_long)size);
 #endif  #endif
   
         /*          /*
Line 692  pool_init(struct pool *pp, size_t size, 
Line 667  pool_init(struct pool *pp, size_t size, 
         /* See the comment below about reserved bytes. */          /* See the comment below about reserved bytes. */
         trysize = palloc->pa_pagesz - ((align - ioff) % align);          trysize = palloc->pa_pagesz - ((align - ioff) % align);
         phsize = ALIGN(sizeof(struct pool_item_header));          phsize = ALIGN(sizeof(struct pool_item_header));
         if ((pp->pr_roflags & (PR_NOTOUCH | PR_NOALIGN)) == 0 &&          if ((pp->pr_roflags & PR_NOTOUCH) == 0 &&
             (pp->pr_size < MIN(palloc->pa_pagesz / 16, phsize << 3) ||              (pp->pr_size < MIN(palloc->pa_pagesz / 16, phsize << 3) ||
             trysize / pp->pr_size == (trysize - phsize) / pp->pr_size)) {              trysize / pp->pr_size == (trysize - phsize) / pp->pr_size)) {
                 /* Use the end of the page for the page header */                  /* Use the end of the page for the page header */
Line 928  pool_get(struct pool *pp, int flags)
Line 903  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)");                  simple_lock_only_held(NULL, "pool_get(PR_WAITOK)");
         SCHED_ASSERT_UNLOCKED();          SCHED_ASSERT_UNLOCKED();
 #endif  #endif
   
Line 1146  pool_do_put(struct pool *pp, void *v, st
Line 1121  pool_do_put(struct pool *pp, void *v, st
 {  {
         struct pool_item *pi = v;          struct pool_item *pi = v;
         struct pool_item_header *ph;          struct pool_item_header *ph;
           caddr_t page;
           int s;
   
         LOCK_ASSERT(simple_lock_held(&pp->pr_slock));          LOCK_ASSERT(simple_lock_held(&pp->pr_slock));
         SCHED_ASSERT_UNLOCKED();          SCHED_ASSERT_UNLOCKED();
   
           page = (caddr_t)((u_long)v & pp->pr_alloc->pa_pagemask);
   
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
         if (__predict_false(pp->pr_nout == 0)) {          if (__predict_false(pp->pr_nout == 0)) {
                 printf("pool %s: putting with none out\n",                  printf("pool %s: putting with none out\n",
Line 1158  pool_do_put(struct pool *pp, void *v, st
Line 1137  pool_do_put(struct pool *pp, void *v, st
         }          }
 #endif  #endif
   
         if (__predict_false((ph = pr_find_pagehead(pp, v)) == NULL)) {          if (__predict_false((ph = pr_find_pagehead(pp, page)) == NULL)) {
                 pr_printlog(pp, NULL, printf);                  pr_printlog(pp, NULL, printf);
                 panic("pool_put: %s: page header missing", pp->pr_wchan);                  panic("pool_put: %s: page header missing", pp->pr_wchan);
         }          }
Line 1238  pool_do_put(struct pool *pp, void *v, st
Line 1217  pool_do_put(struct pool *pp, void *v, st
                          * be reclaimed by the pagedaemon.  This minimizes                           * be reclaimed by the pagedaemon.  This minimizes
                          * ping-pong'ing for memory.                           * ping-pong'ing for memory.
                          */                           */
                         getmicrotime(&ph->ph_time);                          s = splclock();
                           ph->ph_time = mono_time;
                           splx(s);
                 }                  }
                 pool_update_curpage(pp);                  pool_update_curpage(pp);
         }          }
Line 1374  pool_prime_page(struct pool *pp, caddr_t
Line 1355  pool_prime_page(struct pool *pp, caddr_t
         unsigned int align = pp->pr_align;          unsigned int align = pp->pr_align;
         unsigned int ioff = pp->pr_itemoffset;          unsigned int ioff = pp->pr_itemoffset;
         int n;          int n;
           int s;
   
         LOCK_ASSERT(simple_lock_held(&pp->pr_slock));          LOCK_ASSERT(simple_lock_held(&pp->pr_slock));
   
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
         if ((pp->pr_roflags & PR_NOALIGN) == 0 &&          if (((u_long)cp & (pp->pr_alloc->pa_pagesz - 1)) != 0)
             ((uintptr_t)cp & (pp->pr_alloc->pa_pagesz - 1)) != 0)  
                 panic("pool_prime_page: %s: unaligned page", pp->pr_wchan);                  panic("pool_prime_page: %s: unaligned page", pp->pr_wchan);
 #endif  #endif
   
Line 1390  pool_prime_page(struct pool *pp, caddr_t
Line 1371  pool_prime_page(struct pool *pp, caddr_t
         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);          s = splclock();
           ph->ph_time = mono_time;
           splx(s);
         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 1556  pool_reclaim(struct pool *pp)
Line 1539  pool_reclaim(struct pool *pp)
         struct pool_pagelist pq;          struct pool_pagelist pq;
         struct pool_cache_grouplist pcgl;          struct pool_cache_grouplist pcgl;
         struct timeval curtime, diff;          struct timeval curtime, diff;
           int s;
   
         if (pp->pr_drain_hook != NULL) {          if (pp->pr_drain_hook != NULL) {
                 /*                  /*
Line 1577  pool_reclaim(struct pool *pp)
Line 1561  pool_reclaim(struct pool *pp)
         LIST_FOREACH(pc, &pp->pr_cachelist, pc_poollist)          LIST_FOREACH(pc, &pp->pr_cachelist, pc_poollist)
                 pool_cache_reclaim(pc, &pq, &pcgl);                  pool_cache_reclaim(pc, &pq, &pcgl);
   
         getmicrotime(&curtime);          s = splclock();
           curtime = mono_time;
           splx(s);
   
         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 1786  pool_print1(struct pool *pp, const char 
Line 1772  pool_print1(struct pool *pp, const char 
         (*pr)("\n");          (*pr)("\n");
         if ((pp->pr_roflags & PR_LOGGING) == 0)          if ((pp->pr_roflags & PR_LOGGING) == 0)
                 (*pr)("\tno log\n");                  (*pr)("\tno log\n");
         else {          else
                 pr_printlog(pp, NULL, pr);                  pr_printlog(pp, NULL, pr);
         }  
   
  skip_log:   skip_log:
         if (print_cache == 0)          if (print_cache == 0)
Line 1839  pool_chk_page(struct pool *pp, const cha
Line 1824  pool_chk_page(struct pool *pp, const cha
         caddr_t page;          caddr_t page;
         int n;          int n;
   
         if ((pp->pr_roflags & PR_NOALIGN) == 0) {          page = (caddr_t)((u_long)ph & pp->pr_alloc->pa_pagemask);
                 page = (caddr_t)((uintptr_t)ph & pp->pr_alloc->pa_pagemask);          if (page != ph->ph_page &&
                 if (page != ph->ph_page &&              (pp->pr_roflags & PR_PHINPAGE) != 0) {
                     (pp->pr_roflags & PR_PHINPAGE) != 0) {                  if (label != NULL)
                         if (label != NULL)                          printf("%s: ", label);
                                 printf("%s: ", label);                  printf("pool(%p:%s): page inconsistency: page %p;"
                         printf("pool(%p:%s): page inconsistency: page %p;"                         " at page head addr %p (p %p)\n", pp,
                                " at page head addr %p (p %p)\n", pp,                          pp->pr_wchan, ph->ph_page,
                                 pp->pr_wchan, ph->ph_page,                          ph, page);
                                 ph, page);                  return 1;
                         return 1;  
                 }  
         }          }
   
         if ((pp->pr_roflags & PR_NOTOUCH) != 0)          if ((pp->pr_roflags & PR_NOTOUCH) != 0)
Line 1865  pool_chk_page(struct pool *pp, const cha
Line 1848  pool_chk_page(struct pool *pp, const cha
                         if (label != NULL)                          if (label != NULL)
                                 printf("%s: ", label);                                  printf("%s: ", label);
                         printf("pool(%s): free list modified: magic=%x;"                          printf("pool(%s): free list modified: magic=%x;"
                                " page %p; item ordinal %d; addr %p\n",                                 " page %p; item ordinal %d;"
                                  " addr %p (p %p)\n",
                                 pp->pr_wchan, pi->pi_magic, ph->ph_page,                                  pp->pr_wchan, pi->pi_magic, ph->ph_page,
                                 n, pi);                                  n, pi, page);
                         panic("pool");                          panic("pool");
                 }                  }
 #endif  #endif
                 if ((pp->pr_roflags & PR_NOALIGN) != 0) {                  page =
                         continue;                      (caddr_t)((u_long)pi & pp->pr_alloc->pa_pagemask);
                 }  
                 page = (caddr_t)((uintptr_t)pi & pp->pr_alloc->pa_pagemask);  
                 if (page == ph->ph_page)                  if (page == ph->ph_page)
                         continue;                          continue;
   
Line 2038  pool_cache_get_paddr(struct pool_cache *
Line 2020  pool_cache_get_paddr(struct pool_cache *
   
 #ifdef LOCKDEBUG  #ifdef LOCKDEBUG
         if (flags & PR_WAITOK)          if (flags & PR_WAITOK)
                 ASSERT_SLEEPABLE(NULL, "pool_cache_get(PR_WAITOK)");                  simple_lock_only_held(NULL, "pool_cache_get(PR_WAITOK)");
 #endif  #endif
   
         simple_lock(&pc->pc_slock);          simple_lock(&pc->pc_slock);

Legend:
Removed from v.1.112.2.6  
changed lines
  Added in v.1.117

CVSweb <webmaster@jp.NetBSD.org>