Index: sys/kern/uipc_mbuf.c =================================================================== RCS file: /home/ncvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.70 diff -u -r1.70 uipc_mbuf.c --- sys/kern/uipc_mbuf.c 2001/03/17 23:23:24 1.70 +++ sys/kern/uipc_mbuf.c 2001/03/24 23:45:08 @@ -245,16 +245,8 @@ * Also, once we run out of map space, it will be impossible to * get any more (nothing is ever freed back to the map). */ - if (mb_map_full || ((nmb + mbstat.m_mbufs) > nmbufs)) { - /* - * Needs to be atomic as we may be incrementing it - * while holding another mutex, like mclfree. In other - * words, m_drops is not reserved solely for mbufs, - * but is also available for clusters. - */ - atomic_add_long(&mbstat.m_drops, 1); + if (mb_map_full || ((nmb + mbstat.m_mbufs) > nmbufs)) return (0); - } mtx_unlock(&mmbfree.m_mtx); p = (caddr_t)kmem_malloc(mb_map, nbytes, M_NOWAIT); @@ -343,8 +335,7 @@ atomic_add_long(&mbstat.m_wait, 1); if (mmbfree.m_head != NULL) MBWAKEUP(m_mballoc_wid); - } else - atomic_add_long(&mbstat.m_drops, 1); + } return (p); } @@ -370,10 +361,8 @@ * If we've hit the mcluster number limit, stop allocating from * mb_map. */ - if (mb_map_full || ((ncl + mbstat.m_clusters) > nmbclusters)) { - atomic_add_long(&mbstat.m_drops, 1); + if (mb_map_full || ((ncl + mbstat.m_clusters) > nmbclusters)) return (0); - } mtx_unlock(&mclfree.m_mtx); p = (caddr_t)kmem_malloc(mb_map, npg_sz, @@ -384,10 +373,8 @@ * Either the map is now full, or `how' is M_DONTWAIT and there * are no pages left. */ - if (p == NULL) { - atomic_add_long(&mbstat.m_drops, 1); + if (p == NULL) return (0); - } /* * We don't let go of the mutex in order to avoid a race. @@ -429,8 +416,7 @@ atomic_add_long(&mbstat.m_wait, 1); if (mclfree.m_head != NULL) MBWAKEUP(m_clalloc_wid); - } else - atomic_add_long(&mbstat.m_drops, 1); + } return (p); } Index: sys/sys/mbuf.h =================================================================== RCS file: /home/ncvs/src/sys/sys/mbuf.h,v retrieving revision 1.71 diff -u -r1.71 mbuf.h --- sys/sys/mbuf.h 2001/02/17 05:35:56 1.71 +++ sys/sys/mbuf.h 2001/03/24 23:45:08 @@ -377,8 +377,10 @@ mbtypes[_mtype]++; \ mtx_unlock(&mmbfree.m_mtx); \ _MGET_SETUP(_mm, _mtype); \ - } else \ + } else { \ mtx_unlock(&mmbfree.m_mtx); \ + atomic_add_long(&mbstat.m_drops, 1); \ + } \ (m) = _mm; \ } while (0) @@ -404,8 +406,10 @@ mbtypes[_mtype]++; \ mtx_unlock(&mmbfree.m_mtx); \ _MGETHDR_SETUP(_mm, _mtype); \ - } else \ + } else { \ mtx_unlock(&mmbfree.m_mtx); \ + atomic_add_long(&mbstat.m_drops, 1); \ + } \ (m) = _mm; \ } while (0) @@ -453,7 +457,8 @@ _mm->m_ext.ext_size = MCLBYTES; \ _mm->m_ext.ext_type = EXT_CLUSTER; \ } \ - } \ + } else \ + atomic_add_long(&mbstat.m_drops, 1); \ } while (0) #define MEXTADD(m, buf, size, free, args, flags, type) do { \