How SMPng Works and Why It Doesn't Work The Way You Think NYC*BUG - - PowerPoint PPT Presentation

how smpng works and why it doesn t work the way you think
SMART_READER_LITE
LIVE PREVIEW

How SMPng Works and Why It Doesn't Work The Way You Think NYC*BUG - - PowerPoint PPT Presentation

How SMPng Works and Why It Doesn't Work The Way You Think NYC*BUG February 6, 2013 John Baldwin jhb@FreeBSD.org Ideal SMP Ideal Ideal SMP Ideal Best Ideal SMP Ideal Best Decent Ideal SMP Ideal Best Decent Hump Ideal SMP Ideal


slide-1
SLIDE 1

How SMPng Works and Why It Doesn't Work The Way You Think

NYC*BUG February 6, 2013 John Baldwin jhb@FreeBSD.org

slide-2
SLIDE 2

Ideal SMP

Ideal

slide-3
SLIDE 3

Ideal SMP

Ideal Best

slide-4
SLIDE 4

Ideal SMP

Ideal Best Decent

slide-5
SLIDE 5

Ideal SMP

Ideal Best Decent Hump

slide-6
SLIDE 6

Ideal SMP

Ideal Best Decent Hump None

slide-7
SLIDE 7

Why is Scaling Hard?

  • N CPUs should do N amount of work
  • Shared Resources
  • Can only be changed by one CPU at a time
  • Multiple CPUs have to take turns (“synchronize”)
  • Examples
  • Devices
  • TCP Connections
  • TTYs
slide-8
SLIDE 8

Old Problem

  • Signal handlers in userland
  • Limited ability (sigaction(2) list)
  • Threads can mask handlers
  • Interrupts in traditional UP kernels
  • Limited ability (not able to block)
  • “Top-half” masked interrupts
  • spl(9) API in BSD and FreeBSD < 5
slide-9
SLIDE 9

SMP: New Wrinkle

  • Adding threads to a userland application

requires additional synchronization (locking)

  • SMP kernels require locking as well
  • Improving scalability is an iterative process of

identifying bottlenecks and improving them

  • SMPng is a project to replace a “Giant” lock

around the entire kernel with “smaller” locks

slide-10
SLIDE 10

FreeBSD 3.0

Giant Mostly Locked Fully Locked Improved Scaling CAM File Systems Storage Drivers USB TTY VFS syscons misc new-bus Network Drivers Sockets Process Management Scheduler Virtual Memory Network Protocols

slide-11
SLIDE 11

FreeBSD 5.0

Giant Mostly Locked Fully Locked Improved Scaling CAM GEOM File Systems Process Management Storage Drivers Scheduler Virtual Memory USB TTY VFS syscons misc new-bus Network Drivers Sockets Network Protocols

slide-12
SLIDE 12

FreeBSD 5.3

Giant Mostly Locked Fully Locked Improved Scaling CAM GEOM File Systems Process Management Storage Drivers Scheduler Virtual Memory USB TTY VFS syscons misc new-bus Network Drivers Sockets Network Protocols

slide-13
SLIDE 13

FreeBSD 5.4

Giant Mostly Locked Fully Locked Improved Scaling CAM GEOM File Systems Process Management Storage Drivers Scheduler Virtual Memory USB TTY VFS syscons misc new-bus Network Drivers Sockets Network Protocols

slide-14
SLIDE 14

FreeBSD 6.0

Giant Mostly Locked Fully Locked Improved Scaling CAM GEOM File Systems Process Management Storage Drivers Scheduler Virtual Memory USB TTY VFS syscons misc new-bus Network Drivers Sockets Network Protocols

slide-15
SLIDE 15

FreeBSD 7.0

Giant Mostly Locked Fully Locked Improved Scaling CAM GEOM File Systems Process Management Storage Drivers Scheduler Virtual Memory USB TTY VFS syscons misc new-bus Network Drivers Sockets Network Protocols

slide-16
SLIDE 16

FreeBSD 8.0

Giant Mostly Locked Fully Locked Improved Scaling CAM GEOM File Systems Process Management Storage Drivers Scheduler Virtual Memory USB TTY VFS syscons misc new-bus Network Drivers Sockets Network Protocols

slide-17
SLIDE 17

FreeBSD 9.0

Giant Mostly Locked Fully Locked Improved Scaling CAM GEOM File Systems Process Management Storage Drivers Scheduler Virtual Memory USB TTY VFS syscons misc new-bus Network Drivers Sockets Network Protocols

slide-18
SLIDE 18

FreeBSD 10.0

Giant Mostly Locked Fully Locked Improved Scaling CAM GEOM File Systems Process Management Storage Drivers Scheduler Virtual Memory USB TTY VFS syscons misc new-bus Network Drivers Sockets Network Protocols

slide-19
SLIDE 19

Remaining Giant Uses

  • Boot Time Initialization
  • Suspend/Resume
  • Module Event Handlers
  • new-bus
  • Some Storage Drivers (aha(4), dpt(4))
  • syscons
  • Miscellaneous (e.g., certain non-trivial sysctls)
slide-20
SLIDE 20

Hardware Tangent

  • SATA NCQ (previously only for SCSI)
  • Multiple RX/TX Queues on NICs
  • Nearly mandatory for 10G
  • X86 Memory Controllers Moved on Die
slide-21
SLIDE 21

Finally

  • http://www.freebsd.org/~jhb/papers/smp/
  • Questions?