Re: [PATCH 5/5] PM/Hibernate: Do not release preallocated memory unnecessarily (rev. 2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 06, 2009 at 07:07:44AM +0800, Rafael J. Wysocki wrote:
> 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 <rjw@xxxxxxx>
> > > > 
> > > > 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

The above 'free' still exposed something wrong: only 74M memory are left,
instead of image_size=500M memory. I'm prepared to test your updated patches :-)
--
To unsubscribe from this list: send the line "unsubscribe kernel-testers" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux