Skip to contentSkip to conversation

New: [bisected] s2disk / hibernate blocks on "Saving 506031 image data pages () ..."

Bug 75101 Johannes Weiner 7 participants 18 messages May 5, 2014 – Apr 4, 2019 1 message not in the archive Memory management

lore
Share & tools
lore
#0 lore raw

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : try_to_grab_pending <-mod_delayed_work_on
[  249.148009]   s2disk-3327    2d... 48550414us : del_timer <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550415us : get_work_pool <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550415us : _raw_spin_lock <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550415us : get_work_pwq <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550415us : pwq_activate_delayed_work <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550415us : get_work_pwq <-pwq_activate_delayed_work
[  249.148009]   s2disk-3327    2d... 48550415us : move_linked_works <-pwq_activate_delayed_work
[  249.148009]   s2disk-3327    2d... 48550415us : get_work_pwq <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550416us : pwq_dec_nr_in_flight <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550416us : __queue_delayed_work <-mod_delayed_work_on
[  249.148009]   s2disk-3327    2d... 48550416us : __queue_work <-mod_delayed_work_on
[  249.148009]   s2disk-3327    2d... 48550416us : get_work_pool <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550416us : _raw_spin_lock <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550416us : insert_work <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550417us : get_pwq.isra.20 <-insert_work
[  249.148009]   s2disk-3327    2d... 48550417us : wake_up_worker <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550417us : wake_up_process <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550417us : try_to_wake_up <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550417us : _raw_spin_lock_irqsave <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550417us : task_waking_fair <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550418us : select_task_rq_fair <-select_task_rq
[  249.148009]   s2disk-3327    2d... 48550418us : idle_cpu <-select_task_rq_fair
[  249.148009]   s2disk-3327    2d... 48550418us : idle_cpu <-select_task_rq_fair
[  249.148009]   s2disk-3327    2d... 48550418us : cpus_share_cache <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550418us : _raw_spin_lock <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550419us : ttwu_do_activate.constprop.100 <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550419us : activate_task <-ttwu_do_activate.constprop.100
[  249.148009]   s2disk-3327    2d... 48550419us : enqueue_task <-ttwu_do_activate.constprop.100
[  249.148009]   s2disk-3327    2d... 48550419us : update_rq_clock <-enqueue_task
[  249.148009]   s2disk-3327    2d... 48550419us : enqueue_task_fair <-ttwu_do_activate.constprop.100
[  249.148009]   s2disk-3327    2d... 48550419us : update_curr <-enqueue_task_fair
[  249.148009]   s2disk-3327    2d... 48550420us : update_min_vruntime <-update_curr
[  249.148009]   s2disk-3327    2d... 48550420us : __compute_runnable_contrib.part.55 <-update_entity_load_avg
[  249.148009]   s2disk-3327    2d... 48550420us : update_cfs_rq_blocked_load <-enqueue_task_fair
[  249.148009]   s2disk-3327    2d... 48550420us : account_entity_enqueue <-enqueue_task_fair
[  249.148009]   s2disk-3327    2d... 48550420us : update_cfs_shares <-enqueue_task_fair
[  249.148009]   s2disk-3327    2d... 48550420us : __enqueue_entity <-enqueue_task_fair
[  249.148009]   s2disk-3327    2d... 48550421us : hrtick_update <-ttwu_do_activate.constprop.100
[  249.148009]   s2disk-3327    2d... 48550421us : wq_worker_waking_up <-ttwu_do_activate.constprop.100
[  249.148009]   s2disk-3327    2d... 48550421us : kthread_data <-wq_worker_waking_up
[  249.148009]   s2disk-3327    2d... 48550421us : ttwu_do_wakeup <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550421us : check_preempt_curr <-ttwu_do_wakeup
[  249.148009]   s2disk-3327    2d... 48550421us : check_preempt_wakeup <-check_preempt_curr
[  249.148009]   s2disk-3327    2d... 48550422us : update_curr <-check_preempt_wakeup
[  249.148009]   s2disk-3327    2d... 48550422us : wakeup_preempt_entity.isra.53 <-check_preempt_wakeup
[  249.148009]   s2disk-3327    2d... 48550422us : _raw_spin_unlock_irqrestore <-try_to_wake_up
[  249.148009]   s2disk-3327    2.... 48550423us : bdi_dirty_limit <-bdi_dirty_limits
[  249.148009]   s2disk-3327    2d... 48550423us : _raw_spin_lock_irqsave <-__percpu_counter_sum
[  249.148009]   s2disk-3327    2d... 48550423us : _raw_spin_unlock_irqrestore <-__percpu_counter_sum
[  249.148009]   s2disk-3327    2d... 48550423us : _raw_spin_lock_irqsave <-__percpu_counter_sum
[  249.148009]   s2disk-3327    2d... 48550424us : _raw_spin_unlock_irqrestore <-__percpu_counter_sum
[  249.148009]   s2disk-3327    2.... 48550424us : bdi_position_ratio <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550424us : io_schedule_timeout <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550424us : __delayacct_blkio_start <-io_schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550424us : ktime_get_ts <-io_schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550424us : blk_flush_plug_list <-io_schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550425us : schedule_timeout <-io_schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550425us : lock_timer_base.isra.35 <-__mod_timer
[  249.148009]   s2disk-3327    2.... 48550425us : _raw_spin_lock_irqsave <-lock_timer_base.isra.35
[  249.148009]   s2disk-3327    2d... 48550425us : detach_if_pending <-__mod_timer
[  249.148009]   s2disk-3327    2d... 48550425us : idle_cpu <-__mod_timer
[  249.148009]   s2disk-3327    2d... 48550425us : internal_add_timer <-__mod_timer
[  249.148009]   s2disk-3327    2d... 48550425us : __internal_add_timer <-internal_add_timer
[  249.148009]   s2disk-3327    2d... 48550426us : _raw_spin_unlock_irqrestore <-__mod_timer
[  249.148009]   s2disk-3327    2.... 48550426us : schedule <-schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550426us : __schedule <-schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550426us : rcu_note_context_switch <-__schedule
[  249.148009]   s2disk-3327    2.... 48550426us : rcu_sched_qs <-rcu_note_context_switch
[  249.148009]   s2disk-3327    2.... 48550426us : _raw_spin_lock_irq <-__schedule
[  249.148009]   s2disk-3327    2d... 48550427us : deactivate_task <-__schedule
[  249.148009]   s2disk-3327    2d... 48550427us : dequeue_task <-__schedule
[  249.148009]   s2disk-3327    2d... 48550427us : update_rq_clock <-dequeue_task
[  249.148009]   s2disk-3327    2d... 48550427us : dequeue_task_fair <-__schedule
[  249.148009]   s2disk-3327    2d... 48550427us : update_curr <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550427us : update_min_vruntime <-update_curr
[  249.148009]   s2disk-3327    2d... 48550427us : cpuacct_charge <-update_curr
[  249.148009]   s2disk-3327    2d... 48550428us : update_cfs_rq_blocked_load <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550428us : clear_buddies <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550428us : account_entity_dequeue <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550428us : update_min_vruntime <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550428us : update_cfs_shares <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550428us : update_curr <-update_cfs_shares
[  249.148009]   s2disk-3327    2d... 48550429us : update_min_vruntime <-update_curr
[  249.148009]   s2disk-3327    2d... 48550429us : account_entity_dequeue <-update_cfs_shares
[  249.148009]   s2disk-3327    2d... 48550429us : account_entity_enqueue <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550429us : update_curr <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550429us : update_cfs_rq_blocked_load <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550429us : clear_buddies <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550429us : account_entity_dequeue <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550430us : update_min_vruntime <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550430us : update_cfs_shares <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550430us : hrtick_update <-__schedule
[  249.148009]   s2disk-3327    2d... 48550430us : put_prev_task_fair <-__schedule
[  249.148009]   s2disk-3327    2d... 48550430us : pick_next_task_fair <-pick_next_task
[  249.148009]   s2disk-3327    2d... 48550430us : clear_buddies <-pick_next_task_fair
[  249.148009]   s2disk-3327    2d... 48550431us : __dequeue_entity <-pick_next_task_fair

but the worker wakeup doesn't actually do anything:

[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Does this make sense? Rafael? Tejun?

Quoted 7 lines

2) /sys/kernel/debug/bdi/<dev>/stats

They are also in [1] - however the major/minors of my sdbX didn't match with the /sys/.../bdi/<dev>'s. So I just displayed them all.

3) What is the estimated bandwith?

Quoted 8 lines

It's an Samsung SSD 840 PRO, in this system: Read: 237 MB/s, Write 265 MB/s - see [2] (the faster writing is maybe due caching?)

Just by curiosity:

Can you also reproduce it ? ... since the test is quite simple. Or is it something specific in my system here ?

I tried to reproduce it here but could never get to hang it in balance_dirty_pages() like you did.

Thanks,
Johannes

Quoted 17 lines

[1] Attached session.log.s2disk.20140505_2238.bz2
- 18MiB uncompressed function-trace output + others
- The bdi outputs are also in there

[2] Rough bandwidth tests
Read:
---

gamix64:~# swapon -s 
Filename                                Type            Size    Used    Priority
/dev/sdb7                               partition       4193276 0       -1
gamix64:~# dd if=/dev/sdb7 bs=1024 count=$[1024*1024*4] |pv >/dev/null
   4GB 0:00:18 [ 226MB/s] [                                                     <=>                                                                                        ]4193280+0 records in
4193280+0 records out

4293918720 bytes (4.3 GB) copied, 18.1509 s, 237 MB/s
---

Quoted 8 lines

Write:
---

