x86/smpboot: Speed up suspend/resume by avoiding 100ms sleep for CPU offline during S3
x86/smpboot: Speed up suspend/resume by avoiding 100ms sleep for CPU offline during S3

With certain kernel configurations, CPU offline consumes more than
100ms during S3.

It's a timing related issue: native_cpu_die() would occasionally fall
into a 100ms sleep when the CPU idle loop thread marked the CPU state
to DEAD too slowly.

What native_cpu_die() does is that it polls the CPU state and waits
for 100ms if CPU state hasn't been marked to DEAD. The 100ms sleep
doesn't make sense and is purely historic.

To avoid such long sleeping, this patch adds a 'struct completion'
to each CPU, waits for the completion in native_cpu_die() and wakes
up the completion when the CPU state is marked to DEAD.

Tested on an Intel Xeon server with 48 cores, Ivybridge and on
Haswell laptops. The CPU offlining cost on these machines is
reduced from more than 100ms to less than 5ms. The system
suspend time is reduced by 2.3s on the servers.

Borislav and Prarit also helped to test the patch on an AMD
machine and a few systems of various sizes and configurations
(multi-socket, single-socket, no hyper threading, etc.). No
issues were seen.

Tested-by: Prarit Bhargava <fe4655370dc87a32329d591d6e8472329333dfad@redhat.com>
Signed-off-by: Lan Tianyu <4221d0916eb5c472a0ab46f0107445bbb3e8a589@intel.com>
Acked-by: Borislav Petkov <0691a664b24b6f15b20cd5aee64b72271db08be1@suse.de>
Cc: Peter Zijlstra <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Cc: 9d183ff83abfec5c556edaf86a280a53916a11d8@redhat.com
Cc: 322b9f75d3806917607539efc168804d71b9503d@hp.com
Cc: 376726f239c919d31d97c9332191663ab16d47b5@redhat.com
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Link: http://lkml.kernel.org/r/1409039025-32310-1-git-send-email-4221d0916eb5c472a0ab46f0107445bbb3e8a589@intel.com
[ Improved a few minor details in the code, cleaned up the changelog. ]
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs