From owner-svn-src-all@FreeBSD.ORG Tue Nov 19 12:11:12 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 594D7488; Tue, 19 Nov 2013 12:11:12 +0000 (UTC) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3B90C2B9E; Tue, 19 Nov 2013 12:11:11 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.7/8.14.7) with ESMTP id rAJCB9mo068241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 19 Nov 2013 16:11:09 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.7/8.14.7/Submit) id rAJCB9ab068240; Tue, 19 Nov 2013 16:11:09 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Tue, 19 Nov 2013 16:11:09 +0400 From: Gleb Smirnoff To: Alexander Motin Subject: Re: svn commit: r258336 - head/sys/vm Message-ID: <20131119121109.GG7577@FreeBSD.org> References: <201311191005.rAJA5snM048103@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201311191005.rAJA5snM048103@svn.freebsd.org> User-Agent: Mutt/1.5.22 (2013-10-16) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Nov 2013 12:11:12 -0000 Alexander, On Tue, Nov 19, 2013 at 10:05:53AM +0000, Alexander Motin wrote: A> Author: mav A> Date: Tue Nov 19 10:05:53 2013 A> New Revision: 258336 A> URL: http://svnweb.freebsd.org/changeset/base/258336 A> A> Log: A> Implement soft pressure on UMA cache bucket sizes. A> A> Every time system detects low memory condition decrease bucket sizes for A> each zone by one item. As result, higher memory pressure will push to A> smaller bucket sizes and so smaller per-CPU caches and so more efficient A> memory use. A> A> Before this change there was no force to oppose buckets growth as result A> of practically inevitable zone lock conflicts, and after some run time A> per-CPU caches could consume enough RAM to kill the system. Brief review of patch tells me that system never recovers from this. uz_count it decremented only and never incremented. A> Modified: A> head/sys/vm/uma_core.c A> head/sys/vm/uma_int.h A> A> Modified: head/sys/vm/uma_core.c A> ============================================================================== A> --- head/sys/vm/uma_core.c Tue Nov 19 09:35:20 2013 (r258335) A> +++ head/sys/vm/uma_core.c Tue Nov 19 10:05:53 2013 (r258336) A> @@ -701,6 +701,13 @@ bucket_cache_drain(uma_zone_t zone) A> bucket_free(zone, bucket, NULL); A> ZONE_LOCK(zone); A> } A> + A> + /* A> + * Shrink further bucket sizes. Price of single zone lock collision A> + * is probably lower then price of global cache drain. A> + */ A> + if (zone->uz_count > zone->uz_count_min) A> + zone->uz_count--; A> } A> A> static void A> @@ -1461,6 +1468,7 @@ zone_ctor(void *mem, int size, void *uda A> zone->uz_fails = 0; A> zone->uz_sleeps = 0; A> zone->uz_count = 0; A> + zone->uz_count_min = 0; A> zone->uz_flags = 0; A> zone->uz_warning = NULL; A> timevalclear(&zone->uz_ratecheck); A> @@ -1552,6 +1560,7 @@ out: A> zone->uz_count = bucket_select(zone->uz_size); A> else A> zone->uz_count = BUCKET_MAX; A> + zone->uz_count_min = zone->uz_count; A> A> return (0); A> } A> A> Modified: head/sys/vm/uma_int.h A> ============================================================================== A> --- head/sys/vm/uma_int.h Tue Nov 19 09:35:20 2013 (r258335) A> +++ head/sys/vm/uma_int.h Tue Nov 19 10:05:53 2013 (r258336) A> @@ -300,7 +300,8 @@ struct uma_zone { A> volatile u_long uz_fails; /* Total number of alloc failures */ A> volatile u_long uz_frees; /* Total number of frees */ A> uint64_t uz_sleeps; /* Total number of alloc sleeps */ A> - uint16_t uz_count; /* Highest amount of items in bucket */ A> + uint16_t uz_count; /* Amount of items in full bucket */ A> + uint16_t uz_count_min; /* Minimal amount of items there */ A> A> /* The next three fields are used to print a rate-limited warnings. */ A> const char *uz_warning; /* Warning to print on failure */ -- Totus tuus, Glebius.