gamix64:~# dd if=/dev/zero bs=1024 count=$[1024*1024*4] |pv >/root/Test/test1.bin
4194304+0 records inMB/s] [                                          <=>                                                                                                   ]
4194304+0 records out
4294967296 bytes (4.3 GB) copied, 16.2039 s, 265 MB/s
   4GB 0:00:15 [ 256MB/s] [                                             <=>                                                                                                ]
---

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 126 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : try_to_grab_pending <-mod_delayed_work_on
[  249.148009]   s2disk-3327    2d... 48550414us : del_timer <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550415us : get_work_pool <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550415us : _raw_spin_lock <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550415us : get_work_pwq <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550415us : pwq_activate_delayed_work <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550415us : get_work_pwq <-pwq_activate_delayed_work
[  249.148009]   s2disk-3327    2d... 48550415us : move_linked_works <-pwq_activate_delayed_work
[  249.148009]   s2disk-3327    2d... 48550415us : get_work_pwq <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550416us : pwq_dec_nr_in_flight <-try_to_grab_pending
[  249.148009]   s2disk-3327    2d... 48550416us : __queue_delayed_work <-mod_delayed_work_on
[  249.148009]   s2disk-3327    2d... 48550416us : __queue_work <-mod_delayed_work_on
[  249.148009]   s2disk-3327    2d... 48550416us : get_work_pool <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550416us : _raw_spin_lock <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550416us : insert_work <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550417us : get_pwq.isra.20 <-insert_work
[  249.148009]   s2disk-3327    2d... 48550417us : wake_up_worker <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550417us : wake_up_process <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550417us : try_to_wake_up <-__queue_work
[  249.148009]   s2disk-3327    2d... 48550417us : _raw_spin_lock_irqsave <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550417us : task_waking_fair <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550418us : select_task_rq_fair <-select_task_rq
[  249.148009]   s2disk-3327    2d... 48550418us : idle_cpu <-select_task_rq_fair
[  249.148009]   s2disk-3327    2d... 48550418us : idle_cpu <-select_task_rq_fair
[  249.148009]   s2disk-3327    2d... 48550418us : cpus_share_cache <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550418us : _raw_spin_lock <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550419us : ttwu_do_activate.constprop.100 <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550419us : activate_task <-ttwu_do_activate.constprop.100
[  249.148009]   s2disk-3327    2d... 48550419us : enqueue_task <-ttwu_do_activate.constprop.100
[  249.148009]   s2disk-3327    2d... 48550419us : update_rq_clock <-enqueue_task
[  249.148009]   s2disk-3327    2d... 48550419us : enqueue_task_fair <-ttwu_do_activate.constprop.100
[  249.148009]   s2disk-3327    2d... 48550419us : update_curr <-enqueue_task_fair
[  249.148009]   s2disk-3327    2d... 48550420us : update_min_vruntime <-update_curr
[  249.148009]   s2disk-3327    2d... 48550420us : __compute_runnable_contrib.part.55 <-update_entity_load_avg
[  249.148009]   s2disk-3327    2d... 48550420us : update_cfs_rq_blocked_load <-enqueue_task_fair
[  249.148009]   s2disk-3327    2d... 48550420us : account_entity_enqueue <-enqueue_task_fair
[  249.148009]   s2disk-3327    2d... 48550420us : update_cfs_shares <-enqueue_task_fair
[  249.148009]   s2disk-3327    2d... 48550420us : __enqueue_entity <-enqueue_task_fair
[  249.148009]   s2disk-3327    2d... 48550421us : hrtick_update <-ttwu_do_activate.constprop.100
[  249.148009]   s2disk-3327    2d... 48550421us : wq_worker_waking_up <-ttwu_do_activate.constprop.100
[  249.148009]   s2disk-3327    2d... 48550421us : kthread_data <-wq_worker_waking_up
[  249.148009]   s2disk-3327    2d... 48550421us : ttwu_do_wakeup <-try_to_wake_up
[  249.148009]   s2disk-3327    2d... 48550421us : check_preempt_curr <-ttwu_do_wakeup
[  249.148009]   s2disk-3327    2d... 48550421us : check_preempt_wakeup <-check_preempt_curr
[  249.148009]   s2disk-3327    2d... 48550422us : update_curr <-check_preempt_wakeup
[  249.148009]   s2disk-3327    2d... 48550422us : wakeup_preempt_entity.isra.53 <-check_preempt_wakeup
[  249.148009]   s2disk-3327    2d... 48550422us : _raw_spin_unlock_irqrestore <-try_to_wake_up
[  249.148009]   s2disk-3327    2.... 48550423us : bdi_dirty_limit <-bdi_dirty_limits
[  249.148009]   s2disk-3327    2d... 48550423us : _raw_spin_lock_irqsave <-__percpu_counter_sum
[  249.148009]   s2disk-3327    2d... 48550423us : _raw_spin_unlock_irqrestore <-__percpu_counter_sum
[  249.148009]   s2disk-3327    2d... 48550423us : _raw_spin_lock_irqsave <-__percpu_counter_sum
[  249.148009]   s2disk-3327    2d... 48550424us : _raw_spin_unlock_irqrestore <-__percpu_counter_sum
[  249.148009]   s2disk-3327    2.... 48550424us : bdi_position_ratio <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550424us : io_schedule_timeout <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550424us : __delayacct_blkio_start <-io_schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550424us : ktime_get_ts <-io_schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550424us : blk_flush_plug_list <-io_schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550425us : schedule_timeout <-io_schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550425us : lock_timer_base.isra.35 <-__mod_timer
[  249.148009]   s2disk-3327    2.... 48550425us : _raw_spin_lock_irqsave <-lock_timer_base.isra.35
[  249.148009]   s2disk-3327    2d... 48550425us : detach_if_pending <-__mod_timer
[  249.148009]   s2disk-3327    2d... 48550425us : idle_cpu <-__mod_timer
[  249.148009]   s2disk-3327    2d... 48550425us : internal_add_timer <-__mod_timer
[  249.148009]   s2disk-3327    2d... 48550425us : __internal_add_timer <-internal_add_timer
[  249.148009]   s2disk-3327    2d... 48550426us : _raw_spin_unlock_irqrestore <-__mod_timer
[  249.148009]   s2disk-3327    2.... 48550426us : schedule <-schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550426us : __schedule <-schedule_timeout
[  249.148009]   s2disk-3327    2.... 48550426us : rcu_note_context_switch <-__schedule
[  249.148009]   s2disk-3327    2.... 48550426us : rcu_sched_qs <-rcu_note_context_switch
[  249.148009]   s2disk-3327    2.... 48550426us : _raw_spin_lock_irq <-__schedule
[  249.148009]   s2disk-3327    2d... 48550427us : deactivate_task <-__schedule
[  249.148009]   s2disk-3327    2d... 48550427us : dequeue_task <-__schedule
[  249.148009]   s2disk-3327    2d... 48550427us : update_rq_clock <-dequeue_task
[  249.148009]   s2disk-3327    2d... 48550427us : dequeue_task_fair <-__schedule
[  249.148009]   s2disk-3327    2d... 48550427us : update_curr <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550427us : update_min_vruntime <-update_curr
[  249.148009]   s2disk-3327    2d... 48550427us : cpuacct_charge <-update_curr
[  249.148009]   s2disk-3327    2d... 48550428us : update_cfs_rq_blocked_load <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550428us : clear_buddies <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550428us : account_entity_dequeue <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550428us : update_min_vruntime <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550428us : update_cfs_shares <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550428us : update_curr <-update_cfs_shares
[  249.148009]   s2disk-3327    2d... 48550429us : update_min_vruntime <-update_curr
[  249.148009]   s2disk-3327    2d... 48550429us : account_entity_dequeue <-update_cfs_shares
[  249.148009]   s2disk-3327    2d... 48550429us : account_entity_enqueue <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550429us : update_curr <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550429us : update_cfs_rq_blocked_load <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550429us : clear_buddies <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550429us : account_entity_dequeue <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550430us : update_min_vruntime <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550430us : update_cfs_shares <-dequeue_task_fair
[  249.148009]   s2disk-3327    2d... 48550430us : hrtick_update <-__schedule
[  249.148009]   s2disk-3327    2d... 48550430us : put_prev_task_fair <-__schedule
[  249.148009]   s2disk-3327    2d... 48550430us : pick_next_task_fair <-pick_next_task
[  249.148009]   s2disk-3327    2d... 48550430us : clear_buddies <-pick_next_task_fair
[  249.148009]   s2disk-3327    2d... 48550431us : __dequeue_entity <-pick_next_task_fair

but the worker wakeup doesn't actually do anything:

[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread
Quoted 7 lines

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

Thanks,
Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited

but the worker wakeup doesn't actually do anything:

[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 5 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and

just happened to work by chance in the past.

Can we patch suspend-utils as follows? Alternatively, suspend-utils could clear the dirty limits before it starts writing and restore them post-resume.

---

#3 lore raw
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and
just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity window it seems. :-)

Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

That (and the patch too) doesn't seem to address the problem with existing suspend-utils binaries, however.

Rafael

Quoted 26 lines

---
From 73d6546d5e264130e3d108c97d8317f86dc11149 Mon Sep 17 00:00:00 2001
From: Johannes Weiner <[email protected]>
Date: Thu, 12 Jun 2014 17:43:05 -0400
Subject: [patch] s2disk: fix buffered IO throttling deadlock in frozen state

s2disk uses buffered IO when writing the snapshot image to disk. If it runs into the dirty limits, the kernel forces it to wait until the flusher threads clean some of the dirty pages. However, at this point s2disk already froze the system, including the flusher infrastructure, and the whole operation deadlocks.

Open the resume device with O_SYNC to force flushing any dirty pages directly from the write() context before they accumulate and engage dirty throttling.

---
  suspend.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
suspend.c +0 -0
index 479ce58555f7..1b9bed81f58a 100644

suspend.c int main(int argc, char *argv[]) · line 2442

Quoted 8 lines
suspend.c +1 -1
@@ -2436,7 +2436,7 @@ int main(int argc, char *argv[])
  		suspend_error("Could not create %s/%s.", chroot_path, "resume");
  		goto Umount;
  	}
