07 Mar, 2010

1 commit

  • There are quite a few GFP_KERNEL memory allocations made during
    suspend/hibernation and resume that may cause the system to hang, because
    the I/O operations they depend on cannot be completed due to the
    underlying devices being suspended.

    Avoid this problem by clearing the __GFP_IO and __GFP_FS bits in
    gfp_allowed_mask before suspend/hibernation and restoring the original
    values of these bits in gfp_allowed_mask durig the subsequent resume.

    [akpm@linux-foundation.org: fix CONFIG_PM=n linkage]
    Signed-off-by: Rafael J. Wysocki
    Reported-by: Maxim Levitsky
    Cc: Sebastian Ott
    Cc: Benjamin Herrenschmidt
    Cc: KOSAKI Motohiro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

27 Feb, 2010

7 commits

  • The hibernate memory preallocation code allocates memory to push some
    user space data out of physical RAM, so that the hibernation image is
    not too large. It allocates more memory than necessary for creating
    the image, so it has to release some pages to make room for
    allocations made while suspending devices and disabling nonboot CPUs,
    or the system will hang due to the lack of free pages to allocate
    from. Unfortunately, the function used for freeing these pages,
    free_unnecessary_pages(), contains a bug that prevents it from doing
    the job on all systems without highmem.

    Fix this problem, which is a regression from the 2.6.30 kernel, by
    using the right condition for the termination of the loop in
    free_unnecessary_pages().

    Signed-off-by: Rafael J. Wysocki
    Reported-and-tested-by: Alan Jenkins
    Cc: stable@kernel.org

    Rafael J. Wysocki
     
  • Its contents and entry in Makefile were already removed in
    8e60c6a1348e17e68ad73589a52a03876e7059be
    (Shift remaining code from swsusp.c to hibernate.c)
    but somehow it remained in-place (rjw: which most likely was my
    mistake).

    Signed-off-by: Jiri Slaby
    Acked-by: Nigel Cunningham
    Signed-off-by: Rafael J. Wysocki

    Jiri Slaby
     
  • Remove a trailing space from a message in swsusp_save().

    Signed-off-by: Frans Pop
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Frans Pop
     
  • It will never reach here if the sws_resume_bdev is erratic.
    swsusp_read() is called only from software_resume(), but after
    swsusp_check() which would catch the error state.

    Signed-off-by: Jiri Slaby
    Signed-off-by: Rafael J. Wysocki

    Jiri Slaby
     
  • They were deprecated and removed from exported headers more than 2
    years ago. Inform users about their removal in the future now.

    (Switch cases needed to be reorderded for an easy fall through.)

    And add an entry to feature-removal-schedule.

    Signed-off-by: Jiri Slaby
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Jiri Slaby
     
  • Add configuration switch CONFIG_PM_ADVANCED_DEBUG for compiling in
    extra PM debugging/testing code allowing one to access some
    PM-related attributes of devices from the user space via sysfs.

    If CONFIG_PM_ADVANCED_DEBUG is set, add sysfs attribute power/async
    for every device allowing the user space to access the device's
    power.async_suspend flag and modify it, if desired.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Add sysfs attribute /sys/power/pm_async allowing the user space to
    disable/enable asynchronous suspend/resume of devices.

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     

23 Feb, 2010

1 commit

  • Introduce run-time PM callbacks for the PCI bus type. Make the new
    callbacks work in analogy with the existing system sleep PM
    callbacks, so that the drivers already converted to struct dev_pm_ops
    can use their suspend and resume routines for run-time PM without
    modifications.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Jesse Barnes

    Rafael J. Wysocki
     

16 Dec, 2009

1 commit

  • The kernel offers with TIOCL_GETKMSGREDIRECT ioctl() the possibility to
    redirect the kernel messages to a specific console.

    However, since it's not possible to switch to the kernel message console
    after a panic(), it would be nice if the kernel would print the panic
    message on the current console.

    This patch series adds a new interface to access the global kmsg_redirect
    variable by a function to be able to use it in code where
    CONFIG_VT_CONSOLE is not set (kernel/panic.c).

    This patch:

    Instead of using and exporting a global value kmsg_redirect, introduce a
    function vt_kmsg_redirect() that both can set and return the console where
    messages are printed.

    Change all users of kmsg_redirect (the VT code itself and kernel/power.c)
    to the new interface.

    The main advantage is that vt_kmsg_redirect() can also be used when
    CONFIG_VT_CONSOLE is not set.

    Signed-off-by: Bernhard Walle
    Cc: Alan Cox
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Bernhard Walle
     

