Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757147AbXH2P6p (ORCPT ); Wed, 29 Aug 2007 11:58:45 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752666AbXH2P6e (ORCPT ); Wed, 29 Aug 2007 11:58:34 -0400 Received: from extu-mxob-2.symantec.com ([216.10.194.135]:40679 "EHLO extu-mxob-2.symantec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753671AbXH2P6d (ORCPT ); Wed, 29 Aug 2007 11:58:33 -0400 Date: Wed, 29 Aug 2007 16:58:01 +0100 (BST) From: Hugh Dickins X-X-Sender: hugh@blonde.wat.veritas.com To: Arjan van de Ven cc: Daniel Drake , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: speeding up swapoff In-Reply-To: <20070829073040.1ec35176@laptopd505.fenrus.org> Message-ID: References: <1188394172.22156.67.camel@localhost> <20070829073040.1ec35176@laptopd505.fenrus.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2161 Lines: 50 On Wed, 29 Aug 2007, Arjan van de Ven wrote: > On Wed, 29 Aug 2007 09:29:32 -0400 > Daniel Drake wrote: > > > I've spent some time trying to understand why swapoff is such a slow > > operation. > > > > My experiments show that when there is not much free physical memory, > > swapoff moves pages out of swap at a rate of approximately 5mb/sec. > > sounds like about disk speed (at random-seek IO pattern) The present method should be reading sequentially (with gaps), rather than randomly. Perhaps we need to check what's happening in practice. (I've often dithered over whether we should be doing swap readahead there or not: at present it does not, preferring to assume buffering at the hardware level, and last time I checked that worked out a little better.) > Another question, if this is during system shutdown, maybe that's a > valid case for flushing most of the pagecache first (from userspace) > since most of what's there won't be used again anyway. If that's enough > to make this go faster... (I didn't understand your point there, but Daniel has replied that it's not at shutdown anyway.) > A third question, have you investigated what happens if a process gets > killed that has pages in swap; as long as we don't page those in but > just forget about them, that would solve the shutdown problem nicely > (since we kill stuff first anyway there) We definitely don't page those in, it would be a disaster for process exit if we did: they just get discarded. As you say, shutdown is rarely a big issue, because almost all the processes which had stuff in swap have already been killed. tmpfs use of swap can be an issue there, but if the distro is wise, it'll do things in such an order that tmpfs'es are unmounted before swapoff (but may need two passes: the opposite case is a regular swapfile, where we need to swapoff before that partition can be unmounted). Hugh - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/