Subject: sys/kern/subr_pool.c, static pool, low water mark warning
To: None <tech-kern@netbsd.org>
From: Tad Hunt <tad@entrisphere.com>
List: tech-kern
Date: 04/03/2001 12:54:15
In one of our device drivers, we're using a static pool (we've got
4MB of SDRAM on a separate memory bus specifically for this ATM
interface to chuck PDUs into).

The driver calls pool_prime() to fill the pool with the static
pages.

As soon as the driver begins to allocate out of this pool, we get
warnings from pool_catchup() for each allocation:

>	 printf("WARNING: static pool `%s' dropped below low water "
                    "mark\n", pp->pr_wchan);

We get this warning because each call to pool_prime() increases
the low water mark.

Here's our static pool init code:

	pool_init(&p, 2048, 8, 0, PR_STATIC, "foo", 0, panicalloc, panicfree, 0);
	if(pool_prime(&p, NITEMS, buf) != 0)
		panic("pool_prime static pool");
	pool_setlowat(&p, 0);

Without the call to pool_setlowat(), we get the above warning for
each call to pool_get().  With the call to pool_setlowat(), we get
the warning once (from the call to pool_catchup() inside
pool_setlowat()).

I failed to find a way to avoid the warning.  I am also not convinced
that calling pool_prime() should change the low water mark, so I
changed pool_prime() as below.  This gets rid of the warning by
changing the semantics of pool_prime() for PR_STATIC pools.

As I'd rather not be mucking around in the MI kernel code, I'm
interested to learn what the correct solution might be.

Thanks,
	-Tad

diff subr_pool.c /usr/NetBSD-current/syssrc/sys/kern/subr_pool.c
1013,1014c1013
<               if ((pp->pr_ro_flags & PR_STATIC) == 0)
<                       pp->pr_minpages++;
---
>               pp->pr_minpages++;
1017,1018c1016
<       if ((pp->pr_ro_flags & PR_STATIC) == 0)
<               pp->pr_minitems = newnitems;
---
>       pp->pr_minitems = newnitems;