From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751336AbZHPNqa (ORCPT ); Sun, 16 Aug 2009 09:46:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751185AbZHPNqa (ORCPT ); Sun, 16 Aug 2009 09:46:30 -0400 Received: from mga03.intel.com ([143.182.124.21]:9453 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750908AbZHPNq3 (ORCPT ); Sun, 16 Aug 2009 09:46:29 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.43,389,1246863600"; d="scan'208";a="176311387" Date: Sun, 16 Aug 2009 21:46:10 +0800 From: Wu Fengguang To: "Rafael J. Wysocki" Cc: "linux-pm@lists.linux-foundation.org" , Andrew Morton , "pavel@ucw.cz" , "torvalds@linux-foundation.org" , "jens.axboe@oracle.com" , "alan-jenkins@tuffmail.co.uk" , "linux-kernel@vger.kernel.org" , "kernel-testers@vger.kernel.org" Subject: Re: [PATCH 5/5] PM/Hibernate: Do not release preallocated memory unnecessarily (rev. 2) Message-ID: <20090816134610.GA6266@localhost> References: <200905040222.39062.rjw@sisk.pl> <20090505022427.GA10880@localhost> <200905060105.10800.rjw@sisk.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200905060105.10800.rjw@sisk.pl> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 06, 2009 at 07:05:09AM +0800, Rafael J. Wysocki wrote: > On Tuesday 05 May 2009, Wu Fengguang wrote: > > On Mon, May 04, 2009 at 08:22:38AM +0800, Rafael J. Wysocki wrote: > > > From: Rafael J. Wysocki > > > > > > Since the hibernation code is now going to use allocations of memory > > > to create enough room for the image, it can also use the page frames > > > allocated at this stage as image page frames. The low-level > > > hibernation code needs to be rearranged for this purpose, but it > > > allows us to avoid freeing a great number of pages and allocating > > > these same pages once again later, so it generally is worth doing. > > > > > > [rev. 2: Change the strategy of preallocating memory to allocate as > > > many pages as needed to get the right image size in one shot (the > > > excessive allocated pages are released afterwards).] > > > > Rafael, I tried out your patches and found doubled memory shrink speed! > > > > [ 579.641781] PM: Preallocating image memory ... done (allocated 383900 pages, 128000 image pages kept) > > [ 583.087875] PM: Allocated 1535600 kbytes in 3.43 seconds (447.69 MB/s) > > Unfortunately, I'm observing a regression and a huge one. > > On my Atom-based test box with 1 GB of RAM after a fresh boot and starting X > with KDE 4 there are ~256 MB free. To create an image we need to free ~300 MB > and that takes ~2 s with the old code and ~15 s with the new one. > > It helps to call shrink_all_memory() once with a sufficiently large argument > before the preallocation. The 10 fold slowdown may be related to swapping IO: shrink_all_memory() tends to be reclaiming less anon pages. Is this box running on SSD? (Which can be slow on random writes.) Thanks, Fengguang From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wu Fengguang Subject: Re: [PATCH 5/5] PM/Hibernate: Do not release preallocated memory unnecessarily (rev. 2) Date: Sun, 16 Aug 2009 21:46:10 +0800 Message-ID: <20090816134610.GA6266@localhost> References: <200905040222.39062.rjw@sisk.pl> <20090505022427.GA10880@localhost> <200905060105.10800.rjw@sisk.pl> Mime-Version: 1.0 Return-path: Content-Disposition: inline In-Reply-To: <200905060105.10800.rjw-KKrjLPT3xs0@public.gmane.org> Sender: kernel-testers-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: "Rafael J. Wysocki" Cc: "linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org" , Andrew Morton , "pavel-+ZI9xUNit7I@public.gmane.org" , "torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org" , "jens.axboe-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org" , "alan-jenkins-cCz0Lq7MMjm9FHfhHBbuYA@public.gmane.org" , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "kernel-testers-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" On Wed, May 06, 2009 at 07:05:09AM +0800, Rafael J. Wysocki wrote: > On Tuesday 05 May 2009, Wu Fengguang wrote: > > On Mon, May 04, 2009 at 08:22:38AM +0800, Rafael J. Wysocki wrote: > > > From: Rafael J. Wysocki > > > > > > Since the hibernation code is now going to use allocations of memory > > > to create enough room for the image, it can also use the page frames > > > allocated at this stage as image page frames. The low-level > > > hibernation code needs to be rearranged for this purpose, but it > > > allows us to avoid freeing a great number of pages and allocating > > > these same pages once again later, so it generally is worth doing. > > > > > > [rev. 2: Change the strategy of preallocating memory to allocate as > > > many pages as needed to get the right image size in one shot (the > > > excessive allocated pages are released afterwards).] > > > > Rafael, I tried out your patches and found doubled memory shrink speed! > > > > [ 579.641781] PM: Preallocating image memory ... done (allocated 383900 pages, 128000 image pages kept) > > [ 583.087875] PM: Allocated 1535600 kbytes in 3.43 seconds (447.69 MB/s) > > Unfortunately, I'm observing a regression and a huge one. > > On my Atom-based test box with 1 GB of RAM after a fresh boot and starting X > with KDE 4 there are ~256 MB free. To create an image we need to free ~300 MB > and that takes ~2 s with the old code and ~15 s with the new one. > > It helps to call shrink_all_memory() once with a sufficiently large argument > before the preallocation. The 10 fold slowdown may be related to swapping IO: shrink_all_memory() tends to be reclaiming less anon pages. Is this box running on SSD? (Which can be slow on random writes.) Thanks, Fengguang