From owner-freebsd-current@FreeBSD.ORG Tue Jul 29 18:23:24 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C5C1837B401; Tue, 29 Jul 2003 18:23:24 -0700 (PDT) Received: from cvsup.no.freebsd.org (c2h5oh.idi.ntnu.no [129.241.103.69]) by mx1.FreeBSD.org (Postfix) with ESMTP id 757ED43F3F; Tue, 29 Jul 2003 18:23:23 -0700 (PDT) (envelope-from Tor.Egge@cvsup.no.freebsd.org) Received: from localhost (localhost [127.0.0.1])h6U1NLr5043033; Wed, 30 Jul 2003 01:23:21 GMT (envelope-from tegge@cvsup.no.freebsd.org) To: phk@phk.freebsd.dk From: Tor.Egge@cvsup.no.freebsd.org In-Reply-To: <88569.1059513090@critter.freebsd.dk> References: <88569.1059513090@critter.freebsd.dk> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Wed_Jul_30_01:21:58_2003_809)--" Content-Transfer-Encoding: 7bit Message-Id: <20030730012321I.tegge@cvsup.no.freebsd.org> Date: Wed, 30 Jul 2003 01:23:21 GMT Sender: Tor Egge X-Dispatcher: imput version 20000228(IM140) Lines: 71 cc: jeffr@freebsd.org cc: current@freebsd.org Subject: Re: HEADSUP: UMA not reentrant / possible memory leak X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jul 2003 01:23:25 -0000 ----Next_Part(Wed_Jul_30_01:21:58_2003_809)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit > The indication of this is that the g_bio zone does not return to > zero USED as it should. It looks like z->uz_cachefree is slightly out of date (updated in zone_timout() every 20th second) and often too low (not taking the z->uz_full_bucket list into account). The enclosed patch recalculates the number of free elements on the buckets instead of using z->uz_cachefree. - Tor Egge ----Next_Part(Wed_Jul_30_01:21:58_2003_809)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="umacore.diff" Index: sys/vm/uma_core.c =================================================================== RCS file: /home/ncvs/src/sys/vm/uma_core.c,v retrieving revision 1.63 diff -u -r1.63 uma_core.c --- sys/vm/uma_core.c 28 Jul 2003 02:29:07 -0000 1.63 +++ sys/vm/uma_core.c 30 Jul 2003 01:05:37 -0000 @@ -2092,6 +2092,10 @@ char *tmpbuf, *offset; uma_zone_t z; char *p; + int cpu; + int cachefree; + uma_bucket_t bucket; + uma_cache_t cache; cnt = 0; mtx_lock(&uma_mtx); @@ -2112,8 +2116,27 @@ LIST_FOREACH(z, &uma_zones, uz_link) { if (cnt == 0) /* list may have changed size */ break; + for (cpu = 0; cpu < maxcpu; cpu++) { + if (CPU_ABSENT(cpu)) + continue; + CPU_LOCK(cpu); + } ZONE_LOCK(z); - totalfree = z->uz_free + z->uz_cachefree; + cachefree = 0; + for (cpu = 0; cpu < maxcpu; cpu++) { + if (CPU_ABSENT(cpu)) + continue; + cache = &z->uz_cpu[cpu]; + if (cache->uc_allocbucket != NULL) + cachefree += cache->uc_allocbucket->ub_ptr + 1; + if (cache->uc_freebucket != NULL) + cachefree += cache->uc_freebucket->ub_ptr + 1; + CPU_UNLOCK(cpu); + } + LIST_FOREACH(bucket, &z->uz_full_bucket, ub_link) { + cachefree += bucket->ub_ptr + 1; + } + totalfree = z->uz_free + cachefree; len = snprintf(offset, linesize, "%-12.12s %6.6u, %8.8u, %6.6u, %6.6u, %8.8llu\n", z->uz_name, z->uz_size, ----Next_Part(Wed_Jul_30_01:21:58_2003_809)----