1. 10 7月, 2016 2 次提交
  2. 02 7月, 2016 3 次提交
    • R
      PM / hibernate: Recycle safe pages after image restoration · 307c5971
      Rafael J. Wysocki 提交于
      One of the memory bitmaps used by the hibernation image restoration
      code is freed after the image has been loaded.
      
      That is not quite efficient, though, because the memory pages used
      for building that bitmap are known to be safe (ie. they were not
      used by the image kernel before hibernation) and the arch-specific
      code finalizing the image restoration may need them.  In that case
      it needs to allocate those pages again via the memory management
      subsystem, check if they are really safe again by consulting the
      other bitmaps and so on.
      
      To avoid that, recycle those pages by putting them into the global
      list of known safe pages so that they can be given to the arch code
      right away when necessary.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      307c5971
    • R
      PM / hibernate: Simplify mark_unsafe_pages() · 6dbecfd3
      Rafael J. Wysocki 提交于
      Rework mark_unsafe_pages() to use a simpler method of clearing
      all bits in free_pages_map and to set the bits for the "unsafe"
      pages (ie. pages that were used by the image kernel before
      hibernation) with the help of duplicate_memory_bitmap().
      
      For this purpose, move the pfn_valid() check from mark_unsafe_pages()
      to unpack_orig_pfns() where the "unsafe" pages are discovered.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6dbecfd3
    • R
      PM / hibernate: Do not free preallocated safe pages during image restore · 9c744481
      Rafael J. Wysocki 提交于
      The core image restoration code preallocates some safe pages
      (ie. pages that weren't used by the image kernel before hibernation)
      for future use before allocating the bulk of memory for loading the
      image data.  Those safe pages are then freed so they can be allocated
      again (with the memory management subsystem's help).  That's done to
      ensure that there will be enough safe pages for temporary data
      structures needed during image restoration.
      
      However, it is not really necessary to free those pages after they
      have been allocated.  They can be added to the (global) list of
      safe pages right away and then picked up from there when needed
      without freeing.
      
      That reduces the overhead related to using safe pages, especially
      in the arch-specific code, so modify the code accordingly.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      9c744481
  3. 07 11月, 2015 1 次提交
    • M
      mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep... · d0164adc
      Mel Gorman 提交于
      mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd
      
      __GFP_WAIT has been used to identify atomic context in callers that hold
      spinlocks or are in interrupts.  They are expected to be high priority and
      have access one of two watermarks lower than "min" which can be referred
      to as the "atomic reserve".  __GFP_HIGH users get access to the first
      lower watermark and can be called the "high priority reserve".
      
      Over time, callers had a requirement to not block when fallback options
      were available.  Some have abused __GFP_WAIT leading to a situation where
      an optimisitic allocation with a fallback option can access atomic
      reserves.
      
      This patch uses __GFP_ATOMIC to identify callers that are truely atomic,
      cannot sleep and have no alternative.  High priority users continue to use
      __GFP_HIGH.  __GFP_DIRECT_RECLAIM identifies callers that can sleep and
      are willing to enter direct reclaim.  __GFP_KSWAPD_RECLAIM to identify
      callers that want to wake kswapd for background reclaim.  __GFP_WAIT is
      redefined as a caller that is willing to enter direct reclaim and wake
      kswapd for background reclaim.
      
      This patch then converts a number of sites
      
      o __GFP_ATOMIC is used by callers that are high priority and have memory
        pools for those requests. GFP_ATOMIC uses this flag.
      
      o Callers that have a limited mempool to guarantee forward progress clear
        __GFP_DIRECT_RECLAIM but keep __GFP_KSWAPD_RECLAIM. bio allocations fall
        into this category where kswapd will still be woken but atomic reserves
        are not used as there is a one-entry mempool to guarantee progress.
      
      o Callers that are checking if they are non-blocking should use the
        helper gfpflags_allow_blocking() where possible. This is because
        checking for __GFP_WAIT as was done historically now can trigger false
        positives. Some exceptions like dm-crypt.c exist where the code intent
        is clearer if __GFP_DIRECT_RECLAIM is used instead of the helper due to
        flag manipulations.
      
      o Callers that built their own GFP flags instead of starting with GFP_KERNEL
        and friends now also need to specify __GFP_KSWAPD_RECLAIM.
      
      The first key hazard to watch out for is callers that removed __GFP_WAIT
      and was depending on access to atomic reserves for inconspicuous reasons.
      In some cases it may be appropriate for them to use __GFP_HIGH.
      
      The second key hazard is callers that assembled their own combination of
      GFP flags instead of starting with something like GFP_KERNEL.  They may
      now wish to specify __GFP_KSWAPD_RECLAIM.  It's almost certainly harmless
      if it's missed in most cases as other activity will wake kswapd.
      Signed-off-by: NMel Gorman <mgorman@techsingularity.net>
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Vitaly Wool <vitalywool@gmail.com>
      Cc: Rik van Riel <riel@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d0164adc
  4. 07 4月, 2015 1 次提交
  5. 04 2月, 2015 1 次提交
  6. 24 1月, 2015 1 次提交
  7. 03 11月, 2014 1 次提交
  8. 01 10月, 2014 1 次提交
    • J
      PM / hibernate: Iterate over set bits instead of PFNs in swsusp_free() · fdd64ed5
      Joerg Roedel 提交于
      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: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      fdd64ed5
  9. 25 9月, 2014 1 次提交
    • R
      Revert "PM / Hibernate: Iterate over set bits instead of PFNs in swsusp_free()" · 5c4dd348
      Rafael J. Wysocki 提交于
      Revert commit 6efde38f (PM / Hibernate: Iterate over set bits
      instead of PFNs in swsusp_free()) that introduced a NULL pointer
      dereference during system resume from hibernation:
      
      BUG: unable to handle kernel NULL pointer dereference at (null)
      IP: [<ffffffff810a8cc1>] swsusp_free+0x21/0x190
      PGD b39c2067 PUD b39c1067 PMD 0
      Oops: 0000 [#1] SMP
      Modules linked in: <irrelevant list of modules>
      CPU: 1 PID: 4898 Comm: s2disk Tainted: G         C     3.17-rc5-amd64 #1 Debian 3.17~rc5-1~exp1
      Hardware name: LENOVO 2776LEG/2776LEG, BIOS 6EET55WW (3.15 ) 12/19/2011
      task: ffff88023155ea40 ti: ffff8800b3b14000 task.ti: ffff8800b3b14000
      RIP: 0010:[<ffffffff810a8cc1>]  [<ffffffff810a8cc1>]
      swsusp_free+0x21/0x190
      RSP: 0018:ffff8800b3b17ea8  EFLAGS: 00010246
      RAX: 0000000000000000 RBX: ffff8800b39bab00 RCX: 0000000000000001
      RDX: ffff8800b39bab10 RSI: ffff8800b39bab00 RDI: 0000000000000000
      RBP: 0000000000000010 R08: 0000000000000000 R09: 0000000000000000
      R10: ffff8800b39bab10 R11: 0000000000000246 R12: ffffea0000000000
      R13: ffff880232f485a0 R14: ffff88023ac27cd8 R15: ffff880232927590
      FS:  00007f406d83b700(0000) GS:ffff88023bc80000(0000)
      knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: 0000000000000000 CR3: 00000000b3a62000 CR4: 00000000000007e0
      Stack:
       ffff8800b39bab00 0000000000000010 ffff880232927590 ffffffff810acb4a
       ffff8800b39bab00 ffffffff811a955a ffff8800b39bab10 0000000000000000
       ffff88023155f098 ffffffff81a6b8c0 ffff88023155ea40 0000000000000007
      Call Trace:
       [<ffffffff810acb4a>] ? snapshot_release+0x2a/0xb0
       [<ffffffff811a955a>] ? __fput+0xca/0x1d0
       [<ffffffff81080627>] ? task_work_run+0x97/0xd0
       [<ffffffff81012d89>] ? do_notify_resume+0x69/0xa0
       [<ffffffff8151452a>] ? int_signal+0x12/0x17
      Code: 66 2e 0f 1f 84 00 00 00 00 00 66 66 66 66 90 41 54 48 8b 05 ba 62 9c 00 49 bc 00 00 00 00 00 ea ff ff 48 8b 3d a1 62 9c 00 55 53 <48> 8b 10 48 89 50 18 48 8b 52 20 48 c7 40 28 00 00 00 00 c7 40
      RIP  [<ffffffff810a8cc1>] swsusp_free+0x21/0x190
       RSP <ffff8800b3b17ea8>
      CR2: 0000000000000000
      ---[ end trace f02be86a1ec0cccb ]---
      
      due to forbidden_pages_map being NULL in swsusp_free().
      
      Fixes: 6efde38f "PM / Hibernate: Iterate over set bits instead of PFNs in swsusp_free()"
      Reported-by: NBjørn Mork <bjorn@mork.no>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      5c4dd348
  10. 07 8月, 2014 1 次提交
    • L
      PM / hibernate: avoid unsafe pages in e820 reserved regions · 84c91b7a
      Lee, Chun-Yi 提交于
      When the machine doesn't well handle the e820 persistent when hibernate
      resuming, then it may cause page fault when writing image to snapshot
      buffer:
      
      [   17.929495] BUG: unable to handle kernel paging request at ffff880069d4f000
      [   17.933469] IP: [<ffffffff810a1cf0>] load_image_lzo+0x810/0xe40
      [   17.933469] PGD 2194067 PUD 77ffff067 PMD 2197067 PTE 0
      [   17.933469] Oops: 0002 [#1] SMP
      ...
      
      The ffff880069d4f000 page is in e820 reserved region of resume boot
      kernel:
      
      [    0.000000] BIOS-e820: [mem 0x0000000069d4f000-0x0000000069e12fff] reserved
      ...
      [    0.000000] PM: Registered nosave memory: [mem 0x69d4f000-0x69e12fff]
      
      So snapshot.c mark the pfn to forbidden pages map. But, this
      page is also in the memory bitmap in snapshot image because it's an
      original page used by image kernel, so it will also mark as an
      unsafe(free) page in prepare_image().
      
      That means the page in e820 when resuming mark as "forbidden" and
      "free", it causes get_buffer() treat it as an allocated unsafe page.
      Then snapshot_write_next() return this page to load_image, load_image
      writing content to this address, but this page didn't really allocated
      . So, we got page fault.
      
      Although the root cause is from BIOS, I think aggressive check and
      significant message in kernel will better then a page fault for
      issue tracking, especially when serial console unavailable.
      
      This patch adds code in mark_unsafe_pages() for check does free pages in
      nosave region. If so, then it print message and return fault to stop whole
      S4 resume process:
      
      [    8.166004] PM: Image loading progress:   0%
      [    8.658717] PM: 0x6796c000 in e820 nosave region: [mem 0x6796c000-0x6796cfff]
      [    8.918737] PM: Read 2511940 kbytes in 1.04 seconds (2415.32 MB/s)
      [    8.926633] PM: Error -14 resuming
      [    8.933534] PM: Failed to load hibernation image, recovering.
      Reviewed-by: NTakashi Iwai <tiwai@suse.de>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Signed-off-by: NLee, Chun-Yi <jlee@suse.com>
      [rjw: Subject]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      84c91b7a
  11. 29 7月, 2014 6 次提交
  12. 06 5月, 2014 1 次提交
  13. 08 4月, 2014 1 次提交
  14. 12 3月, 2014 1 次提交
  15. 22 1月, 2014 1 次提交
    • S
      kernel/power/snapshot.c: use memblock apis for early memory allocations · c2f69cda
      Santosh Shilimkar 提交于
      Switch to memblock interfaces for early memory allocator instead of
      bootmem allocator.  No functional change in beahvior than what it is in
      current code from bootmem users points of view.
      
      Archs already converted to NO_BOOTMEM now directly use memblock
      interfaces instead of bootmem wrappers build on top of memblock.  And
      the archs which still uses bootmem, these new apis just fallback to
      exiting bootmem APIs.
      Acked-by: N"Rafael J. Wysocki" <rjw@sisk.pl>
      Signed-off-by: NSantosh Shilimkar <santosh.shilimkar@ti.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Christoph Lameter <cl@linux-foundation.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Grygorii Strashko <grygorii.strashko@ti.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Michal Hocko <mhocko@suse.cz>
      Cc: Paul Walmsley <paul@pwsan.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Tony Lindgren <tony@atomide.com>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      c2f69cda
  16. 15 11月, 2013 1 次提交
    • R
      PM / Hibernate: Do not crash kernel in free_basic_memory_bitmaps() · 6a0c7cd3
      Rafael J. Wysocki 提交于
      I have received a report about the BUG_ON() in free_basic_memory_bitmaps()
      triggering mysteriously during an aborted s2disk hibernation attempt.
      The only way I can explain that is that /dev/snapshot was first
      opened for writing (resume mode), then closed and then opened again
      for reading and closed again without freezing tasks.  In that case
      the first invocation of snapshot_open() would set the free_bitmaps
      flag in snapshot_state, which is a static variable.  That flag
      wouldn't be cleared later and the second invocation of snapshot_open()
      would just leave it like that, so the subsequent snapshot_release()
      would see data->frozen set and free_basic_memory_bitmaps() would be
      called unnecessarily.
      
      To prevent that from happening clear data->free_bitmaps in
      snapshot_open() when the file is being opened for reading (hibernate
      mode).
      
      In addition to that, replace the BUG_ON() in free_basic_memory_bitmaps()
      with a WARN_ON() as the kernel can continue just fine if the condition
      checked by that macro occurs.
      
      Fixes: aab17289 (PM / hibernate: Fix user space driven resume regression)
      Reported-by: NOliver Lorenz <olli@olorenz.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: 3.12+ <stable@vger.kernel.org> # 3.12+
      6a0c7cd3
  17. 07 11月, 2013 1 次提交
  18. 01 10月, 2013 1 次提交
    • R
      PM / hibernate: Fix user space driven resume regression · aab17289
      Rafael J. Wysocki 提交于
      Recent commit 8fd37a4c (PM / hibernate: Create memory bitmaps after
      freezing user space) broke the resume part of the user space driven
      hibernation (s2disk), because I forgot that the resume utility
      loaded the image into memory without freezing user space (it still
      freezes tasks after loading the image).  This means that during user
      space driven resume we need to create the memory bitmaps at the
      "device open" time rather than at the "freeze tasks" time, so make
      that happen (that's a special case anyway, so it needs to be treated
      in a special way).
      Reported-and-tested-by: NRonald <ronald645@gmail.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      aab17289
  19. 12 9月, 2013 1 次提交
  20. 04 7月, 2013 1 次提交
  21. 04 6月, 2013 1 次提交
  22. 20 3月, 2012 1 次提交
  23. 18 2月, 2012 1 次提交
  24. 20 1月, 2012 1 次提交
  25. 11 1月, 2012 1 次提交
  26. 17 10月, 2011 1 次提交
  27. 07 7月, 2011 1 次提交
    • R
      PM / Hibernate: Fix free_unnecessary_pages() · 4d4cf23c
      Rafael J. Wysocki 提交于
      There is a bug in free_unnecessary_pages() that causes it to
      attempt to free too many pages in some cases, which triggers the
      BUG_ON() in memory_bm_clear_bit() for copy_bm.  Namely, if
      count_data_pages() is initially greater than alloc_normal, we get
      to_free_normal equal to 0 and "save" greater from 0.  In that case,
      if the sum of "save" and count_highmem_pages() is greater than
      alloc_highmem, we subtract a positive number from to_free_normal.
      Hence, since to_free_normal was 0 before the subtraction and is
      an unsigned int, the result is converted to a huge positive number
      that is used as the number of pages to free.
      
      Fix this bug by checking if to_free_normal is actually greater
      than or equal to the number we're going to subtract from it.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Reported-and-tested-by: NMatthew Garrett <mjg@redhat.com>
      Cc: stable@kernel.org
      4d4cf23c
  28. 18 5月, 2011 2 次提交
    • R
      Revert "PM / Hibernate: Reduce autotuned default image size" · 1c1be3a9
      Rafael J. Wysocki 提交于
      This reverts commit bea3864f
      (PM / Hibernate: Reduce autotuned default image size), because users
      are now able to resolve the issue this commit was supposed to address
      in a different way (i.e. by using the new /sys/power/reserved_size
      interface).
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      1c1be3a9
    • R
      PM / Hibernate: Add sysfs knob to control size of memory for drivers · ddeb6487
      Rafael J. Wysocki 提交于
      Martin reports that on his system hibernation occasionally fails due
      to the lack of memory, because the radeon driver apparently allocates
      too much of it during the device freeze stage.  It turns out that the
      amount of memory allocated by radeon during hibernation (and
      presumably during system suspend too) depends on the utilization of
      the GPU (e.g. hibernating while there are two KDE 4 sessions with
      compositing enabled causes radeon to allocate more memory than for
      one KDE 4 session).
      
      In principle it should be possible to use image_size to make the
      memory preallocation mechanism free enough memory for the radeon
      driver, but in practice it is not easy to guess the right value
      because of the way the preallocation code uses image_size.  For this
      reason, it seems reasonable to allow users to control the amount of
      memory reserved for driver allocations made after the hibernate
      preallocation, which currently is constant and amounts to 1 MB.
      
      Introduce a new sysfs file, /sys/power/reserved_size, whose value
      will be used as the amount of memory to reserve for the
      post-preallocation reservations made by device drivers, in bytes.
      For backwards compatibility, set its default (and initial) value to
      the currently used number (1 MB).
      
      References: https://bugzilla.kernel.org/show_bug.cgi?id=34102Reported-and-tested-by: NMartin Steigerwald <Martin@Lichtvoll.de>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      ddeb6487
  29. 15 3月, 2011 1 次提交
  30. 17 2月, 2011 1 次提交
  31. 27 10月, 2010 1 次提交