From owner-p4-projects@FreeBSD.ORG Mon Jun 23 01:12:39 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7DC26106567C; Mon, 23 Jun 2008 01:12:39 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3FEBC10656AB for ; Mon, 23 Jun 2008 01:12:39 +0000 (UTC) (envelope-from snb@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 2DC6C8FC20 for ; Mon, 23 Jun 2008 01:12:39 +0000 (UTC) (envelope-from snb@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m5N1Cd7L053563 for ; Mon, 23 Jun 2008 01:12:39 GMT (envelope-from snb@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m5N1CdWM053561 for perforce@freebsd.org; Mon, 23 Jun 2008 01:12:39 GMT (envelope-from snb@FreeBSD.org) Date: Mon, 23 Jun 2008 01:12:39 GMT Message-Id: <200806230112.m5N1CdWM053561@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to snb@FreeBSD.org using -f From: Nick Barkas To: Perforce Change Reviews Cc: Subject: PERFORCE change 143941 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jun 2008 01:12:39 -0000 http://perforce.freebsd.org/chv.cgi?CH=143941 Change 143941 by snb@snb_toro on 2008/06/23 01:12:33 Return number of bytes freed by ufsdirhash_destroy() rather than 0 upon success. Also increment a counter vfs.ufs.dirhash_lowmemcount rather than printing a message when ufsdirhash_lowmem() is called. Affected files ... .. //depot/projects/soc2008/snb-dirhash/sys-ufs-ufs/ufs_dirhash.c#4 edit Differences ... ==== //depot/projects/soc2008/snb-dirhash/sys-ufs-ufs/ufs_dirhash.c#4 (text+ko) ==== @@ -81,6 +81,9 @@ static int ufs_dirhashcheck = 0; SYSCTL_INT(_vfs_ufs, OID_AUTO, dirhash_docheck, CTLFLAG_RW, &ufs_dirhashcheck, 0, "enable extra sanity tests"); +static int ufs_dirhashlowmemcount = 0; +SYSCTL_INT(_vfs_ufs, OID_AUTO, dirhash_lowmemcount, CTLFLAG_RD, + &ufs_dirhashlowmemcount, 0, "number of times low memory hook called"); static int ufsdirhash_hash(struct dirhash *dh, char *name, int namelen); @@ -1082,7 +1085,8 @@ * Assumes that ufsdirhash_list is locked, and leaves it locked. * If unable to obtain a lock on the first dirhash, moves down * the list until it can lock a dirhash and destroys it. Returns - * -1 if unable to find any dirhashes that can be destroyed. + * the amount of memory freed, or -1 if unable to find any + * dirhashes that can be destroyed. */ static int ufsdirhash_destroy() @@ -1130,7 +1134,7 @@ DIRHASHLIST_LOCK(); ufs_dirhashmem -= mem; - return (0); + return (mem); } /* @@ -1168,15 +1172,15 @@ static void ufsdirhash_lowmem() { - /* XXX: temporary silly way of notifying when this is called */ - printf("dirhash: ufsdirhash_lowmem() called\n"); + ufs_dirhashlowmemcount++; DIRHASHLIST_LOCK(); - /* - * Try deleting only one dirhash for now, and don't bother - * to check if it worked. - */ - ufsdirhash_destroy(); + if (ufs_dirhashmem > 0) + /* + * Try deleting only one dirhash for now, and don't bother + * to check if it worked. + */ + ufsdirhash_destroy(); DIRHASHLIST_UNLOCK(); }