06 Dec, 2009

5 commits


03 Nov, 2009

3 commits

  • Finish a line by \n when load_image fails in the middle of loading.

    Signed-off-by: Jiri Slaby
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Jiri Slaby
     
  • There are too many retval variables in save_image(). Thus error return
    value from snapshot_read_next() may be ignored and only part of the
    snapshot (successfully) written.

    Remove 'error' variable, invert the condition in the do-while loop
    and convert the loop to use only 'ret' variable.

    Switch the rest of the function to consider only 'ret'.

    Also make sure we end printed line by \n if an error occurs.

    Signed-off-by: Jiri Slaby
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Jiri Slaby
     
  • While cruising through the swsusp code I found few blkdev reference
    leaks of resume_bdev.

    swsusp_read: remove blkdev_put altogether. Some fail paths do
    not do that.
    swsusp_check: make sure we always put a reference on fail paths
    software_resume: all fail paths between swsusp_check and swsusp_read
    omit swsusp_close. Add it in those cases. And since
    swsusp_read doesn't drop the reference anymore, do
    it here unconditionally.

    [rjw: Fixed a small coding style issue.]

    Signed-off-by: Jiri Slaby
    Signed-off-by: Rafael J. Wysocki

    Jiri Slaby
     

29 Oct, 2009

1 commit

  • Freezing isn't exactly the most latency sensitive operation and
    there's no reason to burn cpu cycles and power waiting for it to
    complete. msleep(10) instead of yield(). This should improve
    reliability of emergency hibernation.

    [rjw: Modified the comment next to the msleep(10).]

    Signed-off-by: Tejun Heo
    Signed-off-by: Rafael J. Wysocki

    Tejun Heo
     

22 Oct, 2009

1 commit

  • Increase TEST_SUSPEND_SECONDS to 10 so the warning in
    suspend_test_finish() doesn't annoy the users of slower systems so much.

    Also, make the warning print the suspend-resume cycle time, so that we
    know why the warning actually triggered.

    Patch prepared during the hacking session at the Kernel Summit in Tokyo.

    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

24 Sep, 2009

1 commit

  • * remove asm/atomic.h inclusion from linux/utsname.h --
    not needed after kref conversion
    * remove linux/utsname.h inclusion from files which do not need it

    NOTE: it looks like fs/binfmt_elf.c do not need utsname.h, however
    due to some personality stuff it _is_ needed -- cowardly leave ELF-related
    headers and files alone.

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

22 Sep, 2009

