From: Wu Fengguang <fengguang.wu@intel.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: "linux-pm@lists.linux-foundation.org"
<linux-pm@lists.linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
"pavel@ucw.cz" <pavel@ucw.cz>,
"torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
"jens.axboe@oracle.com" <jens.axboe@oracle.com>,
"alan-jenkins@tuffmail.co.uk" <alan-jenkins@tuffmail.co.uk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel-testers@vger.kernel.org" <kernel-testers@vger.kernel.org>
Subject: Re: [PATCH 5/5] PM/Hibernate: Do not release preallocated memory unnecessarily (rev. 2)
Date: Tue, 5 May 2009 10:24:27 +0800 [thread overview]
Message-ID: <20090505022427.GA10880@localhost> (raw)
In-Reply-To: <200905040222.39062.rjw@sisk.pl>
On Mon, May 04, 2009 at 08:22:38AM +0800, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rjw@sisk.pl>
>
> 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.
+ error = memory_bm_create(&orig_bm, GFP_IMAGE, PG_ANY);
+ if (error)
+ goto err_out;
+
+ error = memory_bm_create(©_bm, GFP_IMAGE, PG_ANY);
+ if (error)
+ goto err_out;
memory_bm_create() is called a number of times, each time it will
call create_mem_extents()/memory_bm_free(). Can they be optimized to
be called only once?
A side note: there are somehow duplicated *_extent_*() logics in the
filesystems, is it possible that we abstract out some of the common code?
+ for_each_populated_zone(zone) {
+ size += snapshot_additional_pages(zone);
+ count += zone_page_state(zone, NR_FREE_PAGES);
+ if (!is_highmem(zone))
+ count -= zone->lowmem_reserve[ZONE_NORMAL];
+ }
Why [ZONE_NORMAL] instead of [zone]? ZONE_NORMAL may not always be the largest zone,
for example, My 4GB laptop has a tiny ZONE_NORMAL and a large ZONE_DMA32.
+ /* If size < max_size, preallocating enough memory may be impossible. */
+ if (count > 0 && size == max_size)
+ error = -ENOMEM;
+ if (error)
+ goto err_out;
The two if()s can be merged.
At last, I'd express my major concern about the transition to preallocate
based memory shrinking: will it lead to more random swapping IOs?
Thanks,
Fengguang
next prev parent reply other threads:[~2009-05-05 2:25 UTC|newest]
Thread overview: 236+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-16 21:42 2.6.30-rc2-git2: Reported regressions from 2.6.29 Rafael J. Wysocki
2009-04-16 21:42 ` [Bug #13031] Deadlock/hang in SATA probe Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13048] /sys/class/backlight/acpi_video0/* is gone on vaio laptop with Intel GM45 Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13044] 2.6.30-rc1 can't find the root fs Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13058] First hibernation attempt fails Rafael J. Wysocki
2009-04-17 6:30 ` Jens Axboe
2009-04-17 8:28 ` Alan Jenkins
2009-04-17 9:13 ` Jens Axboe
2009-04-17 9:34 ` Jens Axboe
2009-04-17 9:38 ` Alan Jenkins
2009-04-17 9:45 ` Jens Axboe
2009-04-17 10:46 ` Alan Jenkins
2009-04-17 16:00 ` Linus Torvalds
2009-04-17 17:46 ` Alan Jenkins
2009-04-17 20:58 ` Rafael J. Wysocki
2009-04-17 21:12 ` Linus Torvalds
2009-04-18 8:16 ` Alan Jenkins
2009-04-18 12:38 ` Rafael J. Wysocki
2009-04-18 12:57 ` Alan Jenkins
2009-04-18 15:23 ` [PATCH] PM/Hibernate: Fix memory shrinking (Re: [Bug #13058] First hibernation attempt fails) Rafael J. Wysocki
2009-04-17 15:55 ` [Bug #13058] First hibernation attempt fails Linus Torvalds
2009-04-07 8:06 ` Pavel Machek
2009-04-20 19:20 ` Andrew Morton
2009-04-20 19:49 ` Rafael J. Wysocki
2009-04-20 19:53 ` Pavel Machek
2009-04-20 20:04 ` Andrew Morton
2009-04-20 23:37 ` Andrew Morton
2009-04-21 18:53 ` Rafael J. Wysocki
2009-04-22 13:07 ` Pavel Machek
2009-04-22 20:11 ` Rafael J. Wysocki
2009-04-22 20:19 ` Andrew Morton
2009-05-01 22:26 ` [PATCH 0/3] PM: Drop shrink_all_memory (was: Re: [Bug #13058] First hibernation attempt fails) Rafael J. Wysocki
2009-05-01 22:27 ` [PATCH 1/3] PM: Disable OOM killer during system-wide power transitions Rafael J. Wysocki
2009-05-01 23:09 ` Andrew Morton
2009-05-02 11:34 ` Rafael J. Wysocki
2009-05-03 9:47 ` Pavel Machek
2009-05-01 22:28 ` [PATCH 2/3] PM/Hibernate: Move memory shrinking to snapshot.c Rafael J. Wysocki
2009-05-01 22:29 ` [PATCH 3/3] PM/Hibernate: Use memory allocations to free memory Rafael J. Wysocki
2009-05-01 23:14 ` Andrew Morton
2009-05-02 11:46 ` Rafael J. Wysocki
2009-05-02 17:49 ` Andrew Morton
2009-05-03 0:20 ` [PATCH 0/4] PM: Drop shrink_all_memory (rev. 2) (was: Re: [PATCH 3/3] PM/Hibernate: Use memory allocations to free memory) Rafael J. Wysocki
2009-05-03 0:22 ` [PATCH 1/4] mm: Add __GFP_NO_OOM_KILL flag Rafael J. Wysocki
2009-05-03 11:54 ` Wu Fengguang
2009-05-03 0:23 ` [PATCH 2/4] PM/Hibernate: Move memory shrinking to snapshot.c (rev. 2) Rafael J. Wysocki
2009-05-03 0:24 ` [PATCH 3/4] PM/Hibernate: Use memory allocations to free memory " Rafael J. Wysocki
2009-05-03 3:06 ` Linus Torvalds
2009-05-03 9:36 ` Pavel Machek
2009-05-03 16:35 ` Rafael J. Wysocki
2009-05-04 9:36 ` Pavel Machek
2009-05-03 16:15 ` Rafael J. Wysocki
2009-05-03 11:51 ` Wu Fengguang
2009-05-03 16:22 ` Rafael J. Wysocki
2009-05-04 9:31 ` Pavel Machek
2009-05-04 19:52 ` Rafael J. Wysocki
2009-05-03 0:25 ` [PATCH 4/4] PM/Hibernate: Do not release preallocated memory unnecessarily Rafael J. Wysocki
2009-05-03 13:08 ` [PATCH 0/4] PM: Drop shrink_all_memory (rev. 2) (was: Re: [PATCH 3/3] PM/Hibernate: Use memory allocations to free memory) Wu Fengguang
2009-05-03 16:30 ` Rafael J. Wysocki
2009-05-04 0:08 ` [PATCH 0/5] PM: Drop shrink_all_memory (rev. 3) Rafael J. Wysocki
2009-05-04 0:10 ` [PATCH 1/5] mm: Add __GFP_NO_OOM_KILL flag Rafael J. Wysocki
2009-05-04 0:38 ` David Rientjes
2009-05-04 15:02 ` Rafael J. Wysocki
2009-05-04 16:44 ` David Rientjes
2009-05-04 19:51 ` Rafael J. Wysocki
2009-05-04 20:02 ` David Rientjes
2009-05-04 22:23 ` Rafael J. Wysocki
2009-05-05 0:37 ` David Rientjes
2009-05-05 22:19 ` Rafael J. Wysocki
2009-05-05 22:37 ` Andrew Morton
2009-05-05 23:20 ` Rafael J. Wysocki
2009-05-05 23:40 ` Andrew Morton
2009-05-07 18:09 ` Rafael J. Wysocki
2009-05-07 18:48 ` Andrew Morton
2009-05-07 19:33 ` Rafael J. Wysocki
2009-05-07 20:02 ` Andrew Morton
2009-05-07 20:18 ` Rafael J. Wysocki
2009-05-07 20:25 ` David Rientjes
2009-05-07 20:35 ` Pavel Machek
2009-05-07 20:40 ` David Rientjes
2009-05-07 20:38 ` Rafael J. Wysocki
2009-05-07 20:42 ` David Rientjes
2009-05-07 20:56 ` Andrew Morton
2009-05-07 21:25 ` David Rientjes
2009-05-07 21:36 ` Rafael J. Wysocki
2009-05-07 21:46 ` David Rientjes
2009-05-07 22:05 ` Rafael J. Wysocki
2009-05-07 21:50 ` Andrew Morton
2009-05-07 22:14 ` Rafael J. Wysocki
2009-05-07 22:38 ` Andrew Morton
2009-05-07 22:50 ` Rafael J. Wysocki
2009-05-07 23:15 ` Andrew Morton
2009-05-07 23:24 ` Rafael J. Wysocki
2009-05-07 22:16 ` David Rientjes
2009-05-07 22:45 ` Andrew Morton
2009-05-07 22:59 ` David Rientjes
2009-05-07 23:11 ` Rafael J. Wysocki
2009-05-08 1:16 ` KAMEZAWA Hiroyuki
2009-05-08 13:42 ` Rafael J. Wysocki
2009-05-08 9:50 ` Wu Fengguang
2009-05-08 13:51 ` Rafael J. Wysocki
2009-05-09 0:08 ` Rafael J. Wysocki
2009-05-09 7:34 ` Wu Fengguang
2009-05-09 19:22 ` Rafael J. Wysocki
2009-05-10 4:52 ` Wu Fengguang
2009-05-10 12:52 ` Rafael J. Wysocki
2009-05-08 23:55 ` Rafael J. Wysocki
2009-05-09 21:22 ` David Rientjes
2009-05-09 21:37 ` Rafael J. Wysocki
2009-05-09 22:39 ` David Rientjes
2009-05-09 23:03 ` Rafael J. Wysocki
2009-05-11 20:11 ` David Rientjes
2009-05-11 22:44 ` Rafael J. Wysocki
2009-05-11 23:07 ` Andrew Morton
2009-05-11 23:28 ` Rafael J. Wysocki
2009-05-12 0:11 ` Andrew Morton
2009-05-12 16:52 ` Rafael J. Wysocki
2009-05-12 17:50 ` Andrew Morton
2009-05-12 20:40 ` Rafael J. Wysocki
2009-05-07 18:50 ` David Rientjes
2009-05-04 19:01 ` Andrew Morton
2009-05-04 0:11 ` [PATCH 2/5] PM/Hibernate: Move memory shrinking to snapshot.c (rev. 2) Rafael J. Wysocki
2009-05-04 13:35 ` Pavel Machek
2009-05-04 0:12 ` [PATCH 3/5] PM/Suspend: Do not shrink memory before suspend Rafael J. Wysocki
2009-05-04 0:20 ` [PATCH 4/5] PM/Hibernate: Use memory allocations to free memory (rev. 3) Rafael J. Wysocki
2009-05-04 0:22 ` [PATCH 5/5] PM/Hibernate: Do not release preallocated memory unnecessarily (rev. 2) Rafael J. Wysocki
2009-05-05 2:24 ` Wu Fengguang [this message]
2009-05-05 2:46 ` Wu Fengguang
2009-05-05 23:07 ` Rafael J. Wysocki
2009-05-05 23:40 ` Wu Fengguang
2009-05-05 23:05 ` Rafael J. Wysocki
2009-05-06 13:30 ` Wu Fengguang
2009-05-06 13:52 ` Wu Fengguang
2009-05-06 13:56 ` Wu Fengguang
2009-05-06 20:54 ` Rafael J. Wysocki
2009-05-07 1:58 ` Wu Fengguang
2009-05-07 12:20 ` Rafael J. Wysocki
2009-05-07 12:34 ` Wu Fengguang
2009-08-16 13:46 ` Wu Fengguang
2009-08-16 22:48 ` Rafael J. Wysocki
2009-05-04 9:33 ` [PATCH 0/4] PM: Drop shrink_all_memory (rev. 2) (was: Re: [PATCH 3/3] PM/Hibernate: Use memory allocations to free memory) Pavel Machek
2009-05-04 19:53 ` Rafael J. Wysocki
2009-05-04 20:27 ` Pavel Machek
2009-04-17 20:34 ` [Bug #13058] First hibernation attempt fails Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13067] iwl3945: wlan0: beacon loss from AP - sending probe request Rafael J. Wysocki
2009-04-17 3:38 ` Justin Madru
2009-04-17 21:09 ` Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13069] regression in 2.6.29-git3 on SH/Dreamcast Rafael J. Wysocki
2009-04-24 17:37 ` Adrian McMenamin
2009-05-17 8:12 ` Pekka Enberg
2009-05-17 10:28 ` Rafael J. Wysocki
2009-05-17 10:38 ` Adrian McMenamin
2009-04-16 21:45 ` [Bug #13068] Lockdep warining in inotify_dev_queue_event Rafael J. Wysocki
2009-04-19 9:36 ` Sachin Sant
2009-04-19 10:56 ` Rafael J. Wysocki
2009-04-22 9:50 ` [Bug #13068] Lockdep warning " Sachin Sant
2009-04-16 21:45 ` [Bug #13066] Intel HD Audio oops Rafael J. Wysocki
2009-04-17 16:57 ` Takashi Iwai
2009-04-17 21:07 ` Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13096] 2.6.30-rc2 hangs in get_measured_perf on tigerton Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13087] boot hang due to commit ff69f2bba67bd45514923aaedbf40fe351787c59 Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13095] thinkpad-acpi: cannot control brightness with hotkeys Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13097] Kernel will freeze network after using a tun/tap device Rafael J. Wysocki
2009-04-17 0:44 ` David Miller
2009-04-17 0:54 ` Herbert Xu
2009-04-16 21:45 ` [Bug #13099] net, sky2: BUG: unable to handle kernel NULL pointer dereference, pci_vpd_truncate() Rafael J. Wysocki
2009-04-17 0:45 ` Ingo Molnar
2009-04-17 21:14 ` Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13101] BUG: scheduling while atomic: swapper/0/0x10000100 Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13098] 2.6.29-git12 breaks vga=0x0f07 on MSI/Intel GPU Rafael J. Wysocki
2009-04-17 5:24 ` Andi Kleen
2009-04-16 21:45 ` [Bug #13106] 2.6.30-rc1: intel 3945 no wireless Rafael J. Wysocki
2009-04-17 0:53 ` Larry Finger
2009-04-17 3:21 ` Justin Madru
2009-04-17 21:16 ` Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13109] High latency on /sys/class/thermal Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13107] LTP 20080131 causes defunct processes w/2.6.30-rc1 Rafael J. Wysocki
2009-04-17 16:55 ` Sukadev Bhattiprolu
2009-04-16 21:45 ` [Bug #13108] 2.6.30-rc1: white screen during boot (regression) on spitz Rafael J. Wysocki
2009-04-25 11:54 ` Pavel Machek
2009-04-26 12:18 ` Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13111] Linux 2.6.30-rc1 tg3 endian issues with MAC addresses on BCM5701 Rafael J. Wysocki
2009-04-17 0:43 ` David Miller
2009-04-17 0:58 ` Matt Carlson
2009-04-17 12:21 ` Robin Holt
2009-04-19 4:30 ` David Miller
2009-04-20 4:31 ` Michael Chan
2009-04-16 21:45 ` [Bug #13113] tiobench read 50% regression with 2.6.30-rc1 Rafael J. Wysocki
2009-04-17 6:29 ` Jens Axboe
2009-04-17 21:22 ` Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13110] 2.6.30-rc1 problems with firmware loading Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13112] Oops in drain_array Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13116] Can't boot with nosmp Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13118] iptables very slow after commit 784544739a25c30637397ace5489eeb6e15d7d49 Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13119] Trouble with make-install from a NFS mount Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13115] microcode driver newly spews warnings Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13114] USB storage (usbstick) automount woes Rafael J. Wysocki
2009-04-17 4:01 ` Mike Galbraith
2009-04-16 21:45 ` [Bug #13124] ioatdma: DMA-API: device driver frees DMA memory with wrong function Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13123] 20 ACPI interrupts per second on EEEPC 4G Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13122] reiserfs_delete_xattrs: Couldn't delete all xattrs (-13) Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13120] BUG: using rootfstype=ext4 causes oops Rafael J. Wysocki
2009-04-19 18:31 ` Andrew Price
2009-04-16 21:45 ` [Bug #13121] commit 1a7c618a3f7bef1a20ae740df512eeba21397fa5 breaks ACPI video Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13126] BUG: MAX_LOCKDEP_ENTRIES too low! when mounting rootfs Rafael J. Wysocki
2009-04-16 21:45 ` [Bug #13125] active uvcvideo breaks over suspend Rafael J. Wysocki
2009-04-17 0:40 ` 2.6.30-rc2-git2: Reported regressions from 2.6.29 Linus Torvalds
2009-04-17 1:25 ` Ingo Molnar
2009-04-17 21:25 ` Rafael J. Wysocki
2009-04-17 0:41 ` David Miller
2009-04-17 21:27 ` Rafael J. Wysocki
2009-04-17 0:46 ` Linus Torvalds
2009-04-17 21:31 ` Rafael J. Wysocki
2009-04-17 1:28 ` Jeff Chua
2009-04-17 1:30 ` Zhang Rui
2009-04-17 2:34 ` yakui_zhao
2009-04-17 21:35 ` Rafael J. Wysocki
2009-04-17 1:37 ` Ming Lei
2009-04-17 21:36 ` Rafael J. Wysocki
2009-04-17 23:56 ` Laurent Pinchart
2009-04-18 12:29 ` Rafael J. Wysocki
2009-04-18 2:32 ` leiming
2009-04-18 2:55 ` Linus Torvalds
2009-04-18 3:50 ` leiming
2009-04-18 4:51 ` leiming
2009-04-18 12:33 ` Rafael J. Wysocki
2009-04-20 20:08 ` Laurent Pinchart
2009-04-21 1:47 ` Ming Lei
2009-04-21 23:21 ` Laurent Pinchart
2009-05-09 3:28 ` Ming Lei
2009-05-09 16:24 ` Linus Torvalds
2009-05-09 21:37 ` Mauro Carvalho Chehab
2009-04-17 17:09 ` Thomas Meyer
2009-04-17 21:38 ` Rafael J. Wysocki
2009-04-24 13:44 ` Kalle Valo
2009-04-25 21:57 ` Rafael J. Wysocki
[not found] ` <200904170752.48078.edt@aei.ca>
[not found] ` <200904171648.38172.rjw@sisk.pl>
2009-04-26 13:35 ` Ed Tomlinson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090505022427.GA10880@localhost \
--to=fengguang.wu@intel.com \
--cc=akpm@linux-foundation.org \
--cc=alan-jenkins@tuffmail.co.uk \
--cc=jens.axboe@oracle.com \
--cc=kernel-testers@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).