From owner-svn-src-all@FreeBSD.ORG Thu Aug 16 08:29:50 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2502F106566B; Thu, 16 Aug 2012 08:29:50 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EAC958FC16; Thu, 16 Aug 2012 08:29:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7G8TnWT084390; Thu, 16 Aug 2012 08:29:49 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7G8TnRl084388; Thu, 16 Aug 2012 08:29:49 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201208160829.q7G8TnRl084388@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Thu, 16 Aug 2012 08:29:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239327 - head/sys/vm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Thu, 16 Aug 2012 08:29:50 -0000 Author: des Date: Thu Aug 16 08:29:49 2012 New Revision: 239327 URL: http://svn.freebsd.org/changeset/base/239327 Log: - When running out of swzone, instead of spewing an error message every tick until the situation is resolved (if ever), just print a single message when running out and another when space becomes available. - When adding more swap, warn if the total amount exceeds half the theoretical maximum we can handle. Modified: head/sys/vm/swap_pager.c Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Thu Aug 16 07:43:15 2012 (r239326) +++ head/sys/vm/swap_pager.c Thu Aug 16 08:29:49 2012 (r239327) @@ -1804,6 +1804,7 @@ restart: static void swp_pager_meta_build(vm_object_t object, vm_pindex_t pindex, daddr_t swapblk) { + static volatile int exhausted; struct swblock *swap; struct swblock **pswap; int idx; @@ -1847,7 +1848,9 @@ retry: mtx_unlock(&swhash_mtx); VM_OBJECT_UNLOCK(object); if (uma_zone_exhausted(swap_zone)) { - printf("swap zone exhausted, increase kern.maxswzone\n"); + if (atomic_cmpset_rel_int(&exhausted, 0, 1)) + printf("swap zone exhausted, " + "increase kern.maxswzone\n"); vm_pageout_oom(VM_OOM_SWAPZ); pause("swzonex", 10); } else @@ -1856,6 +1859,9 @@ retry: goto retry; } + if (atomic_cmpset_rel_int(&exhausted, 1, 0)) + printf("swap zone ok\n"); + swap->swb_hnext = NULL; swap->swb_object = object; swap->swb_index = pindex & ~(vm_pindex_t)SWAP_META_MASK; @@ -2112,6 +2118,31 @@ done: return (error); } +/* + * Check that the total amount of swap currently configured does not + * exceed half the theoretical maximum. If it does, print a warning + * message and return -1; otherwise, return 0. + */ +static int +swapon_check_swzone(unsigned long npages) +{ + unsigned long maxpages; + + /* absolute maximum we can handle assuming 100% efficiency */ + maxpages = uma_zone_get_max(swap_zone) * SWAP_META_PAGES; + + /* recommend using no more than half that amount */ + if (npages > maxpages / 2) { + printf("warning: total configured swap (%lu pages) " + "exceeds maximum recommended amount (%lu pages).\n", + npages, maxpages); + printf("warning: increase kern.maxswzone " + "or reduce amount of swap.\n"); + return (-1); + } + return (0); +} + static void swaponsomething(struct vnode *vp, void *id, u_long nblks, sw_strategy_t *strategy, sw_close_t *close, dev_t dev) { @@ -2175,6 +2206,7 @@ swaponsomething(struct vnode *vp, void * nswapdev++; swap_pager_avail += nblks; swap_total += (vm_ooffset_t)nblks * PAGE_SIZE; + swapon_check_swzone(swap_total / PAGE_SIZE); swp_sizecheck(); mtx_unlock(&sw_dev_mtx); }