PM / hibernate: Iterate over set bits instead of PFNs in swsusp_free()
authorJoerg Roedel <jroedel@suse.de>
Tue, 30 Sep 2014 11:31:29 +0000 (13:31 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 30 Sep 2014 19:12:20 +0000 (21:12 +0200)
commitfdd64ed54eeba6b8619b36dcc7cb6442f2c6da0c
treeebaca3059701e9f42eb5455af02f5d5fba83462e
parent905563ff47db35dcb3f69e69d434207270ad1966
PM / hibernate: Iterate over set bits instead of PFNs in swsusp_free()

The existing implementation of swsusp_free iterates over all
pfns in the system and checks every bit in the two memory
bitmaps.

This doesn't scale very well with large numbers of pfns,
especially when the bitmaps are not populated very densly.
Change the algorithm to iterate over the set bits in the
bitmaps instead to make it scale better in large memory
configurations.

Also add a memory_bm_clear_current() helper function that
clears the bit for the last position returned from the
memory bitmap.

This new version adds a !NULL check for the memory bitmaps
before they are walked. Not doing so causes a kernel crash
when the bitmaps are NULL.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
kernel/power/snapshot.c