19 Dec, 2008

1 commit

  • According to the ACPI Specification 3.0b, Section 15.3.2,
    "OSPM will call the _PTS control method some time before entering a
    sleeping state, to allow the platform's AML code to update this
    memory image before entering the sleeping state. After the system
    awakes from an S4 state, OSPM will restore this memory area and call
    the _WAK control method to enable the BIOS to reclaim its memory
    image." For this reason, implement a mechanism allowing us to save
    the NVS memory during hibernation and to restore it during the
    subsequent resume.

    Based on a patch by Zhang Rui.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Nigel Cunningham
    Cc: Zhang Rui
    Signed-off-by: Len Brown

    Rafael J. Wysocki
     

02 Feb, 2008

3 commits


19 Oct, 2007

1 commit

  • The following scenario leads to total confusion of the platform firmware on
    some boxes (eg. HPC nx6325):
    * Hibernate with ACPI enabled
    * Resume passing "acpi=off" to the boot kernel

    To prevent this from happening it's necessary to check if ACPI is enabled (and
    enable it if that's not the case) _right_ _after_ control has been transfered
    from the boot kernel to the image kernel, before device_power_up() is called
    (ie. with interrupts disabled).  Enabling ACPI after calling
    device_power_up() turns out to be insufficient.

    For this reason, introduce new hibernation callback ->leave() that will be
    executed before device_power_up() by the restored image kernel.  To make it
    work, it also is necessary to move swsusp_suspend() from swsusp.c to disk.c
    (it's name is changed to "create_image", which is more up to the point).

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

08 May, 2007

2 commits

  • Move the definition of PAGES_FOR_IO to kernel/power/power.h and introduce
    SPARE_PAGES representing the number of pages that should be freed by the
    swsusp's memory shrinker in addition to PAGES_FOR_IO so that device drivers
    can allocate some memory (up to 1 MB total) in their .suspend() routines
    without causing the suspend to fail.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Cc: Nigel Cunningham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • Make swsusp use extents instead of a bitmap to trace swap pages allocated
    for saving the image (the tracking is only needed in case there's an error,
    so that the allocated swap pages can be released).

    This should allow us to reduce the memory usage, practically always, and
    improve performance.

    Signed-off-by: Rafael J. Wysocki
    Cc: Nigel Cunningham
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

05 Apr, 2007

1 commit

  • Fix a bug in the swsusp's memory shrinker that causes some systems using
    highmem to refuse to suspend to disk if image_size is set above 1/2 of
    available RAM.

    Special thanks to Jiri Slaby for reporting the problem and assistance in
    debugging it.

    Signed-off-by: Rafael J. Wysocki
    Cc: Jiri Slaby
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

12 Feb, 2007

1 commit

  • This is again simplifies some of the VM counter calculations through the use
    of the ZVC consolidated counters.

    [michal.k.k.piotrowski@gmail.com: build fix]
    Signed-off-by: Christoph Lameter
    Signed-off-by: Michal Piotrowski
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     

08 Dec, 2006

4 commits

  • Move all labels in the swsusp code to the second column, so that they won't
    fool diff -p.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Cc: Nigel Cunningham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • Make swsusp measure and print the time needed to shrink memory during the
    suspend.

    Signed-off-by: Rafael J. Wysocki
    Cc: Pavel Machek
    Cc: Nigel Cunningham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • Currently swsusp saves the contents of highmem pages by copying them to the
    normal zone which is quite inefficient (eg. it requires two normal pages
    to be used for saving one highmem page). This may be improved by using
    highmem for saving the contents of saveable highmem pages.

    Namely, during the suspend phase of the suspend-resume cycle we try to
    allocate as many free highmem pages as there are saveable highmem pages.
    If there are not enough highmem image pages to store the contents of all of
    the saveable highmem pages, some of them will be stored in the "normal"
    memory. Next, we allocate as many free "normal" pages as needed to store
    the (remaining) image data. We use a memory bitmap to mark the allocated
    free pages (ie. highmem as well as "normal" image pages).

    Now, we use another memory bitmap to mark all of the saveable pages
    (highmem as well as "normal") and the contents of the saveable pages are
    copied into the image pages. Then, the second bitmap is used to save the
    pfns corresponding to the saveable pages and the first one is used to save
    their data.

    During the resume phase the pfns of the pages that were saveable during the
    suspend are loaded from the image and used to mark the "unsafe" page
    frames. Next, we try to allocate as many free highmem page frames as to
    load all of the image data that had been in the highmem before the suspend
    and we allocate so many free "normal" page frames that the total number of
    allocated free pages (highmem and "normal") is equal to the size of the
    image. While doing this we have to make sure that there will be some extra
    free "normal" and "safe" page frames for two lists of PBEs constructed
    later.

    Now, the image data are loaded, if possible, into their "original" page
    frames. The image data that cannot be written into their "original" page
    frames are loaded into "safe" page frames and their "original" kernel
    virtual addresses, as well as the addresses of the "safe" pages containing
    their copies, are stored in one of two lists of PBEs.

    One list of PBEs is for the copies of "normal" suspend pages (ie. "normal"
    pages that were saveable during the suspend) and it is used in the same way
    as previously (ie. by the architecture-dependent parts of swsusp). The
    other list of PBEs is for the copies of highmem suspend pages. The pages
    in this list are restored (in a reversible way) right before the
    arch-dependent code is called.

    Signed-off-by: Rafael J. Wysocki
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • Make swsusp use block device offsets instead of swap offsets to identify swap
    locations and make it use the same code paths for writing as well as for
    reading data.

    This allows us to use the same code for handling swap files and swap
    partitions and to simplify the code, eg. by dropping rw_swap_page_sync().

    Signed-off-by: Rafael J. Wysocki
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

27 Sep, 2006

1 commit

  • * master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (47 commits)
    Driver core: Don't call put methods while holding a spinlock
    Driver core: Remove unneeded routines from driver core
    Driver core: Fix potential deadlock in driver core
    PCI: enable driver multi-threaded probe
    Driver Core: add ability for drivers to do a threaded probe
    sysfs: add proper sysfs_init() prototype
    drivers/base: check errors
    drivers/base: Platform notify needs to occur before drivers attach to the device
    v4l-dev2: handle __must_check
    add CONFIG_ENABLE_MUST_CHECK
    add __must_check to device management code
    Driver core: fixed add_bind_files() definition
    Driver core: fix comments in drivers/base/power/resume.c
    sysfs_remove_bin_file: no return value, dump_stack on error
    kobject: must_check fixes
    Driver core: add ability for devices to create and remove bin files
    Class: add support for class interfaces for devices
    Driver core: create devices/virtual/ tree
    Driver core: add device_rename function
    Driver core: add ability for classes to handle devices properly
    ...

    Linus Torvalds
     

26 Sep, 2006

2 commits

  • Introduce the memory bitmap data structure and make swsusp use in the suspend
    phase.

    The current swsusp's internal data structure is not very efficient from the
    memory usage point of view, so it seems reasonable to replace it with a data
    structure that will require less memory, such as a pair of bitmaps.

    The idea is to use bitmaps that may be allocated as sets of individual pages,
    so that we can avoid making allocations of order greater than 0. For this
    reason the memory bitmap structure consists of several linked lists of objects
    that contain pointers to memory pages with the actual bitmap data. Still, for
    a typical system all of these lists fit in a single page, so it's reasonable
    to introduce an additional mechanism allowing us to allocate all of them
    efficiently without sacrificing the generality of the design. This is done
    with the help of the chain_allocator structure and associated functions.

    We need to use two memory bitmaps during the suspend phase of the
    suspend-resume cycle. One of them is necessary for marking the saveable
    pages, and the second is used to mark the pages in which to store the copies
    of them (aka image pages).

    First, the bitmaps are created and we allocate as many image pages as needed
    (the corresponding bits in the second bitmap are set as soon as the pages are
    allocated). Second, the bits corresponding to the saveable pages are set in
    the first bitmap and the saveable pages are copied to the image pages.
    Finally, the first bitmap is used to save the kernel virtual addresses of the
    saveable pages and the second one is used to save the contents of the image
    pages.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • This patch is the first of this series that should actually change any
    behavior ... by issuing the new event, now tha the rest of the kernel is
    prepared to receive it.

    This converts the PM core to issue the new PRETHAW message, which the rest of
    the kernel is now ready to receive.

    Signed-off-by: David Brownell
    Cc: "Rafael J. Wysocki"
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    David Brownell
     

26 Jun, 2006

1 commit

  • This reverts commits

    3e3318dee0878d42ed62a19c292a2ac284135db3 [PATCH] swsusp: x86_64 mark special saveable/unsaveable pages
    b6370d96e09944c6e3ae8d5743ca8a8ab1f79f6c [PATCH] swsusp: i386 mark special saveable/unsaveable pages
    ce4ab0012b32c1a4a1d6e934aeb73bf3151c48d9 [PATCH] swsusp: add architecture special saveable pages support

    because not only do they apparently cause page faults on x86, the
    infrastructure doesn't compile on powerpc.

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

23 Jun, 2006

3 commits

  • swsusp allocates memory from the normal zone, so it cannot use lowmem
    reserve pages from the lower zones. Therefore it should not count these
    pages as available to it.

    Signed-off-by: Rafael J. Wysocki
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • 1. Add architecture specific pages save/restore support. Next two patches
    will use this to save/restore 'ACPI NVS' pages.

    2. Allow reserved pages 'nosave'. This could avoid save/restore BIOS
    reserved pages.

    Signed-off-by: Shaohua Li
    Cc: Pavel Machek
    Cc: "Rafael J. Wysocki"
    Cc: Nigel Cunningham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Shaohua Li
     
  • Rework the swsusp's memory shrinker in the following way:

    - Simplify balance_pgdat() by removing all of the swsusp-related code
    from it.

    - Make shrink_all_memory() use shrink_slab() and a new function
    shrink_all_zones() which calls shrink_active_list() and
    shrink_inactive_list() directly for each zone in a way that's optimized
    for suspend.

    In shrink_all_memory() we try to free exactly as many pages as the caller
    asks for, preferably in one shot, starting from easier targets.  If slab
    caches are huge, they are most likely to have enough pages to reclaim.
     The inactive lists are next (the zones with more inactive pages go first)
    etc.

    Each time shrink_all_memory() attempts to shrink the active and inactive
    lists for each zone in 5 passes.  In the first pass, only the inactive
    lists are taken into consideration.  In the next two passes the active
    lists are also shrunk, but mapped pages are not reclaimed.  In the last
    two passes the active and inactive lists are shrunk and mapped pages are
    reclaimed as well. The aim of this is to alter the reclaim logic to choose
    the best pages to keep on resume and improve the responsiveness of the
    resumed system.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Con Kolivas
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

23 Mar, 2006

3 commits

  • Move the swap-writing/reading code of swsusp to a separate file.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • Introduce the low level interface that can be used for handling the
    snapshot of the system memory by the in-kernel swap-writing/reading code of
    swsusp and the userland interface code (to be introduced shortly).

    Also change the way in which swsusp records the allocated swap pages and,
    consequently, simplifies the in-kernel swap-writing/reading code (this is
    necessary for the userland interface too). To this end, it introduces two
    helper functions in mm/swapfile.c, so that the swsusp code does not refer
    directly to the swap internals.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Adrian Bunk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • This was a temporary thing for 2.6.16.

    Cc: "Rafael J. Wysocki"
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

18 Feb, 2006

1 commit


08 Feb, 2006

1 commit

  • - Remove unneeded bio_get() which would cause a bio leak

    - Writing doesn't dirty pages. Reading dirties pages.

    - We should dirty the pages after the IO completion, not before

    (Busy-waiting for disk I/O completion isn't very polite.)

    Signed-off-by: Pavel Machek
    Cc: "Rafael J. Wysocki"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pavel Machek
     

02 Feb, 2006

1 commit


07 Jan, 2006

7 commits

  • This makes the swsusp_info structure become the header of the image in the
    literal sense (ie. it is saved to the swap and read before any other image
    data with the help of the swsusp's swap map structure, so generally it is
    treated in the same way as the rest of the image).

    The main thing it does is to make swsusp_header contain the offset of the swap
    map used to track the image data pages rather than the offset of swsusp_info.
     Simultaneously, swsusp_info becomes the first image page written to the swap.

    The other changes are generally consequences of the above with a few
    exceptions (there's some consolidation in the image reading part as a few
    functions turn into trivial wrappers around something else).

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • This changes the handling of swap partitions by swsusp to avoid locking of the
    swap devices that are not used for suspend and, consequently, simplifies the
    code.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • Make the suspend image size limit tunable via /sys/power/image_size.

    It is necessary for systems on which there is a limited amount of swap
    available for suspend. It can also be useful for optimizing performance of
    swsusp on systems with 1 GB of RAM or more.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • Limit the size of the suspend image to approx. 500 MB, which should
    improve the overall performance of swsusp on systems with more than 1 GB of
    RAM.

    It introduces the constant IMAGE_SIZE that can be set to the preferred size
    of the image (in MB) and modifies the memory-shrinking part of swsusp to
    take this constant into account (500 is the default value of IMAGE_SIZE).

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • This patch makes swsusp free only as much memory as needed to complete the
    suspend and not as much as possible.  In the most of cases this should speed
    up the suspend and make the system much more responsive after resume,
    especially if a GUI (eg. X Windows) is used.

    If needed, the old behavior (ie to free as much memory as possible during
    suspend) can be restored by unsetting FAST_FREE in power.h

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • This patch introduces the swap map structure that can be used by swsusp for
    keeping tracks of data pages written to the swap.  The structure itself is
    described in a comment within the patch.

    The overall idea is to reduce the amount of metadata written to the swap and
    to write and read the image pages sequentially, in a file-alike way. This
    makes the swap-handling part of swsusp fairly independent of its
    snapshot-handling part and will hopefully allow us to completely separate
    these two parts in the future.

    This patch is needed to remove the suspend image size limit imposed by the
    limited size of the swsusp_info structure, which is essential for x86-64
    systems with more than 512 MB of RAM.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • This patch removes the image encryption that is only used by swsusp instead of
    zeroing the image after resume in order to prevent someone from reading some
    confidential data from it in the future and it does not protect the image from
    being read by an unauthorized person before resume. The functionality it
    provides should really belong to the user space and will possibly be
    reimplemented after the swap-handling functionality of swsusp is moved to the
    user space.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

09 Nov, 2005

3 commits

  • This patch makes only the functions in swsusp.c call functions in snapshot.c
    and not both ways.  It also moves the check for available swap out of
    swsusp_suspend() which is necessary for separating the swap-handling functions
    in swsusp from the core code.

    Signed-off-by: Rafael J. Wysocki
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • This patch simplifies the relocation of the page backup list (aka pagedir)
    during resume.

    Signed-off-by: Rafael J. Wysocki
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     
  • The changes made by this patch are necessary for the pagedir relocation
    simplification in the next patch.  Additionally, these changes allow us to
    drop check_pagedir() and make get_safe_page() be a one-line wrapper around
    alloc_image_page() (get_safe_page() goes to snapshot.c, because
    alloc_image_page() is static and it does not make sense to export it).

    Signed-off-by: Rafael J. Wysocki
    Cc: Pavel Machek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

07 Nov, 2005

2 commits


31 Oct, 2005

2 commits