[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.74.2.2 and 1.77

version 1.74.2.2, 2002/03/12 15:54:04 version 1.77, 2002/07/11 17:18:48
Line 1 
Line 1 
 /*      $NetBSD$        */  /*      $NetBSD$        */
   
 /*-  /*-
  * Copyright (c) 1997, 1999, 2000, 2002 The NetBSD Foundation, Inc.   * Copyright (c) 1997, 1999, 2000 The NetBSD Foundation, Inc.
  * All rights reserved.   * All rights reserved.
  *   *
  * This code is derived from software contributed to The NetBSD Foundation   * This code is derived from software contributed to The NetBSD Foundation
Line 145  struct pool_item {
Line 145  struct pool_item {
 /* The cache group pool. */  /* The cache group pool. */
 static struct pool pcgpool;  static struct pool pcgpool;
   
 /* The pool cache group. */  
 #define PCG_NOBJECTS            16  
 struct pool_cache_group {  
         TAILQ_ENTRY(pool_cache_group)  
                 pcg_list;       /* link in the pool cache's group list */  
         u_int   pcg_avail;      /* # available objects */  
                                 /* pointers to the objects */  
         void    *pcg_objects[PCG_NOBJECTS];  
 };  
   
 static void     pool_cache_reclaim(struct pool_cache *);  static void     pool_cache_reclaim(struct pool_cache *);
   
 static int      pool_catchup(struct pool *);  static int      pool_catchup(struct pool *);
Line 425  pool_init(struct pool *pp, size_t size, 
Line 415  pool_init(struct pool *pp, size_t size, 
         if (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 = ALIGN(size);
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
         if (size > palloc->pa_pagesz)          if (size > palloc->pa_pagesz)
                 panic("pool_init: pool item size (%lu) too large",                  panic("pool_init: pool item size (%lu) too large",
Line 646  pool_get(struct pool *pp, int flags)
Line 636  pool_get(struct pool *pp, int flags)
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
         if (__predict_false(curproc == NULL && doing_shutdown == 0 &&          if (__predict_false(curproc == NULL && doing_shutdown == 0 &&
                             (flags & PR_WAITOK) != 0))                              (flags & PR_WAITOK) != 0))
                 panic("pool_get: must have NOWAIT");                  panic("pool_get: %s: must have NOWAIT", pp->pr_wchan);
   
 #ifdef LOCKDEBUG  #ifdef LOCKDEBUG
         if (flags & PR_WAITOK)          if (flags & PR_WAITOK)
Line 871  pool_get(struct pool *pp, int flags)
Line 861  pool_get(struct pool *pp, int flags)
   
         pr_leave(pp);          pr_leave(pp);
         simple_unlock(&pp->pr_slock);          simple_unlock(&pp->pr_slock);
         KASSERT((((vaddr_t)v + pp->pr_itemoffset) & (pp->pr_align - 1)) == 0);  
         return (v);          return (v);
 }  }
   
Line 1049  pool_prime(struct pool *pp, int n)
Line 1038  pool_prime(struct pool *pp, int n)
 {  {
         struct pool_item_header *ph;          struct pool_item_header *ph;
         caddr_t cp;          caddr_t cp;
         int newpages, error = 0;          int newpages;
   
         simple_lock(&pp->pr_slock);          simple_lock(&pp->pr_slock);
   
Line 1063  pool_prime(struct pool *pp, int n)
Line 1052  pool_prime(struct pool *pp, int n)
                 simple_lock(&pp->pr_slock);                  simple_lock(&pp->pr_slock);
   
                 if (__predict_false(cp == NULL || ph == NULL)) {                  if (__predict_false(cp == NULL || ph == NULL)) {
                         error = ENOMEM;  
                         if (cp != NULL)                          if (cp != NULL)
                                 pool_allocator_free(pp, cp);                                  pool_allocator_free(pp, cp);
                         break;                          break;
Line 1091  pool_prime_page(struct pool *pp, caddr_t
Line 1079  pool_prime_page(struct pool *pp, caddr_t
 {  {
         struct pool_item *pi;          struct pool_item *pi;
         caddr_t cp = storage;          caddr_t cp = storage;
         const unsigned int align = pp->pr_align;          unsigned int align = pp->pr_align;
         const unsigned int ioff = pp->pr_itemoffset;          unsigned int ioff = pp->pr_itemoffset;
         int n;          int n;
   
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
Line 1128  pool_prime_page(struct pool *pp, caddr_t
Line 1116  pool_prime_page(struct pool *pp, caddr_t
         if (ioff != 0)          if (ioff != 0)
                 cp = (caddr_t)(cp + (align - ioff));                  cp = (caddr_t)(cp + (align - ioff));
   
         KASSERT((((vaddr_t)cp + ioff) & (align - 1)) == 0);  
   
         /*          /*
          * Insert remaining chunks on the bucket list.           * Insert remaining chunks on the bucket list.
          */           */
Line 1145  pool_prime_page(struct pool *pp, caddr_t
Line 1131  pool_prime_page(struct pool *pp, caddr_t
                 pi->pi_magic = PI_MAGIC;                  pi->pi_magic = PI_MAGIC;
 #endif  #endif
                 cp = (caddr_t)(cp + pp->pr_size);                  cp = (caddr_t)(cp + pp->pr_size);
   
                 KASSERT((((vaddr_t)cp + ioff) & (align - 1)) == 0);  
         }          }
   
         /*          /*
Line 1203  pool_catchup(struct pool *pp)
Line 1187  pool_catchup(struct pool *pp)
 void  void
 pool_setlowat(struct pool *pp, int n)  pool_setlowat(struct pool *pp, int n)
 {  {
         int error;  
   
         simple_lock(&pp->pr_slock);          simple_lock(&pp->pr_slock);
   
Line 1213  pool_setlowat(struct pool *pp, int n)
Line 1196  pool_setlowat(struct pool *pp, int n)
                 : roundup(n, pp->pr_itemsperpage) / pp->pr_itemsperpage;                  : roundup(n, pp->pr_itemsperpage) / pp->pr_itemsperpage;
   
         /* Make sure we're caught up with the newly-set low water mark. */          /* Make sure we're caught up with the newly-set low water mark. */
         if (POOL_NEEDS_CATCHUP(pp) && (error = pool_catchup(pp) != 0)) {          if (POOL_NEEDS_CATCHUP(pp) && pool_catchup(pp) != 0) {
                 /*                  /*
                  * XXX: Should we log a warning?  Should we set up a timeout                   * XXX: Should we log a warning?  Should we set up a timeout
                  * to try again in a second or so?  The latter could break                   * to try again in a second or so?  The latter could break
Line 1702  pool_cache_get(struct pool_cache *pc, in
Line 1685  pool_cache_get(struct pool_cache *pc, in
                                 return (NULL);                                  return (NULL);
                         }                          }
                 }                  }
                 KASSERT((((vaddr_t)object + pc->pc_pool->pr_itemoffset) &  
                     (pc->pc_pool->pr_align - 1)) == 0);  
                 return (object);                  return (object);
         }          }
   
Line 1717  pool_cache_get(struct pool_cache *pc, in
Line 1698  pool_cache_get(struct pool_cache *pc, in
   
         simple_unlock(&pc->pc_slock);          simple_unlock(&pc->pc_slock);
   
         KASSERT((((vaddr_t)object + pc->pc_pool->pr_itemoffset) &  
             (pc->pc_pool->pr_align - 1)) == 0);  
         return (object);          return (object);
 }  }
   

Legend:
Removed from v.1.74.2.2  
changed lines
  Added in v.1.77

CVSweb <webmaster@jp.NetBSD.org>