-	resume_fd = open("resume", O_RDWR);
+	resume_fd = open("resume", O_RDWR | O_SYNC);
  	if (resume_fd < 0) {
  		ret = errno;
  		suspend_error("Could not open the resume device.");

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 6 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 7 lines
Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

That (and the patch too) doesn't seem to address the problem with existing suspend-utils
binaries, however.

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw
Quoted 59 lines · Johannes Weiner
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and
just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 8 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

Quoted 7 lines
Quoted 3 lines

That (and the patch too) doesn't seem to address the problem with existing suspend-utils
binaries, however.

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

OK, that sounds like a workable plan.

How do I set those limits to infinity?

Rafael

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#6 lore raw

I cc'ed a bunch of people from bugzilla.

Folks, please please please remember to reply via emailed reply-to-all. Don't use the bugzilla interface!

Quoted 63 lines · On Mon, 16 Jun 2014 18:29:26 +0200 "Rafael J. Wysocki"…
Quoted 62 lines · Johannes Weiner
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and
just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 11 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

That (and the patch too) doesn't seem to address the problem with existing suspend-utils
binaries, however.

Quoted 8 lines
Quoted 4 lines

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

OK, that sounds like a workable plan.

How do I set those limits to infinity?

Five years have passed and people are still hitting this.

Killian described the workaround in comment 14 at
https://bugzilla.kernel.org/show_bug.cgi?id=75101.

People can use this workaround manually by hand or in scripts. But we really should find a proper solution. Maybe special-case the freezing of the flusher threads until all the writeout has completed. Or something else.

#7 lore raw

Wow! Here I am to revive this topic in 2019! I have exactly the same problem, on ubuntu 18.04.2 with basically all kernels since 4.15.0-42 up to 5, which was all I tested, currently on 4.18.0-17-generic... I guess this has nothing to do with the kernel anyway.

It was working fine before, even with proprietary nvidia drivers which would generally cause a bug on the resume and not while saving the ram snapshot. I've been trying to tell this to the ubuntu guys and you can see my whole story with this problem right here:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1819915

Shortly, I tried with or without nvidia modules enabled (or intel or using nouveau), many different kernels, disabled i915, and this is all get in all those different combinations:
https://launchpadlibrarian.net/417327528/i915.jpg

The event is pretty random and seems to be more likely to happen after 2 or 4 gb of ram is ever used (I have 16 in total), and nothing changes if later I reduce the ram usage later. But is random, I successfully hibernated with 11gb in use yesterday, just resumed and hibernated 5 seconds later without doing nothing else than running hibernate, and got freeze there.

This also happens randomly if there's just 3 or 2 gb in use, likely on the second attempt of after more than 5 minutes after the computer is on. What can be wrong here?

Quoted 112 lines · On Tue, Apr 2, 2019, 20:25 Andrew Morton <[email protected]> wrote:

I cc'ed a bunch of people from bugzilla.

Folks, please please please remember to reply via emailed reply-to-all. Don't use the bugzilla interface!

Quoted 11 lines · On Mon, 16 Jun 2014 18:29:26 +0200 "Rafael J. Wysocki" <…
Quoted 10 lines · Johannes Weiner
Quoted 9 lines · Rafael J. Wysocki
Quoted 8 lines · Johannes Weiner
Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Johannes Weiner

Hi Oliver,

Quoted 3 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see

[1]

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in

detail

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us :

global_dirty_limits <-balance_dirty_pages_ratelimited

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[  249.148009]   s2disk-3327    2.... 48550414us :

global_dirtyable_memory <-global_dirty_limits

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[  249.148009]   s2disk-3327    2.... 48550414us :

writeback_in_progress <-balance_dirty_pages_ratelimited

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[  249.148009]   s2disk-3327    2.... 48550414us :

bdi_start_background_writeback <-balance_dirty_pages_ratelimited

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[  249.148009]   s2disk-3327    2.... 48550414us :

mod_delayed_work_on <-balance_dirty_pages_ratelimited

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

but the worker wakeup doesn't actually do anything:

[  249.148009] kworker/-3466    2d... 48550431us :

finish_task_switch <-__schedule

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[  249.148009] kworker/-3466    2.... 48550431us :

_raw_spin_lock_irq <-worker_thread

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[  249.148009] kworker/-3466    2d... 48550431us :

need_to_create_worker <-worker_thread

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[  249.148009] kworker/-3466    2d... 48550432us :

worker_enter_idle <-worker_thread

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[  249.148009] kworker/-3466    2d... 48550432us :

too_many_workers <-worker_enter_idle

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[  249.148009] kworker/-3466    2.... 48550432us : schedule

<-worker_thread

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
[  249.148009] kworker/-3466    2.... 48550432us : __schedule

<-worker_thread

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

My suspicion is that this fails because the bdi_wq is frozen at

this

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

point and so the flush work never runs until resume, whereas

before my

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

patch the effective dirty limit was high enough so that image

could be

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

written in one go without being throttled; followed by an fsync()

that

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

then writes the pages in the context of the unfrozen s2disk.

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model

and

Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
Quoted 1 line

just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 2 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore

them

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

post-resume.

That (and the patch too) doesn't seem to address the problem with

existing

Quoted 10 lines
Quoted 6 lines
Quoted 2 lines

suspend-utils
binaries, however.

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

OK, that sounds like a workable plan.

How do I set those limits to infinity?

Five years have passed and people are still hitting this.

Killian described the workaround in comment 14 at
https://bugzilla.kernel.org/show_bug.cgi?id=75101.

People can use this workaround manually by hand or in scripts. But we really should find a proper solution. Maybe special-case the freezing of the flusher threads until all the writeout has completed. Or something else.

#8 lore raw

Am 03.04.19 um 05:54 schrieb Matheus Fillipe:

Quoted 22 lines

Wow! Here I am to revive this topic in 2019! I have exactly the same problem, on ubuntu 18.04.2 with basically all kernels since 4.15.0-42 up to 5, which was all I tested, currently on 4.18.0-17-generic... I guess this has nothing to do with the kernel anyway.

It was working fine before, even with proprietary nvidia drivers which would generally cause a bug on the resume and not while saving the ram snapshot. I've been trying to tell this to the ubuntu guys and you can see my whole story with this problem right here:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1819915

Shortly, I tried with or without nvidia modules enabled (or intel or using nouveau), many different kernels, disabled i915, and this is all get in all those different combinations:
https://launchpadlibrarian.net/417327528/i915.jpg

The event is pretty random and seems to be more likely to happen after 2 or 4 gb of ram is ever used (I have 16 in total), and nothing changes if later I reduce the ram usage later. But is random, I successfully hibernated with 11gb in use yesterday, just resumed and hibernated 5 seconds later without doing nothing else than running hibernate, and got freeze there.

Quoted 4 lines

This also happens randomly if there's just 3 or 2 gb in use, likely on the second attempt of after more than 5 minutes after the computer is on. What can be wrong here?

The last time that I've encountered this issue was sometime in 2017 under conditions described in Comment 23. And that's true for s2both/s2disk and the kernel-methods.

It seems that you are using the uswsusp package. In that case it might be worth taking a look at the settings in /etc/suspend.conf. What works here is:

#image size = 3500000
early writeout = n
#threads = y

If this doesn't help, you should try hard to figure out what has changed from Ubuntu 18.04.1 to 18.04.2 as it worked with the former for you.

#9 lore raw
In reply to Andrew Morton

Am 03.04.19 um 01:25 schrieb Andrew Morton:

Quoted 5 lines

I cc'ed a bunch of people from bugzilla.

Folks, please please please remember to reply via emailed reply-to-all. Don't use the bugzilla interface!

Do you want this as a general rule? If so, an according message should be displayed after login into Bugzilla. How else would people know?

Regards!

Rainer Fiebig

#10 lore raw
In reply to Andrew Morton
Quoted 82 lines · Andrew Morton

I cc'ed a bunch of people from bugzilla.

Folks, please please please remember to reply via emailed reply-to-all. Don't use the bugzilla interface!

Quoted 63 lines · On Mon, 16 Jun 2014 18:29:26 +0200 "Rafael J. Wysocki"…
Quoted 62 lines · Johannes Weiner
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and
just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 11 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

That (and the patch too) doesn't seem to address the problem with existing suspend-utils
binaries, however.

Quoted 8 lines
Quoted 4 lines

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

OK, that sounds like a workable plan.

How do I set those limits to infinity?

Five years have passed and people are still hitting this.

Quoted 7 lines

Killian described the workaround in comment 14 at
https://bugzilla.kernel.org/show_bug.cgi?id=75101.

People can use this workaround manually by hand or in scripts. But we really should find a proper solution. Maybe special-case the freezing of the flusher threads until all the writeout has completed. Or something else.

I've refreshed my memory wrt this bug and I believe the bug is really on the side of suspend-utils (uswsusp or however it is called). They are low level system tools, they ask the kernel to freeze all processes (SNAPSHOT_FREEZE ioctl), and then they rely on buffered writeback (which is relatively heavyweight infrastructure) to work. That is wrong in my opinion.

I can see Johanness was suggesting in comment 11 to use O_SYNC in suspend-utils which worked but was too slow. Indeed O_SYNC is rather big hammer but using O_DIRECT should be what they need and get better performance - no additional buffering in the kernel, no dirty throttling, etc. They only need their buffer & device offsets sector aligned - they seem to be even page aligned in suspend-utils so they should be fine. And if the performance still sucks (currently they appear to do mostly random 4k writes so it probably would for rotating disks), they could use AIO DIO to get multiple pages in flight (as many as they dare to allocate buffers) and then the IO scheduler will reorder things as good as it can and they should get reasonable performance.

Is there someone who works on suspend-utils these days? Because the repo I've found on kernel.org seems to be long dead (last commit in 2012).

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#11 lore raw

Am 03.04.19 um 11:34 schrieb Jan Kara:

Quoted 110 lines · Andrew Morton
Quoted 82 lines

I cc'ed a bunch of people from bugzilla.

Folks, please please please remember to reply via emailed reply-to-all. Don't use the bugzilla interface!

Quoted 63 lines · On Mon, 16 Jun 2014 18:29:26 +0200 "Rafael J. Wysocki"…
Quoted 62 lines · Johannes Weiner
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and
just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 11 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

That (and the patch too) doesn't seem to address the problem with existing suspend-utils
binaries, however.

Quoted 8 lines
Quoted 4 lines

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

OK, that sounds like a workable plan.

How do I set those limits to infinity?

Five years have passed and people are still hitting this.

Quoted 7 lines

Killian described the workaround in comment 14 at
https://bugzilla.kernel.org/show_bug.cgi?id=75101.

People can use this workaround manually by hand or in scripts. But we really should find a proper solution. Maybe special-case the freezing of the flusher threads until all the writeout has completed. Or something else.

I've refreshed my memory wrt this bug and I believe the bug is really on the side of suspend-utils (uswsusp or however it is called). They are low level system tools, they ask the kernel to freeze all processes (SNAPSHOT_FREEZE ioctl), and then they rely on buffered writeback (which is relatively heavyweight infrastructure) to work. That is wrong in my opinion.

I can see Johanness was suggesting in comment 11 to use O_SYNC in suspend-utils which worked but was too slow. Indeed O_SYNC is rather big hammer but using O_DIRECT should be what they need and get better performance - no additional buffering in the kernel, no dirty throttling, etc. They only need their buffer & device offsets sector aligned - they seem to be even page aligned in suspend-utils so they should be fine. And if the performance still sucks (currently they appear to do mostly random 4k writes so it probably would for rotating disks), they could use AIO DIO to get multiple pages in flight (as many as they dare to allocate buffers) and then the IO scheduler will reorder things as good as it can and they should get reasonable performance.

Quoted 5 lines

Is there someone who works on suspend-utils these days? Because the repo I've found on kernel.org seems to be long dead (last commit in 2012).

Honza

Whether it's suspend-utils (or uswsusp) or not could be answered quickly by de-installing this package and using the kernel-methods instead.

#12 lore raw

Yes I can sorta confirm the bug is in uswsusp. I removed the package and pm-utils and used both "systemctl hibernate" and "echo disk >> /sys/power/state" to hibernate. It seems to succeed and shuts down, I am just not able to resume from it, which seems to be a classical problem solved just by setting the resume swap file/partition on grub. (which i tried and didn't work even with nvidia disabled)

Anyway uswsusp is still necessary because the default kernel hibernation doesn't work with the proprietary nvidia drivers as long as I know and tested.

Is there anyway I could get any workaround to this bug on my current OS by the way?

Quoted 122 lines · Rainer Fiebig

Am 03.04.19 um 11:34 schrieb Jan Kara:

Quoted 110 lines · Andrew Morton
Quoted 82 lines

I cc'ed a bunch of people from bugzilla.

Folks, please please please remember to reply via emailed reply-to-all. Don't use the bugzilla interface!

Quoted 63 lines · On Mon, 16 Jun 2014 18:29:26 +0200 "Rafael J. Wysocki"…
Quoted 62 lines · Johannes Weiner
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and
just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 11 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

That (and the patch too) doesn't seem to address the problem with existing suspend-utils
binaries, however.

Quoted 8 lines
Quoted 4 lines

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

OK, that sounds like a workable plan.

How do I set those limits to infinity?

Five years have passed and people are still hitting this.

Quoted 7 lines

Killian described the workaround in comment 14 at
https://bugzilla.kernel.org/show_bug.cgi?id=75101.

People can use this workaround manually by hand or in scripts. But we really should find a proper solution. Maybe special-case the freezing of the flusher threads until all the writeout has completed. Or something else.

I've refreshed my memory wrt this bug and I believe the bug is really on the side of suspend-utils (uswsusp or however it is called). They are low level system tools, they ask the kernel to freeze all processes (SNAPSHOT_FREEZE ioctl), and then they rely on buffered writeback (which is relatively heavyweight infrastructure) to work. That is wrong in my opinion.

I can see Johanness was suggesting in comment 11 to use O_SYNC in suspend-utils which worked but was too slow. Indeed O_SYNC is rather big hammer but using O_DIRECT should be what they need and get better performance - no additional buffering in the kernel, no dirty throttling, etc. They only need their buffer & device offsets sector aligned - they seem to be even page aligned in suspend-utils so they should be fine. And if the performance still sucks (currently they appear to do mostly random 4k writes so it probably would for rotating disks), they could use AIO DIO to get multiple pages in flight (as many as they dare to allocate buffers) and then the IO scheduler will reorder things as good as it can and they should get reasonable performance.

Quoted 5 lines

Is there someone who works on suspend-utils these days? Because the repo I've found on kernel.org seems to be long dead (last commit in 2012).

Honza

Whether it's suspend-utils (or uswsusp) or not could be answered quickly by de-installing this package and using the kernel-methods instead.

#13 lore raw

Am 03.04.19 um 18:59 schrieb Matheus Fillipe:

Quoted 2 lines

Yes I can sorta confirm the bug is in uswsusp. I removed the package and pm-utils

Matheus,

there is no need to uninstall pm-utils. You actually need this to have comfortable suspend/hibernate.

The only additional option you will get from uswsusp is true s2both (which is nice, imo).

pm-utils provides something similar called "suspend-hybrid" which means that the computer suspends and after a configurable time wakes up again to go into hibernation.

and used both "systemctl hibernate" and "echo disk >>

Quoted 8 lines

/sys/power/state" to hibernate. It seems to succeed and shuts down, I am just not able to resume from it, which seems to be a classical problem solved just by setting the resume swap file/partition on grub. (which i tried and didn't work even with nvidia disabled)

Anyway uswsusp is still necessary because the default kernel hibernation doesn't work with the proprietary nvidia drivers as long as I know and tested.

What doesn't work: hibernating or resuming?
And /var/log/pm-suspend.log might give you a clue what causes the problem.

Quoted 3 lines

Is there anyway I could get any workaround to this bug on my current OS by the way?

*I* don't know, I don't use Ubuntu. But what I would do now is re-install pm-utils *without* uswsusp and make sure that you have got the swap-partition/file right in grub.cfg or menu.lst (grub legacy).

Then do a few pm-hibernate/resume and tell us what happened.

So long!

Quoted 124 lines · Rainer Fiebig
Quoted 122 lines

Am 03.04.19 um 11:34 schrieb Jan Kara:

Quoted 110 lines · Andrew Morton
Quoted 82 lines

I cc'ed a bunch of people from bugzilla.

Folks, please please please remember to reply via emailed reply-to-all. Don't use the bugzilla interface!

Quoted 63 lines · On Mon, 16 Jun 2014 18:29:26 +0200 "Rafael J. Wysocki"…
Quoted 62 lines · Johannes Weiner
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and
just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 11 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

That (and the patch too) doesn't seem to address the problem with existing suspend-utils
binaries, however.

Quoted 8 lines
Quoted 4 lines

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

OK, that sounds like a workable plan.

How do I set those limits to infinity?

Five years have passed and people are still hitting this.

Quoted 7 lines

Killian described the workaround in comment 14 at
https://bugzilla.kernel.org/show_bug.cgi?id=75101.

People can use this workaround manually by hand or in scripts. But we really should find a proper solution. Maybe special-case the freezing of the flusher threads until all the writeout has completed. Or something else.

I've refreshed my memory wrt this bug and I believe the bug is really on the side of suspend-utils (uswsusp or however it is called). They are low level system tools, they ask the kernel to freeze all processes (SNAPSHOT_FREEZE ioctl), and then they rely on buffered writeback (which is relatively heavyweight infrastructure) to work. That is wrong in my opinion.

I can see Johanness was suggesting in comment 11 to use O_SYNC in suspend-utils which worked but was too slow. Indeed O_SYNC is rather big hammer but using O_DIRECT should be what they need and get better performance - no additional buffering in the kernel, no dirty throttling, etc. They only need their buffer & device offsets sector aligned - they seem to be even page aligned in suspend-utils so they should be fine. And if the performance still sucks (currently they appear to do mostly random 4k writes so it probably would for rotating disks), they could use AIO DIO to get multiple pages in flight (as many as they dare to allocate buffers) and then the IO scheduler will reorder things as good as it can and they should get reasonable performance.

Quoted 5 lines

Is there someone who works on suspend-utils these days? Because the repo I've found on kernel.org seems to be long dead (last commit in 2012).

Honza

Whether it's suspend-utils (or uswsusp) or not could be answered quickly by de-installing this package and using the kernel-methods instead.

#14 lore raw

Okay, I reinstalled pm-utils and make sure uswsusp was removed (apt remove --purge uswsusp).

# fdisk -l |  grep swap
/dev/sda8  439762944 473214975  33452032    16G Linux swap
root@matheus-Inspiron-15-7000-Gaming:/home/matheus# blkid /dev/sda8
/dev/sda8: UUID="70d967e6-ad52-4c21-baf0-01a813ccc6ac" TYPE="swap"
PARTUUID="666096bb-0e72-431a-b981-9fd0c7e553ee"

I have resume=70d967e6-ad52-4c21-baf0-01a813ccc6ac variable set in all linux comamnd kernel (GRUB_CMDLINE_LINUX_DEFAULT) as you can see on my attached boot-sequence. You can see more info about my setup and what I already did here:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1819915

Quoted 2 lines

What doesn't work: hibernating or resuming?
And /var/log/pm-suspend.log might give you a clue what causes the problem.

Resuming doesn't work and still don't work.I tried setting either my partition to /dev/sda8 or the uiid. It simply boots as if it was the fist boot.

Quoted 34 lines · Rainer Fiebig

Am 03.04.19 um 18:59 schrieb Matheus Fillipe:

Quoted 2 lines

Yes I can sorta confirm the bug is in uswsusp. I removed the package and pm-utils

Matheus,

there is no need to uninstall pm-utils. You actually need this to have comfortable suspend/hibernate.

The only additional option you will get from uswsusp is true s2both (which is nice, imo).

pm-utils provides something similar called "suspend-hybrid" which means that the computer suspends and after a configurable time wakes up again to go into hibernation.

and used both "systemctl hibernate" and "echo disk >>

Quoted 8 lines

/sys/power/state" to hibernate. It seems to succeed and shuts down, I am just not able to resume from it, which seems to be a classical problem solved just by setting the resume swap file/partition on grub. (which i tried and didn't work even with nvidia disabled)

Anyway uswsusp is still necessary because the default kernel hibernation doesn't work with the proprietary nvidia drivers as long as I know and tested.

What doesn't work: hibernating or resuming?
And /var/log/pm-suspend.log might give you a clue what causes the problem.

Quoted 3 lines

Is there anyway I could get any workaround to this bug on my current OS by the way?

Quoted 134 lines

*I* don't know, I don't use Ubuntu. But what I would do now is re-install pm-utils *without* uswsusp and make sure that you have got the swap-partition/file right in grub.cfg or menu.lst (grub legacy).

Then do a few pm-hibernate/resume and tell us what happened.

So long!

Quoted 124 lines · Rainer Fiebig
Quoted 122 lines

Am 03.04.19 um 11:34 schrieb Jan Kara:

Quoted 110 lines · Andrew Morton
Quoted 82 lines

I cc'ed a bunch of people from bugzilla.

Folks, please please please remember to reply via emailed reply-to-all. Don't use the bugzilla interface!

Quoted 63 lines · On Mon, 16 Jun 2014 18:29:26 +0200 "Rafael J. Wysocki"…
Quoted 62 lines · Johannes Weiner
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and
just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 11 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

That (and the patch too) doesn't seem to address the problem with existing suspend-utils
binaries, however.

Quoted 8 lines
Quoted 4 lines

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

OK, that sounds like a workable plan.

How do I set those limits to infinity?

Five years have passed and people are still hitting this.

Quoted 7 lines

Killian described the workaround in comment 14 at
https://bugzilla.kernel.org/show_bug.cgi?id=75101.

People can use this workaround manually by hand or in scripts. But we really should find a proper solution. Maybe special-case the freezing of the flusher threads until all the writeout has completed. Or something else.

I've refreshed my memory wrt this bug and I believe the bug is really on the side of suspend-utils (uswsusp or however it is called). They are low level system tools, they ask the kernel to freeze all processes (SNAPSHOT_FREEZE ioctl), and then they rely on buffered writeback (which is relatively heavyweight infrastructure) to work. That is wrong in my opinion.

I can see Johanness was suggesting in comment 11 to use O_SYNC in suspend-utils which worked but was too slow. Indeed O_SYNC is rather big hammer but using O_DIRECT should be what they need and get better performance - no additional buffering in the kernel, no dirty throttling, etc. They only need their buffer & device offsets sector aligned - they seem to be even page aligned in suspend-utils so they should be fine. And if the performance still sucks (currently they appear to do mostly random 4k writes so it probably would for rotating disks), they could use AIO DIO to get multiple pages in flight (as many as they dare to allocate buffers) and then the IO scheduler will reorder things as good as it can and they should get reasonable performance.

Quoted 5 lines

Is there someone who works on suspend-utils these days? Because the repo I've found on kernel.org seems to be long dead (last commit in 2012).

Honza

Whether it's suspend-utils (or uswsusp) or not could be answered quickly by de-installing this package and using the kernel-methods instead.

Initial commandline parameters:
qua abr 3 13:02:38 -03 2019: Running hooks for hibernate. Running hook /usr/lib/pm-utils/sleep.d/000kernel-change hibernate hibernate:
/usr/lib/pm-utils/sleep.d/000kernel-change hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/000record-status hibernate hibernate:
/usr/lib/pm-utils/sleep.d/000record-status hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/00logging hibernate hibernate:
Linux matheus-Inspiron-15-7000-Gaming 4.18.0-17-generic #18~18.04.1-Ubuntu SMP Fri Mar 15 15:27:12 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Module                  Size  Used by
rfcomm                 77824  4
iptable_filter         16384  0
bpfilter               16384  0
ccm                    20480  6
pci_stub               16384  1
vboxpci                24576  0
vboxnetadp             28672  0
vboxnetflt             28672  0
vboxdrv               487424  3 vboxpci,vboxnetadp,vboxnetflt
cmac                   16384  1
bnep                   20480  2
bridge                159744  0
stp                    16384  1 bridge
llc                    16384  2 bridge,stp
binfmt_misc            20480  1
nls_iso8859_1          16384  1
arc4                   16384  2
hid_multitouch         20480  0
intel_rapl             20480  0
x86_pkg_temp_thermal    16384  0
intel_powerclamp       16384  0
dell_smm_hwmon         16384  0
coretemp               16384  0
dell_laptop            20480  1
kvm_intel             208896  0
kvm                   626688  1 kvm_intel
irqbypass              16384  1 kvm
crct10dif_pclmul       16384  0
snd_usb_audio         225280  3
crc32_pclmul           16384  0
snd_hda_codec_realtek   106496  1
ghash_clmulni_intel    16384  0
snd_usbmidi_lib        32768  1 snd_usb_audio
snd_hda_codec_generic    73728  1 snd_hda_codec_realtek
pcbc                   16384  0
aesni_intel           200704  6
uvcvideo               94208  0
aes_x86_64             20480  1 aesni_intel
videobuf2_vmalloc      16384  1 uvcvideo
crypto_simd            16384  1 aesni_intel
videobuf2_memops       16384  1 videobuf2_vmalloc
snd_hda_intel          40960  3
cryptd                 24576  3 crypto_simd,ghash_clmulni_intel,aesni_intel
videobuf2_v4l2         24576  1 uvcvideo
glue_helper            16384  1 aesni_intel
snd_hda_codec         126976  3 snd_hda_codec_generic,snd_hda_intel,snd_hda_codec_realtek
videobuf2_common       40960  2 videobuf2_v4l2,uvcvideo
btusb                  45056  0
videodev              188416  3 videobuf2_v4l2,uvcvideo,videobuf2_common
btrtl                  16384  1 btusb
snd_hda_core           81920  4 snd_hda_codec_generic,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek
btbcm                  16384  1 btusb
media                  40960  2 videodev,uvcvideo
btintel                20480  1 btusb
snd_hwdep              20480  2 snd_usb_audio,snd_hda_codec
bluetooth             552960  33 btrtl,btintel,btbcm,bnep,btusb,rfcomm
snd_pcm                98304  5 snd_hda_intel,snd_usb_audio,snd_hda_codec,snd_hda_core
ecdh_generic           24576  2 bluetooth
snd_seq_midi           16384  0
ath10k_pci             40960  0
snd_seq_midi_event     16384  1 snd_seq_midi
snd_rawmidi            32768  2 snd_seq_midi,snd_usbmidi_lib
ath10k_core           417792  1 ath10k_pci
ath                    32768  1 ath10k_core
intel_cstate           20480  0
snd_seq                65536  2 snd_seq_midi,snd_seq_midi_event
mac80211              802816  1 ath10k_core
intel_rapl_perf        16384  0
cfg80211              667648  3 ath,mac80211,ath10k_core
snd_seq_device         16384  3 snd_seq,snd_seq_midi,snd_rawmidi
snd_timer              32768  2 snd_seq,snd_pcm
idma64                 20480  0
virt_dma               16384  1 idma64
dell_wmi               16384  0
snd                    81920  23 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_pcm,snd_rawmidi
dell_smbios            24576  2 dell_wmi,dell_laptop
intel_lpss_pci         20480  0
soundcore              16384  1 snd
dcdbas                 16384  1 dell_smbios
mei_me                 40960  0
intel_lpss             16384  1 intel_lpss_pci
joydev                 24576  0
input_leds             16384  0
mei                    98304  1 mei_me
dell_wmi_descriptor    16384  2 dell_wmi,dell_smbios
wmi_bmof               16384  0
serio_raw              16384  0
intel_pch_thermal      16384  0
int3403_thermal        16384  0
int3400_thermal        16384  0
processor_thermal_device    16384  0
acpi_thermal_rel       16384  1 int3400_thermal
mac_hid                16384  0
intel_soc_dts_iosf     16384  1 processor_thermal_device
int3402_thermal        16384  0
intel_hid              16384  0
int340x_thermal_zone    16384  3 int3403_thermal,int3402_thermal,processor_thermal_device
sparse_keymap          16384  2 intel_hid,dell_wmi
acpi_pad              180224  0
sch_fq_codel           20480  2
nvidia_uvm            798720  0
vhci_hcd               49152  0
usbip_core             32768  1 vhci_hcd
parport_pc             36864  0
ppdev                  20480  0
lp                     20480  0
sunrpc                352256  1
parport                49152  3 parport_pc,lp,ppdev
binder_linux          102400  0
ashmem_linux           16384  0
ip_tables              28672  1 iptable_filter
x_tables               40960  2 iptable_filter,ip_tables
autofs4                40960  2
btrfs                1163264  0
zstd_compress         163840  1 btrfs
raid10                 53248  0
raid456               151552  0
async_raid6_recov      20480  1 raid456
async_memcpy           16384  2 raid456,async_raid6_recov
async_pq               16384  2 raid456,async_raid6_recov
async_xor              16384  3 async_pq,raid456,async_raid6_recov
async_tx               16384  5 async_pq,async_memcpy,async_xor,raid456,async_raid6_recov
xor                    24576  2 async_xor,btrfs
raid6_pq              114688  4 async_pq,btrfs,raid456,async_raid6_recov
libcrc32c              16384  2 btrfs,raid456
raid1                  40960  0
raid0                  20480  0
multipath              16384  0
linear                 16384  0
dm_mirror              24576  0
dm_region_hash         20480  1 dm_mirror
dm_log                 20480  2 dm_region_hash,dm_mirror
hid_generic            16384  0
usbhid                 49152  0
nvidia_drm             40960  3
nvidia_modeset       1085440  3 nvidia_drm
nvidia              17600512  105 nvidia_uvm,nvidia_modeset
i915                 1740800  3
mxm_wmi                16384  0
i2c_algo_bit           16384  1 i915
drm_kms_helper        172032  2 nvidia_drm,i915
syscopyarea            16384  1 drm_kms_helper
sysfillrect            16384  1 drm_kms_helper
sysimgblt              16384  1 drm_kms_helper
fb_sys_fops            16384  1 drm_kms_helper
r8169                  86016  0
psmouse               151552  0
drm                   458752  7 drm_kms_helper,nvidia_drm,i915
ipmi_devintf           20480  0
mii                    16384  1 r8169
ahci                   40960  5
i2c_hid                20480  0
ipmi_msghandler       102400  2 ipmi_devintf,nvidia
libahci                32768  1 ahci
hid                   122880  4 i2c_hid,usbhid,hid_multitouch,hid_generic
wmi                    24576  5 dell_wmi,wmi_bmof,dell_smbios,dell_wmi_descriptor,mxm_wmi
video                  45056  3 dell_wmi,dell_laptop,i915
              total        used        free      shared  buff/cache   available
Mem:       16288036      844604    13847012       37908     1596420    15112004
Swap:      16726012           0    16726012

/usr/lib/pm-utils/sleep.d/00logging hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/00powersave hibernate hibernate:
/usr/lib/pm-utils/sleep.d/00powersave hibernate hibernate: success.

Running hook /etc/pm/sleep.d/10_grub-common hibernate hibernate:
/etc/pm/sleep.d/10_grub-common hibernate hibernate: success.

Running hook /etc/pm/sleep.d/10_unattended-upgrades-hibernate hibernate hibernate:
/etc/pm/sleep.d/10_unattended-upgrades-hibernate hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/20tuxonice hibernate hibernate:
/usr/lib/pm-utils/sleep.d/20tuxonice hibernate hibernate: not applicable.

Running hook /usr/lib/pm-utils/sleep.d/40inputattach hibernate hibernate:
/usr/lib/pm-utils/sleep.d/40inputattach hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/50unload_alx hibernate hibernate:
/usr/lib/pm-utils/sleep.d/50unload_alx hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/60_wpa_supplicant hibernate hibernate:
Selected interface 'p2p-dev-wlp3s0'
OK
/usr/lib/pm-utils/sleep.d/60_wpa_supplicant hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/75modules hibernate hibernate:
/usr/lib/pm-utils/sleep.d/75modules hibernate hibernate: not applicable.

Running hook /usr/lib/pm-utils/sleep.d/90clock hibernate hibernate:
/usr/lib/pm-utils/sleep.d/90clock hibernate hibernate: not applicable.

Running hook /usr/lib/pm-utils/sleep.d/94cpufreq hibernate hibernate:
/usr/lib/pm-utils/sleep.d/94cpufreq hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/95anacron hibernate hibernate:
Warning: Stopping anacron.service, but it can still be activated by:
anacron.timer
/usr/lib/pm-utils/sleep.d/95anacron hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/95hdparm-apm hibernate hibernate:
/usr/lib/pm-utils/sleep.d/95hdparm-apm hibernate hibernate: not applicable.

Running hook /usr/lib/pm-utils/sleep.d/95led hibernate hibernate:
/usr/lib/pm-utils/sleep.d/95led hibernate hibernate: not applicable.

Running hook /usr/lib/pm-utils/sleep.d/98video-quirk-db-handler hibernate hibernate:
Kernel modesetting video driver detected, not using quirks. /usr/lib/pm-utils/sleep.d/98video-quirk-db-handler hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/999mounta hibernate hibernate:
/usr/lib/pm-utils/sleep.d/999mounta hibernate hibernate: success.

Running hook /etc/pm/sleep.d/99_hibernate_scripts hibernate hibernate:
/etc/pm/sleep.d/99_hibernate_scripts hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/99video hibernate hibernate:
/usr/lib/pm-utils/sleep.d/99video hibernate hibernate: success.

qua abr 3 13:02:38 -03 2019: performing hibernate
Initial commandline parameters:
qua abr 3 15:24:51 -03 2019: Running hooks for hibernate. Running hook /usr/lib/pm-utils/sleep.d/000kernel-change hibernate hibernate:
/usr/lib/pm-utils/sleep.d/000kernel-change hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/000record-status hibernate hibernate:
/usr/lib/pm-utils/sleep.d/000record-status hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/00logging hibernate hibernate:
Linux matheus-Inspiron-15-7000-Gaming 4.18.0-17-generic #18~18.04.1-Ubuntu SMP Fri Mar 15 15:27:12 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Module                  Size  Used by
tcp_diag               16384  0
inet_diag              24576  1 tcp_diag
unix_diag              16384  0
snd_seq_dummy          16384  0
rfcomm                 77824  16
iptable_filter         16384  0
bpfilter               16384  0
ccm                    20480  6
pci_stub               16384  1
vboxpci                24576  0
vboxnetadp             28672  0
vboxnetflt             28672  0
cmac                   16384  1
vboxdrv               487424  3 vboxpci,vboxnetadp,vboxnetflt
bnep                   20480  2
bridge                159744  0
stp                    16384  1 bridge
llc                    16384  2 bridge,stp
binfmt_misc            20480  1
nls_iso8859_1          16384  1
arc4                   16384  2
hid_multitouch         20480  0
intel_rapl             20480  0
dell_laptop            20480  1
x86_pkg_temp_thermal    16384  0
dell_smm_hwmon         16384  0
intel_powerclamp       16384  0
coretemp               16384  0
uvcvideo               94208  0
kvm_intel             208896  0
snd_hda_codec_realtek   106496  1
snd_hda_codec_generic    73728  1 snd_hda_codec_realtek
kvm                   626688  1 kvm_intel
videobuf2_vmalloc      16384  1 uvcvideo
irqbypass              16384  1 kvm
videobuf2_memops       16384  1 videobuf2_vmalloc
videobuf2_v4l2         24576  1 uvcvideo
crct10dif_pclmul       16384  0
videobuf2_common       40960  2 videobuf2_v4l2,uvcvideo
crc32_pclmul           16384  0
videodev              188416  3 videobuf2_v4l2,uvcvideo,videobuf2_common
snd_hda_intel          40960  6
ghash_clmulni_intel    16384  0
pcbc                   16384  0
snd_usb_audio         225280  4
snd_hda_codec         126976  3 snd_hda_codec_generic,snd_hda_intel,snd_hda_codec_realtek
btusb                  45056  0
media                  40960  2 videodev,uvcvideo
btrtl                  16384  1 btusb
snd_usbmidi_lib        32768  1 snd_usb_audio
snd_hda_core           81920  4 snd_hda_codec_generic,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek
btbcm                  16384  1 btusb
aesni_intel           200704  6
btintel                20480  1 btusb
snd_hwdep              20480  2 snd_usb_audio,snd_hda_codec
bluetooth             552960  43 btrtl,btintel,btbcm,bnep,btusb,rfcomm
snd_pcm                98304  8 snd_hda_intel,snd_usb_audio,snd_hda_codec,snd_hda_core
aes_x86_64             20480  1 aesni_intel
crypto_simd            16384  1 aesni_intel
ecdh_generic           24576  2 bluetooth
ath10k_pci             40960  0
cryptd                 24576  3 crypto_simd,ghash_clmulni_intel,aesni_intel
ath10k_core           417792  1 ath10k_pci
glue_helper            16384  1 aesni_intel
snd_seq_midi           16384  0
snd_seq_midi_event     16384  1 snd_seq_midi
ath                    32768  1 ath10k_core
intel_cstate           20480  0
snd_rawmidi            32768  2 snd_seq_midi,snd_usbmidi_lib
intel_rapl_perf        16384  0
mac80211              802816  1 ath10k_core
snd_seq                65536  9 snd_seq_midi,snd_seq_midi_event,snd_seq_dummy
snd_seq_device         16384  3 snd_seq,snd_seq_midi,snd_rawmidi
joydev                 24576  0
snd_timer              32768  2 snd_seq,snd_pcm
input_leds             16384  0
dell_wmi               16384  0
serio_raw              16384  0
cfg80211              667648  3 ath,mac80211,ath10k_core
idma64                 20480  0
dell_smbios            24576  2 dell_wmi,dell_laptop
snd                    81920  32 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_pcm,snd_rawmidi
virt_dma               16384  1 idma64
dcdbas                 16384  1 dell_smbios
mei_me                 40960  0
wmi_bmof               16384  0
soundcore              16384  1 snd
intel_lpss_pci         20480  0
dell_wmi_descriptor    16384  2 dell_wmi,dell_smbios
mei                    98304  1 mei_me
processor_thermal_device    16384  0
intel_lpss             16384  1 intel_lpss_pci
intel_soc_dts_iosf     16384  1 processor_thermal_device
intel_pch_thermal      16384  0
int3403_thermal        16384  0
intel_hid              16384  0
int3400_thermal        16384  0
sparse_keymap          16384  2 intel_hid,dell_wmi
acpi_thermal_rel       16384  1 int3400_thermal
int3402_thermal        16384  0
int340x_thermal_zone    16384  3 int3403_thermal,int3402_thermal,processor_thermal_device
mac_hid                16384  0
acpi_pad              180224  0
sch_fq_codel           20480  2
nvidia_uvm            798720  0
vhci_hcd               49152  0
usbip_core             32768  1 vhci_hcd
parport_pc             36864  0
ppdev                  20480  0
lp                     20480  0
sunrpc                352256  1
parport                49152  3 parport_pc,lp,ppdev
binder_linux          102400  0
ashmem_linux           16384  0
ip_tables              28672  1 iptable_filter
x_tables               40960  2 iptable_filter,ip_tables
autofs4                40960  2
btrfs                1163264  0
zstd_compress         163840  1 btrfs
raid10                 53248  0
raid456               151552  0
async_raid6_recov      20480  1 raid456
async_memcpy           16384  2 raid456,async_raid6_recov
async_pq               16384  2 raid456,async_raid6_recov
async_xor              16384  3 async_pq,raid456,async_raid6_recov
async_tx               16384  5 async_pq,async_memcpy,async_xor,raid456,async_raid6_recov
xor                    24576  2 async_xor,btrfs
raid6_pq              114688  4 async_pq,btrfs,raid456,async_raid6_recov
libcrc32c              16384  2 btrfs,raid456
raid1                  40960  0
raid0                  20480  0
multipath              16384  0
linear                 16384  0
dm_mirror              24576  0
dm_region_hash         20480  1 dm_mirror
dm_log                 20480  2 dm_region_hash,dm_mirror
hid_generic            16384  0
usbhid                 49152  0
nvidia_drm             40960  13
nvidia_modeset       1085440  33 nvidia_drm
nvidia              17600512  1683 nvidia_uvm,nvidia_modeset
i915                 1740800  3
mxm_wmi                16384  0
i2c_algo_bit           16384  1 i915
drm_kms_helper        172032  2 nvidia_drm,i915
syscopyarea            16384  1 drm_kms_helper
sysfillrect            16384  1 drm_kms_helper
sysimgblt              16384  1 drm_kms_helper
fb_sys_fops            16384  1 drm_kms_helper
psmouse               151552  0
drm                   458752  16 drm_kms_helper,nvidia_drm,i915
r8169                  86016  0
ahci                   40960  5
ipmi_devintf           20480  0
mii                    16384  1 r8169
libahci                32768  1 ahci
ipmi_msghandler       102400  2 ipmi_devintf,nvidia
i2c_hid                20480  0
hid                   122880  4 i2c_hid,usbhid,hid_multitouch,hid_generic
wmi                    24576  5 dell_wmi,wmi_bmof,dell_smbios,dell_wmi_descriptor,mxm_wmi
video                  45056  3 dell_wmi,dell_laptop,i915
              total        used        free      shared  buff/cache   available
Mem:       16288036     8226200     1094072      543812     6967764     7254512
Swap:      16726012           0    16726012

/usr/lib/pm-utils/sleep.d/00logging hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/00powersave hibernate hibernate:
/usr/lib/pm-utils/sleep.d/00powersave hibernate hibernate: success.

Running hook /etc/pm/sleep.d/10_grub-common hibernate hibernate:
/etc/pm/sleep.d/10_grub-common hibernate hibernate: success.

Running hook /etc/pm/sleep.d/10_unattended-upgrades-hibernate hibernate hibernate:
/etc/pm/sleep.d/10_unattended-upgrades-hibernate hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/20tuxonice hibernate hibernate:
/usr/lib/pm-utils/sleep.d/20tuxonice hibernate hibernate: not applicable.

Running hook /usr/lib/pm-utils/sleep.d/40inputattach hibernate hibernate:
/usr/lib/pm-utils/sleep.d/40inputattach hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/50unload_alx hibernate hibernate:
/usr/lib/pm-utils/sleep.d/50unload_alx hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/60_wpa_supplicant hibernate hibernate:
Selected interface 'p2p-dev-wlp3s0'
OK
/usr/lib/pm-utils/sleep.d/60_wpa_supplicant hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/75modules hibernate hibernate:
/usr/lib/pm-utils/sleep.d/75modules hibernate hibernate: not applicable.

Running hook /usr/lib/pm-utils/sleep.d/90clock hibernate hibernate:
/usr/lib/pm-utils/sleep.d/90clock hibernate hibernate: not applicable.

Running hook /usr/lib/pm-utils/sleep.d/94cpufreq hibernate hibernate:
/usr/lib/pm-utils/sleep.d/94cpufreq hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/95anacron hibernate hibernate:
Warning: Stopping anacron.service, but it can still be activated by:
anacron.timer
/usr/lib/pm-utils/sleep.d/95anacron hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/95hdparm-apm hibernate hibernate:
/usr/lib/pm-utils/sleep.d/95hdparm-apm hibernate hibernate: not applicable.

Running hook /usr/lib/pm-utils/sleep.d/95led hibernate hibernate:
/usr/lib/pm-utils/sleep.d/95led hibernate hibernate: not applicable.

Running hook /usr/lib/pm-utils/sleep.d/98video-quirk-db-handler hibernate hibernate:
Kernel modesetting video driver detected, not using quirks. /usr/lib/pm-utils/sleep.d/98video-quirk-db-handler hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/999mounta hibernate hibernate:
/usr/lib/pm-utils/sleep.d/999mounta hibernate hibernate: success.

Running hook /etc/pm/sleep.d/99_hibernate_scripts hibernate hibernate:
/etc/pm/sleep.d/99_hibernate_scripts hibernate hibernate: success.

Running hook /usr/lib/pm-utils/sleep.d/99video hibernate hibernate:
/usr/lib/pm-utils/sleep.d/99video hibernate hibernate: success.

qua abr 3 15:24:51 -03 2019: performing hibernate

A message that is not in the archive (sent off-list or not yet received): CAFWuBvfxS0S6me_pneXmNzKwObSRUOg08_7=YToAoBg53UtPKg@mail.gmail.com

#16 lore raw

Am 03.04.19 um 22:05 schrieb Matheus Fillipe:

Quoted 11 lines

Okay I found a way to get it working and there was also a huge mistake on my last boot-config, the resume was commented :P
I basically followed this: https://askubuntu.com/a/1064114
but changed to:
resume=/dev/disk/by-uuid/70d967e6-ad52-4c21-baf0-01a813ccc6ac (just the uuid wouldnt work) and this is probably the most important thing to do.it worked!
I also set the resume variable in initramfs to my swap partition but this might nor be so important anyway since it's automatically detected.

Quoted 173 lines

I tested both systemctl hibernate and pm-hibernate, i guess they call the same thing anyway. I attached a screenshot. Seems to be working fine without uswsusp and with nvidia proprietary drivers!

Quoted 168 lines · Rainer Fiebig

Am 03.04.19 um 18:59 schrieb Matheus Fillipe:

Quoted 2 lines

Yes I can sorta confirm the bug is in uswsusp. I removed the package and pm-utils

Matheus,

there is no need to uninstall pm-utils. You actually need this to have comfortable suspend/hibernate.

The only additional option you will get from uswsusp is true s2both (which is nice, imo).

pm-utils provides something similar called "suspend-hybrid" which means that the computer suspends and after a configurable time wakes up again to go into hibernation.

and used both "systemctl hibernate" and "echo disk >>

Quoted 8 lines

/sys/power/state" to hibernate. It seems to succeed and shuts down, I am just not able to resume from it, which seems to be a classical problem solved just by setting the resume swap file/partition on grub. (which i tried and didn't work even with nvidia disabled)

Anyway uswsusp is still necessary because the default kernel hibernation doesn't work with the proprietary nvidia drivers as long as I know and tested.

What doesn't work: hibernating or resuming?
And /var/log/pm-suspend.log might give you a clue what causes the problem.

Quoted 3 lines

Is there anyway I could get any workaround to this bug on my current OS by the way?

*I* don't know, I don't use Ubuntu. But what I would do now is re-install pm-utils *without* uswsusp and make sure that you have got the swap-partition/file right in grub.cfg or menu.lst (grub legacy).

Then do a few pm-hibernate/resume and tell us what happened.

So long!

Quoted 124 lines · Rainer Fiebig
Quoted 122 lines

Am 03.04.19 um 11:34 schrieb Jan Kara:

Quoted 110 lines · Andrew Morton
Quoted 82 lines

I cc'ed a bunch of people from bugzilla.

Folks, please please please remember to reply via emailed reply-to-all. Don't use the bugzilla interface!

Quoted 63 lines · On Mon, 16 Jun 2014 18:29:26 +0200 "Rafael J. Wysocki"…
Quoted 62 lines · Johannes Weiner
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1]
attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail
Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and
just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 11 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

That (and the patch too) doesn't seem to address the problem with existing suspend-utils
binaries, however.

Quoted 8 lines
Quoted 4 lines

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

OK, that sounds like a workable plan.

How do I set those limits to infinity?

Five years have passed and people are still hitting this.

Quoted 7 lines

Killian described the workaround in comment 14 at
https://bugzilla.kernel.org/show_bug.cgi?id=75101.

People can use this workaround manually by hand or in scripts. But we really should find a proper solution. Maybe special-case the freezing of the flusher threads until all the writeout has completed. Or something else.

I've refreshed my memory wrt this bug and I believe the bug is really on the side of suspend-utils (uswsusp or however it is called). They are low level system tools, they ask the kernel to freeze all processes (SNAPSHOT_FREEZE ioctl), and then they rely on buffered writeback (which is relatively heavyweight infrastructure) to work. That is wrong in my opinion.

I can see Johanness was suggesting in comment 11 to use O_SYNC in suspend-utils which worked but was too slow. Indeed O_SYNC is rather big hammer but using O_DIRECT should be what they need and get better performance - no additional buffering in the kernel, no dirty throttling, etc. They only need their buffer & device offsets sector aligned - they seem to be even page aligned in suspend-utils so they should be fine. And if the performance still sucks (currently they appear to do mostly random 4k writes so it probably would for rotating disks), they could use AIO DIO to get multiple pages in flight (as many as they dare to allocate buffers) and then the IO scheduler will reorder things as good as it can and they should get reasonable performance.

Quoted 5 lines

Is there someone who works on suspend-utils these days? Because the repo I've found on kernel.org seems to be long dead (last commit in 2012).

Honza

Whether it's suspend-utils (or uswsusp) or not could be answered quickly by de-installing this package and using the kernel-methods instead.

So you got hibernate working now with pm-utils *and* the prop. Nvidia drivers. That's good - although a bit contrary to what you said in Comment 29:

Quoted 3 lines

Anyway uswsusp is still necessary because the default kernel hibernation doesn't work with the proprietary nvidia drivers as long as I know and tested

Never mind. Stick with it if you don't need s2both.

What still puzzles me is that while others are having problems, suspend-utils/uswsusp work for me almost 100 % of the time, except for a few extreme test-cases in the past. You also said that it worked "flawlessly" for you until you upgraded your system.

So I'm wondering whether used-up swap space might play a role in this matter, too. At least for the cases that I've seen on my system, I can't rule this out. And when I look at the screenshot you provided in Comment 27 (https://launchpadlibrarian.net/417327528/i915.jpg), sparse swap-space could have been a factor in that case as well. Because roughly 3.5 GB free swap-space doesn't seem much for a 16-GB-RAM box.

#17 lore raw
Quoted 5 lines

So you got hibernate working now with pm-utils*and* the prop. Nvidia drivers. That's good - although a bit contrary to what you said in Comment 29:

I was told so, long time ago struggling to get nvidia prop to resume from hibernation, I found out that uswsusp was better for it (googling or on irc), and it indeed worked better, or with less effort at least, back  then.  I made that comment thinking this was true but I just proved myself wrong...

Quoted 4 lines

till puzzles me is that while others are having problems, suspend-utils/uswsusp work for me almost 100 % of the time, except for a few extreme test-cases in the past. You also said that it worked "flawlessly" for yo

Yes! It worked pretty good on version 18.04.1 of ubuntu with kernel 4.15.0-42 and 41 using uswsusp. There was a long problem with nvidia props that wouldn't let the system resume, but this was fixed when I upgraded to the latest version of the 415 nvidia driver. I kept like one month just hibernating to switch to windows and coming back to the restored snapshot of linux.  You can check my apt history here: https://launchpadlibrarian.net/415602746/aptHistory.log. At the Start-Date: 2019-02-02 15:40:45, I'm 100% sure it was perfect. I am 100% sure that it wasn't already working anymore having the s2disk freeze issue at Start-Date: 2019-03-05 10:38:4.

uswsusp also worked fine on ubuntu 16.04, but I dont remember the kernel versions. Now I'm currently with the nvidia 418.56, ubuntu 18.04.2, kernel 4.18.0-17-generic and hibernation with pm-utils works. I haven't found any major problem with it besides failing to suspend to ram yesterday, which  I don't know if is related to it or not, but today I tested it after and before hibernation and seems to be ok.

Quoted 6 lines

So I'm wondering whether used-up swap space might play a role in this matter, too. At least for the cases that I've seen on my system, I can't rule this out. And when I look at the screenshot you provided in Comment 27 (https://launchpadlibrarian.net/417327528/i915.jpg), sparse swap-space could have been a factor in that case as well. Because roughly 3.5 GB free swap-space doesn't seem much for a 16-GB-RAM box.

On my many tests with uswsusp and a 16gb swap partition and 16 gb of ram, I noticed that it would be less likely to fail when less than something about 2 gb of ram, like just after boot up, it would though after the 3rd or 4th followed hibernation cycle. If after the boot up I allocate more than that value if would be much more likely to happen like always on the 2nd attempt, and if more than around 6gb would fail on the first attempt.

Those aren't sure values, sometimes it failed regardless of ram usage, specially on my latest tests. also once it hibernated with more than 11gb ram usage and failed on the second attempt. So this is all happening pretty randomly. What I described above is just most of the cases and maybe this is just random anyway.

#18 lore raw
In reply to Jan Kara
Quoted 110 lines · CEST Jan Kara
Quoted 82 lines · Andrew Morton

I cc'ed a bunch of people from bugzilla.

Folks, please please please remember to reply via emailed reply-to-all. Don't use the bugzilla interface!

Quoted 63 lines · On Mon, 16 Jun 2014 18:29:26 +0200 "Rafael J. Wysocki"…
Quoted 62 lines · Johannes Weiner
Quoted 36 lines · Rafael J. Wysocki
Quoted 35 lines · Johannes Weiner
Quoted 34 lines · Rafael J. Wysocki
Quoted 33 lines · Johannes Weiner

Hi Oliver,

Quoted 7 lines · Oliver Winker

Hello,

1) Attached a full function-trace log + other SysRq outputs, see [1] attached.

