LCE12: CPU Hotplug, RCU, and big.LITTLE

33
© 2009 IBM Corporation CPU Hotplug, RCU, and big.LITTLE Paul E. McKenney, IBM Distinguished Engineer, Linux Technology Center (Linaro) November 1, 2012 2012 Linux Plumbers Conference, Scheduling Microconference

description

Resource: LCE12 Name: CPU Hotplug, RCU, and big.LITTLE Date: 01-11-2012 Speaker: Paul McKenney

Transcript of LCE12: CPU Hotplug, RCU, and big.LITTLE

Page 1: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation

CPU Hotplug, RCU, and big.LITTLE

Paul E. McKenney, IBM Distinguished Engineer, Linux Technology Center (Linaro)

November 1, 2012

2012 Linux Plumbers Conference, Scheduling Microconference

Page 2: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation2

CPU Hotplug: Work In Progress

CPU Hotplug, RCU, and big.LITTLE

Page 3: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation3

CPU Hotplug: Work In Progress

CPU Hotplug, RCU, and big.LITTLE

Reduce task creation/destruction overhead– Thomas Gleixner's generic-idle (mainline) and park/unpark (-tip)– Tejun Heo's fix for workqueues

Numerous fixes from Srivatsa Bhat (3.4-3.6)

Disturbance-free SRCU (Lai Jiangshan, 3.4)

Wean RCU from __stop_machine() (PEM, 3.5-3.7)

Wean scheduler from __stop_machine() (Peter, 3.7)

Guard for_each_online_cpu() (Silas Boyd-Wickizer, 3.7-3.8)

Switch hotplug from __stop_machine() (PEM, 3.8?)

Tell RCU exactly when CPU goes offline (PEM, 3.8?)

Reverse notifier order, reworking notifier concepts (TBD)

Apply park/unpark everywhere (TBD)

Good progress, some work left

Page 4: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation4

RCU Callbacks, HPC, Real Time and big.LITTLE

CPU Hotplug, RCU, and big.LITTLE

Page 5: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation5

RCU Callbacks, HPC, Real Time and big.LITTLE

CPU Hotplug, RCU, and big.LITTLE

For an overview, see http://lwn.net/Articles/262464/

For the purposes of this presentation, think of RCU as something that defers work, with one work item per callback

–Each callback has a function pointer and an argument–Callbacks are queued on per-CPU lists, invoked after grace period

• Invocation can result in OS jitter and real-time latency–Global list handles callbacks from offlined CPUs: adopted quickly

Page 6: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation6

The Problem With RCU Callbacks

CPU Hotplug, RCU, and big.LITTLE

The problem with RCU callbacks:

CPU 0

call_rcu()

Callback Invoked

Grace Period

Likely disrupting whatever was intended to execute at about this time...

Page 7: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation7

The Problem With RCU Callbacks

CPU Hotplug, RCU, and big.LITTLE

The problem with RCU callbacks:

CPU 0

call_rcu()

Callback Invoked

Grace Period

Likely disrupting whatever was intended to execute at about this time... Such as a big CPU's desire to remain idle.

Page 8: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation8

The Problem With RCU Callbacks

CPU Hotplug, RCU, and big.LITTLE

The problem with RCU callbacks:

CPU 0

call_rcu()

Callback Invoked

Grace Period

Likely disrupting whatever was intended to execute at about this time... Such as a big CPU's desire to remain idle.

Not so good for HPC andreal time, either

Page 9: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation9

The Problem With RCU Callbacks and big.LITTLE

CPU Hotplug, RCU, and big.LITTLE

big CPU

call_rcu()

CB

Grace Period

LITTLE CPU

Busy

Busy Busy Busy

Page 10: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation10

What big.LITTLE Might Want Instead

CPU Hotplug, RCU, and big.LITTLE

big CPU

call_rcu()

CB

Grace Period

LITTLE CPU

Busy

Busy Busy Busy

Page 11: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation11

CB

What big.LITTLE Might Want Instead: But Not Free

CPU Hotplug, RCU, and big.LITTLE

big CPU

call_rcu()

CB

Grace Period

LITTLE CPU

Busy

Busy Busy Busy

Page 12: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation12

Callback Invoked

RCU Callbacks, Houston/Korty for TREE_RCU

CPU Hotplug, RCU, and big.LITTLE

CPU 2