2 commits

  • Signed-off-by: Alexey Dobriyan
    Acked-by: David Rientjes
    Reviewed-by: KOSAKI Motohiro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     
  • Since alloc_bootmem() will never return inaccessible (via virtual
    addressing) memory anyway, using the ..._low() variant only makes sense
    when the physical address range of the allocated memory must fulfill
    further constraints, espacially since on 64-bits (or more generally in all
    cases where the pools the two variants allocate from are than the full
    available range.

    Probably the use in alloc_tce_table() could also be eliminated (based on
    code inspection of pci-calgary_64.c), but that seems too risky given I
    know nothing about that hardware and have no way to test it.

    Signed-off-by: Jan Beulich
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Beulich
     

20 Sep, 2009

1 commit

  • In the past someone gratuitiously borrowed chunks of kernel internal vt
    code and dumped them in kernel/power. They have all sorts of deep relations
    with the vt code so put them in the vt tree instead

    Signed-off-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Alan Cox
     

15 Sep, 2009

6 commits

  • Fix the definition of BM_BITS_PER_BLOCK and kerneldoc
    description of create_bm_block_list().

    [rjw: Added changelog.]

    Signed-off-by: Wu Fengguang
    Signed-off-by: Rafael J. Wysocki

    Wu Fengguang
     
  • Use for_each_populated_zone() instead of for_each_zone() in hibernation
    code. This fixes a bug on s390, where we allow both config options
    HIBERNATION and MEMORY_HOTPLUG, so that we also have a ZONE_MOVABLE
    here. We only allow hibernation if no memory hotplug operation was
    performed, so in fact both features can only be used exclusively, but
    this way we don't need 2 differently configured (distribution) kernels.

    If we have an unpopulated ZONE_MOVABLE, we allow hibernation but run
    into a BUG_ON() in memory_bm_test/set/clear_bit() because hibernation
    code iterates through all zones, not only the populated zones, in
    several places. For example, swsusp_free() does for_each_zone() and
    then checks for pfn_valid(), which is true even if the zone is not
    populated, resulting in a BUG_ON() later because the pfn cannot be
    found in the memory bitmap.

    Replacing all occurences of for_each_zone() in hibernation code with
    for_each_populated_zone() would fix this issue.

    [rjw: Rebased on top of linux-next hibernation patches.]

    Signed-off-by: Gerald Schaefer
    Acked-by: KOSAKI Motohiro
    Signed-off-by: Rafael J. Wysocki

    Gerald Schaefer
     
  • We want to avoid attempting to free too much memory too hard during
    hibernation, so estimate the minimum size of the image to use as the
    lower limit for preallocating memory.

    The approach here is based on the (experimental) observation that we
    can't free more page frames than the sum of:

    * global_page_state(NR_SLAB_RECLAIMABLE)
    * global_page_state(NR_ACTIVE_ANON)
    * global_page_state(NR_INACTIVE_ANON)
    * global_page_state(NR_ACTIVE_FILE)
    * global_page_state(NR_INACTIVE_FILE)

    minus

    * global_page_state(NR_FILE_MAPPED)

    Namely, if this number is subtracted from the number of saveable
    pages in the system, we get a good estimate of the minimum reasonable
    size of a hibernation image.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Wu Fengguang

    Rafael J. Wysocki
     
  • Since the hibernation code is now going to use allocations of memory
    to make 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: Take highmem into account correctly.]

    Signed-off-by: Rafael J. Wysocki

    Rafael J. Wysocki
     
  • Rework swsusp_shrink_memory() so that it calls shrink_all_memory()
    just once to make some room for the image and then allocates memory
    to apply more pressure to the memory management subsystem, if
    necessary.

    Unfortunately, we don't seem to be able to drop shrink_all_memory()
    entirely just yet, because that would lead to huge performance
    regressions in some test cases.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek

    Rafael J. Wysocki
     
  • Although the same label name is used somewhere else in the file, this
    particular label was consistently typoed in all of its uses.

    Signed-off-by: Thadeu Lima de Souza Cascardo
    Signed-off-by: Rafael J. Wysocki

    Thadeu Lima de Souza Cascardo
     

23 Aug, 2009

1 commit

  • Introduce a core framework for run-time power management of I/O
    devices. Add device run-time PM fields to 'struct dev_pm_info'
    and device run-time PM callbacks to 'struct dev_pm_ops'. Introduce
    a run-time PM workqueue and define some device run-time PM helper
    functions at the core level. Document all these things.

    Special thanks to Alan Stern for his help with the design and
    multiple detailed reviews of the pereceding versions of this patch
    and to Magnus Damm for testing feedback.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Magnus Damm

    Rafael J. Wysocki
     

13 Jul, 2009

1 commit

  • * Remove smp_lock.h from files which don't need it (including some headers!)
    * Add smp_lock.h to files which do need it
    * Make smp_lock.h include conditional in hardirq.h
    It's needed only for one kernel_locked() usage which is under CONFIG_PREEMPT

    This will make hardirq.h inclusion cheaper for every PREEMPT=n config
    (which includes allmodconfig/allyesconfig, BTW)

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

17 Jun, 2009

1 commit

  • Currently, the following scenario appears to be possible in theory:

    * Tasks are frozen for hibernation or suspend.
    * Free pages are almost exhausted.
    * Certain piece of code in the suspend code path attempts to allocate
    some memory using GFP_KERNEL and allocation order less than or
    equal to PAGE_ALLOC_COSTLY_ORDER.
    * __alloc_pages_internal() cannot find a free page so it invokes the
    OOM killer.
    * The OOM killer attempts to kill a task, but the task is frozen, so
    it doesn't die immediately.
    * __alloc_pages_internal() jumps to 'restart', unsuccessfully tries
    to find a free page and invokes the OOM killer.
    * No progress can be made.

    Although it is now hard to trigger during hibernation due to the memory
    shrinking carried out by the hibernation code, it is theoretically
    possible to trigger during suspend after the memory shrinking has been
    removed from that code path. Moreover, since memory allocations are
    going to be used for the hibernation memory shrinking, it will be even
    more likely to happen during hibernation.

    To prevent it from happening, introduce the oom_killer_disabled switch
    that will cause __alloc_pages_internal() to fail in the situations in
    which the OOM killer would have been called and make the freezer set
    this switch after tasks have been successfully frozen.

    [akpm@linux-foundation.org: be nicer to the namespace]
    Signed-off-by: Rafael J. Wysocki
    Cc: Fengguang Wu
    Cc: David Rientjes
    Acked-by: Pavel Machek
    Cc: Mel Gorman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

