From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: [PATCH 5/5] PM/Hibernate: Do not release preallocated memory unnecessarily (rev. 2) Date: Wed, 6 May 2009 01:07:44 +0200 Message-ID: <200905060107.45345.rjw@sisk.pl> References: <20090505022427.GA10880@localhost> <20090505024646.GA14621@localhost> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20090505024646.GA14621@localhost> Content-Disposition: inline Sender: kernel-testers-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: Text/Plain; charset="us-ascii" To: Wu Fengguang 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 Tuesday 05 May 2009, Wu Fengguang wrote: > On Tue, May 05, 2009 at 10:24:27AM +0800, 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) > > > For you reference, here is the free memory before/after > > hibernate_preallocate_memory(): > > > > # free > > total used free shared buffers cached > > Mem: 1933 1917 15 0 0 1845 > > -/+ buffers/cache: 72 1861 > > Swap: 0 0 0 > > > > # free > > total used free shared buffers cached > > Mem: 1933 920 1012 0 0 356 > > -/+ buffers/cache: 563 1369 > > Swap: 0 0 0 > > > > It seems that the preallocated memory is not freed on -ENOMEM. > > Ah, this was my fault. > > I used to do this debugging trick: > > @@ -1207,7 +1207,7 @@ int hibernate_preallocate_memory(void) > pages, size); > swsusp_show_speed(&start, &stop, pages, "Allocated"); > > - return 0; > + return -ENOMEM; > > err_out: > printk(KERN_CONT "\n"); > > That "return -ENOMEM" should be "error = -ENOMEM" :-) > > Here is one more run: > > [ 194.016991] PM: Preallocating image memory ... done (allocated 383897 pages, 128000 image pages kept) > [ 196.505999] PM: Allocated 1535588 kbytes in 2.47 seconds (621.69 MB/s) > > Now the free report is back to normal: > > # free > total used free shared buffers cached > Mem: 1933 74 1858 0 0 15 Thanks for testing. The results look encouraging, but I'd also like to get rid of the regression mentioned in my previous message. Thanks, Rafael From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758620AbZEEXHy (ORCPT ); Tue, 5 May 2009 19:07:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752774AbZEEXHp (ORCPT ); Tue, 5 May 2009 19:07:45 -0400 Received: from ogre.sisk.pl ([217.79.144.158]:52398 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751810AbZEEXHo (ORCPT ); Tue, 5 May 2009 19:07:44 -0400 From: "Rafael J. Wysocki" To: Wu Fengguang Subject: Re: [PATCH 5/5] PM/Hibernate: Do not release preallocated memory unnecessarily (rev. 2) Date: Wed, 6 May 2009 01:07:44 +0200 User-Agent: KMail/1.11.2 (Linux/2.6.30-rc4-rjw; KDE/4.2.2; x86_64; ; ) 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" References: <20090505022427.GA10880@localhost> <20090505024646.GA14621@localhost> In-Reply-To: <20090505024646.GA14621@localhost> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200905060107.45345.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 05 May 2009, Wu Fengguang wrote: > On Tue, May 05, 2009 at 10:24:27AM +0800, 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) > > > For you reference, here is the free memory before/after > > hibernate_preallocate_memory(): > > > > # free > > total used free shared buffers cached > > Mem: 1933 1917 15 0 0 1845 > > -/+ buffers/cache: 72 1861 > > Swap: 0 0 0 > > > > # free > > total used free shared buffers cached > > Mem: 1933 920 1012 0 0 356 > > -/+ buffers/cache: 563 1369 > > Swap: 0 0 0 > > > > It seems that the preallocated memory is not freed on -ENOMEM. > > Ah, this was my fault. > > I used to do this debugging trick: > > @@ -1207,7 +1207,7 @@ int hibernate_preallocate_memory(void) > pages, size); > swsusp_show_speed(&start, &stop, pages, "Allocated"); > > - return 0; > + return -ENOMEM; > > err_out: > printk(KERN_CONT "\n"); > > That "return -ENOMEM" should be "error = -ENOMEM" :-) > > Here is one more run: > > [ 194.016991] PM: Preallocating image memory ... done (allocated 383897 pages, 128000 image pages kept) > [ 196.505999] PM: Allocated 1535588 kbytes in 2.47 seconds (621.69 MB/s) > > Now the free report is back to normal: > > # free > total used free shared buffers cached > Mem: 1933 74 1858 0 0 15 Thanks for testing. The results look encouraging, but I'd also like to get rid of the regression mentioned in my previous message. Thanks, Rafael