Grace Period

rcuo1 kthread

CPU 1

Callback Invoked

Grace Period

rcuo0 kthread

call_rcu()

call_rcu()

Page 13: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation13

Callback Invoked

RCU Callbacks, Houston/Korty for TREE_RCU

CPU Hotplug, RCU, and big.LITTLE

CPU 2

Grace Period

rcuo1 kthread

CPU 1

Callback Invoked

Grace Period

rcuo0 kthread

call_rcu()

call_rcu()

Manually place rcuoN kthreads on LITTLE CPUs

Page 14: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation14

Callback Invoked

RCU Callbacks, Houston/Korty for TREE_RCU

CPU Hotplug, RCU, and big.LITTLE

CPU 2

Grace Period

rcuo1 kthread

No big-CPU wakeups!!!

CPU 1

Callback Invoked

Grace Period

rcuo0 kthread

call_rcu()

call_rcu()

Manually place rcuoN kthreads on LITTLE CPUs

Page 15: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation15

Offloadable RCU Callbacks: Limitations and Futures

CPU Hotplug, RCU, and big.LITTLE

Must reboot to reconfigure no-CBs CPUs– Should be just fine for big.LITTLE– Hopefully also OK for HPC and real-time workloads

Scalability: 1,000 no-CBs CPUs would not do well– Not a problem for big.LITTLE, but must be solved for HPC

Must be at least one non-no-CBs CPU (namely, CPU 0)– OK if CPU 0 is a LITTLE CPU, but expect to relax this constraint “real soon now”

No energy-efficiency code: lazy & non-lazy CBs? Non-lazy!– But non-lazy Cbs are common case, so deferring interpretation of laziness.

No-CBs CPUs' kthreads not subject to priority boosting– Probably not a near-term problem for big.LITTLE

Setting all no-CBs CPUs' kthreads to RT prio w/out pinning them: bad!– At least on large systems: Probably OK near-term for big.LITTLE

Note: I do not expect no-CBs path to completely replace current CB path

Page 16: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation16

Offloadable RCU Callbacks: Plans

CPU Hotplug, RCU, and big.LITTLE

Initial version in 3.8 or 3.9, depending on testing results–Thanks to Robin Randhawa and Paul Gortmaker for testing efforts thus far

Page 17: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation17

To Probe More Deeply...

CPU Hotplug, RCU, and big.LITTLE

What Is New In RCU for Real Time (RTLWS 2012)– http://www.rdrop.com/users/paulmck/realtime/paper/RTLWS2012occcRT.2012.

10.19e.pdf• Slides 21-on

Getting RCU Further Out of the Way (Plumbers 2012)– http://www.rdrop.com/users/paulmck/realtime/paper/nocb.2012.08.31a.pdf

Cleaning Up Linux’s CPU Hotplug For Real Time and Energy Management (ECRTS 2012)

– http://www.rdrop.com/users/paulmck/realtime/paper/hotplug-ecrts.2012.06.11a.pdf

And hot off the press: “Relocating RCU callbacks”–http://lwn.net/Articles/522262/

Page 18: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation18

Legal Statement

This work represents the view of the author and does not necessarily represent the view of IBM.

IBM and IBM (logo) are trademarks or registered trademarks of International Business Machines Corporation in the United States and/or other countries.

Linux is a registered trademark of Linus Torvalds.

Other company, product, and service names may be trademarks or service marks of others.

CPU Hotplug, RCU, and big.LITTLE

Page 19: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation19

Questions?

CPU Hotplug, RCU, and big.LITTLE

Page 20: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation20

Scheduling Topics

Target CPU Selection (Vincent Guittot)

Sharing Scheduler Information (Vincent Guittot)

Task Placement for Asymmetric Cores (Morten Rasmussen)

Scheduling and the big.LITTLE Architecture (you are here!)

Dynamic CPU Core Management (Peter De Schrijver and Antti Miettinen)

Application of Deadline Scheduling for Power-Saving Strategies (Juri Lelli)

Main focus of this talk is progress on CPU hotplug–See Peter's and Antti's talk for alternatives

CPU Hotplug, RCU, and big.LITTLE

Page 21: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation21

CPU Hotplug Primer: Online Process

CPU_UP_PREPARE

CPU_STARTING CPU_UP_CANCELLED

FailedSucceeded

CPU_ONLINE

