[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.51 and 1.52

version 1.51, 2001/05/04 19:41:26 version 1.52, 2001/05/09 23:46:03
Line 153  static void pool_print1(struct pool *, c
Line 153  static void pool_print1(struct pool *, c
         void (*)(const char *, ...));          void (*)(const char *, ...));
   
 /*  /*
  * Pool log entry. An array of these is allocated in pool_create().   * Pool log entry. An array of these is allocated in pool_init().
  */   */
 struct pool_log {  struct pool_log {
         const char      *pl_file;          const char      *pl_file;
Line 344  pr_rmpage(struct pool *pp, struct pool_i
Line 344  pr_rmpage(struct pool *pp, struct pool_i
 }  }
   
 /*  /*
  * Allocate and initialize a pool.  
  */  
 struct pool *  
 pool_create(size_t size, u_int align, u_int ioff, int nitems,  
     const char *wchan, size_t pagesz,  
     void *(*alloc)(unsigned long, int, int),  
     void (*release)(void *, unsigned long, int),  
     int mtype)  
 {  
         struct pool *pp;  
         int flags;  
   
         pp = (struct pool *)malloc(sizeof(*pp), M_POOL, M_NOWAIT);  
         if (pp == NULL)  
                 return (NULL);  
   
         flags = PR_FREEHEADER;  
         pool_init(pp, size, align, ioff, flags, wchan, pagesz,  
                   alloc, release, mtype);  
   
         if (nitems != 0) {  
                 if (pool_prime(pp, nitems, NULL) != 0) {  
                         pool_destroy(pp);  
                         return (NULL);  
                 }  
         }  
   
         return (pp);  
 }  
   
 /*  
  * Initialize the given pool resource structure.   * Initialize the given pool resource structure.
  *   *
  * We export this routine to allow other kernel parts to declare   * We export this routine to allow other kernel parts to declare
Line 966  _pool_put(struct pool *pp, void *v, cons
Line 935  _pool_put(struct pool *pp, void *v, cons
 }  }
   
 /*  /*
  * Add N items to the pool.  
  */  
 int  
 pool_prime(struct pool *pp, int n, caddr_t storage)  
 {  
         caddr_t cp;  
         int error, newnitems, newpages;  
   
 #ifdef DIAGNOSTIC  
         if (__predict_false(storage && !(pp->pr_roflags & PR_STATIC)))  
                 panic("pool_prime: static");  
         /* !storage && static caught below */  
 #endif  
   
         simple_lock(&pp->pr_slock);  
   
         newnitems = pp->pr_minitems + n;  
         newpages =  
                 roundup(newnitems, pp->pr_itemsperpage) / pp->pr_itemsperpage  
                 - pp->pr_minpages;  
   
         while (newpages-- > 0) {  
                 if (pp->pr_roflags & PR_STATIC) {  
                         cp = storage;  
                         storage += pp->pr_pagesz;  
                 } else {  
                         simple_unlock(&pp->pr_slock);  
                         cp = (*pp->pr_alloc)(pp->pr_pagesz, 0, pp->pr_mtype);  
                         simple_lock(&pp->pr_slock);  
                 }  
   
                 if (cp == NULL) {  
                         simple_unlock(&pp->pr_slock);  
                         return (ENOMEM);  
                 }  
   
                 if ((error = pool_prime_page(pp, cp, PR_NOWAIT)) != 0) {  
                         if ((pp->pr_roflags & PR_STATIC) == 0)  
                                 (*pp->pr_free)(cp, pp->pr_pagesz,  
                                     pp->pr_mtype);  
                         simple_unlock(&pp->pr_slock);  
                         return (error);  
                 }  
                 pp->pr_npagealloc++;  
                 pp->pr_minpages++;  
         }  
   
         pp->pr_minitems = newnitems;  
   
         if (pp->pr_minpages >= pp->pr_maxpages)  
                 pp->pr_maxpages = pp->pr_minpages + 1;  /* XXX */  
   
         simple_unlock(&pp->pr_slock);  
         return (0);  
 }  
   
 /*  
  * Add a page worth of items to the pool.   * Add a page worth of items to the pool.
  *   *
  * Note, we must be called with the pool descriptor LOCKED.   * Note, we must be called with the pool descriptor LOCKED.
Line 1106  pool_prime_page(struct pool *pp, caddr_t
Line 1018  pool_prime_page(struct pool *pp, caddr_t
 }  }
   
 /*  /*
  * Like pool_prime(), except this is used by pool_get() when nitems   * Used by pool_get() when nitems drops below the low water mark.  This
  * drops below the low water mark.  This is used to catch up nitmes   * is used to catch up nitmes with the low water mark.
  * with the low water mark.  
  *   *
  * Note 1, we never wait for memory here, we let the caller decide what to do.   * Note 1, we never wait for memory here, we let the caller decide what to do.
  *   *

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.52

CVSweb <webmaster@jp.NetBSD.org>