15 Jun, 2009

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (31 commits)
    trivial: remove the trivial patch monkey's name from SubmittingPatches
    trivial: Fix a typo in comment of addrconf_dad_start()
    trivial: usb: fix missing space typo in doc
    trivial: pci hotplug: adding __init/__exit macros to sgi_hotplug
    trivial: Remove the hyphen from git commands
    trivial: fix ETIMEOUT -> ETIMEDOUT typos
    trivial: Kconfig: .ko is normally not included in module names
    trivial: SubmittingPatches: fix typo
    trivial: Documentation/dell_rbu.txt: fix typos
    trivial: Fix Pavel's address in MAINTAINERS
    trivial: ftrace:fix description of trace directory
    trivial: unnecessary (void*) cast removal in sound/oss/msnd.c
    trivial: input/misc: Fix typo in Kconfig
    trivial: fix grammo in bus_for_each_dev() kerneldoc
    trivial: rbtree.txt: fix rb_entry() parameters in sample code
    trivial: spelling fix in ppc code comments
    trivial: fix typo in bio_alloc kernel doc
    trivial: Documentation/rbtree.txt: cleanup kerneldoc of rbtree.txt
    trivial: Miscellaneous documentation typo fixes
    trivial: fix typo milisecond/millisecond for documentation and source comments.
    ...

    Linus Torvalds
     

13 Jun, 2009

6 commits

  • The *_nvs_* routines in swsusp.c make use of the io*map()
    functions, which are only provided for HAS_IOMEM, thus
    breaking compilation if HAS_IOMEM is not set. Fix this
    by moving the *_nvs_* routines into hibernate_nvs.c, which
    is only compiled if HAS_IOMEM is set.

    [rjw: Change the name of the new file to hibernate_nvs.c, add the
    license line to the header comment.]

    Signed-off-by: Cornelia Huck
    Acked-by: Pavel Machek
    Signed-off-by: Rafael J. Wysocki

    Cornelia Huck
     
  • Change the name of kernel/power/disk.c to kernel/power/hibernate.c
    in analogy with the file names introduced by the changes that
    separated the suspend to RAM and standby funtionality from the
    common PM functions.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek

    Rafael J. Wysocki
     
  • Move the suspend to RAM and standby code from kernel/power/main.c
    to two separate files, kernel/power/suspend.c containing the basic
    functions and kernel/power/suspend_test.c containing the automatic
    suspend test facility based on the RTC clock alarm.

    There are no changes in functionality related to these modifications.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek

    Rafael J. Wysocki
     
  • A future patch is going to modify the memory shrinking code so that
    it will make memory allocations to free memory instead of using an
    artificial memory shrinking mechanism for that. For this purpose it
    is convenient to move swsusp_shrink_memory() from
    kernel/power/swsusp.c to kernel/power/snapshot.c, because the new
    memory-shrinking code is going to use things that are local to
    kernel/power/snapshot.c .

    [rev. 2: Make some functions static and remove their headers from
    kernel/power/power.h]

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Acked-by: Wu Fengguang

    Rafael J. Wysocki
     
  • Remove the shrinking of memory from the suspend-to-RAM code, where
    it is not really necessary.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Nigel Cunningham
    Acked-by: Wu Fengguang

    Rafael J. Wysocki
     
  • This patch (as1241) renames a bunch of functions in the PM core.
    Rather than go through a boring list of name changes, suffice it to
    say that in the end we have a bunch of pairs of functions:

    device_resume_noirq dpm_resume_noirq
    device_resume dpm_resume
    device_complete dpm_complete
    device_suspend_noirq dpm_suspend_noirq
    device_suspend dpm_suspend
    device_prepare dpm_prepare

    in which device_X does the X operation on a single device and dpm_X
    invokes device_X for all devices in the dpm_list.

    In addition, the old dpm_power_up and device_resume_noirq have been
    combined into a single function (dpm_resume_noirq).

    Lastly, dpm_suspend_start and dpm_resume_end are the renamed versions
    of the former top-level device_suspend and device_resume routines.

    Signed-off-by: Alan Stern
    Acked-by: Magnus Damm
    Signed-off-by: Rafael J. Wysocki

    Alan Stern