I saw bdi_...() calls in the s2disk paths, but didn't check in detail Probably more efficient when one of you guys looks directly.

Thanks, this looks interesting. balance_dirty_pages() wakes up the bdi_wq workqueue as it should:

[  249.148009]   s2disk-3327    2.... 48550413us : global_dirty_limits <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : global_dirtyable_memory <-global_dirty_limits
[  249.148009]   s2disk-3327    2.... 48550414us : writeback_in_progress <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : bdi_start_background_writeback <-balance_dirty_pages_ratelimited
[  249.148009]   s2disk-3327    2.... 48550414us : mod_delayed_work_on <-balance_dirty_pages_ratelimited
but the worker wakeup doesn't actually do anything:
[  249.148009] kworker/-3466    2d... 48550431us : finish_task_switch <-__schedule
[  249.148009] kworker/-3466    2.... 48550431us : _raw_spin_lock_irq <-worker_thread
[  249.148009] kworker/-3466    2d... 48550431us : need_to_create_worker <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : worker_enter_idle <-worker_thread
[  249.148009] kworker/-3466    2d... 48550432us : too_many_workers <-worker_enter_idle
[  249.148009] kworker/-3466    2.... 48550432us : schedule <-worker_thread
[  249.148009] kworker/-3466    2.... 48550432us : __schedule <-worker_thread