cpu_hotplug.lock held

cpu_add_remove_lock held

Succeeded

Failed

CPU Hotplug, RCU, and big.LITTLE

Page 22: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation22

CPU Hotplug Primer: Offline Process

CPU_DOWN_PREPARE

CPU_DYING CPU_DOWN_FAILED

FailedSucceeded

CPU_DEAD

CPU_POST_DEAD

All other CPUs spinning withinterrupts off while outgoing CPUis in CPU_DYING notifiers

cpu_hotplug.lock held

cpu_add_remove_lock held

Succeeded

Failed

CPU Hotplug, RCU, and big.LITTLE

Page 23: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation23

CPU Hotplug Is Not Atomic

Scheduler

IPIs RCU

Valid notifier order for online:● IPIs● RCU● SchedulerMust reverse order for offline

Reality will intrude...● RCU depends on scheduler● Circular dependency!Must further decompose RCU andscheduler interaction

CPU Hotplug, RCU, and big.LITTLE

Page 24: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation24

CPU Hotplug: Valid Online Order (1/3)

IPIs

Valid notifier order for online:● IPIs● RCU● SchedulerMust reverse order for offline

Reality will intrude...● RCU depends on scheduler● Circular dependency!Must further decompose RCU andscheduler interaction

CPU Hotplug, RCU, and big.LITTLE

Page 25: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation25

CPU Hotplug: Valid Online Order (2/3)

IPIs RCU

Valid notifier order for online:● IPIs● RCU● SchedulerMust reverse order for offline

Reality will intrude...● RCU depends on scheduler● Circular dependency!Must further decompose RCU andscheduler interaction

CPU Hotplug, RCU, and big.LITTLE

Page 26: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation26

CPU Hotplug: Valid Online Order (3/3)

Scheduler

IPIs RCU

Valid notifier order for online:● IPIs● RCU● SchedulerMust reverse order for offline

Reality will intrude...● RCU depends on scheduler● Circular dependency!Must further decompose RCU andscheduler interaction

CPU Hotplug, RCU, and big.LITTLE

Page 27: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation27

Suppose We Offline In The Same Order...

Scheduler

IPIs RCU

Valid notifier order for online:● IPIs● RCU● SchedulerMust reverse order for offline

Reality will intrude...● RCU depends on scheduler● Circular dependency!Must further decompose RCU andscheduler interaction

CPU Hotplug, RCU, and big.LITTLE

Page 28: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation28

CPU Hotplug: Invalid Offline Order

Scheduler

RCU???

Valid notifier order for online:● IPIs● RCU● SchedulerMust reverse order for offline

Reality will intrude...● RCU depends on scheduler● Circular dependency!Must further decompose RCU andscheduler interaction

CPU Hotplug, RCU, and big.LITTLE

Page 29: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation29

CPU Hotplug: Valid Offline Order (1/3)

Scheduler

IPIs RCU

Valid notifier order for online:● IPIs● RCU● SchedulerMust reverse order for offline

Reality will intrude...● RCU depends on scheduler● Circular dependency!Must further decompose RCU andscheduler interaction

CPU Hotplug, RCU, and big.LITTLE

Page 30: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation30

CPU Hotplug: Valid Online Order (2/3)

IPIs RCU

Valid notifier order for online:● IPIs● RCU● SchedulerMust reverse order for offline

Reality will intrude...● RCU depends on scheduler● Circular dependency!Must further decompose RCU andscheduler interaction

CPU Hotplug, RCU, and big.LITTLE

Page 31: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation31

CPU Hotplug: Valid Offline Order (3/3)

IPIs

Valid notifier order for online:● IPIs● RCU● SchedulerMust reverse order for offline

Reality will intrude...● RCU depends on scheduler● Circular dependency!Must further decompose RCU andscheduler interaction

CPU Hotplug, RCU, and big.LITTLE

Page 32: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation32

Other Topics

Synthetic Mobile Workloads–Progress, but no nice solution yet

Emulating big.LITTLE on commodity systems–An embarrassment of riches: http://lwn.net/Articles/501501/

CPU Hotplug, RCU, and big.LITTLE

Page 33: LCE12: CPU Hotplug, RCU, and big.LITTLE

© 2009 IBM Corporation33

Summary

Excellent progress on many fronts

But much work still to be done!

CPU Hotplug, RCU, and big.LITTLE