My suspicion is that this fails because the bdi_wq is frozen at this point and so the flush work never runs until resume, whereas before my patch the effective dirty limit was high enough so that image could be written in one go without being throttled; followed by an fsync() that then writes the pages in the context of the unfrozen s2disk.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Does this make sense? Rafael? Tejun?

Well, it does seem to make sense to me.

From what I see, this is a deadlock in the userspace suspend model and
just happened to work by chance in the past.

Well, it had been working for quite a while, so it was a rather large opportunity
window it seems. :-)

No doubt about that, and I feel bad that it broke. But it's still a deadlock that can't reasonably be accommodated from dirty throttling.

It can't just put the flushers to sleep and then issue a large amount of buffered IO, hoping it doesn't hit the dirty limits. Don't shoot the messenger, this bug needs to be addressed, not get papered over.

Quoted 11 lines
Quoted 1 line

Can we patch suspend-utils as follows?

Perhaps we can. Let's ask the new maintainer.

Rodolfo, do you think you can apply the patch below to suspend-utils?

Quoted 3 lines

Alternatively, suspend-utils
could clear the dirty limits before it starts writing and restore them post-resume.

That (and the patch too) doesn't seem to address the problem with existing suspend-utils
binaries, however.

Quoted 8 lines
Quoted 4 lines

It's userspace that freezes the system before issuing buffered IO, so my conclusion was that the bug is in there. This is arguable. I also wouldn't be opposed to a patch that sets the dirty limits to infinity from the ioctl that freezes the system or creates the image.

OK, that sounds like a workable plan.

How do I set those limits to infinity?

Five years have passed and people are still hitting this.

Quoted 7 lines

Killian described the workaround in comment 14 at
https://bugzilla.kernel.org/show_bug.cgi?id=75101.

People can use this workaround manually by hand or in scripts. But we really should find a proper solution. Maybe special-case the freezing of the flusher threads until all the writeout has completed. Or something else.

I've refreshed my memory wrt this bug and I believe the bug is really on the side of suspend-utils (uswsusp or however it is called). They are low level system tools, they ask the kernel to freeze all processes (SNAPSHOT_FREEZE ioctl), and then they rely on buffered writeback (which is relatively heavyweight infrastructure) to work. That is wrong in my opinion.

I can see Johanness was suggesting in comment 11 to use O_SYNC in suspend-utils which worked but was too slow. Indeed O_SYNC is rather big hammer but using O_DIRECT should be what they need and get better performance - no additional buffering in the kernel, no dirty throttling, etc. They only need their buffer & device offsets sector aligned - they seem to be even page aligned in suspend-utils so they should be fine. And if the performance still sucks (currently they appear to do mostly random 4k writes so it probably would for rotating disks), they could use AIO DIO to get multiple pages in flight (as many as they dare to allocate buffers) and then the IO scheduler will reorder things as good as it can and they should get reasonable performance.

Quoted 1 line

Is there someone who works on suspend-utils these days?

Not that I know of.

Quoted 2 lines

Because the repo I've found on kernel.org seems to be long dead (last commit in 2012).

And that's where the things are as of today, AFAICS.

Cheers,
Rafael