You are on page 1of 29

Highlights of LinuxCon 2010

Alison Chaiken
alchaiken@gmail.com
14th September 2010

Power management
Android boot-time
New filesystems
kvm

1
Power management: LinuxCon’s biggest
controversy
Contending approaches:

Current mainline approach represented by Rafael J. Wysocki


Intel embellishments and optimization presented by Len
Brown
Android wake_locks and early_suspend, alternate mechanism
from OHA

1
Additions to existing runtime power
management patch
Linux ACPI has replaced earlier BIOS-based APM.
Kernel already has support for underclocking (cpu_freq == "P
states") and hibernation (cpu_idle == "C states")
Next step is to implement per-bus and per-device granularity.
Traditional device-driver approach is addition of new
dev_pm_ops methods to API.
Runtime power management framework provides the kernel
interface for the new driver methods.

1
dev_pm_ops methods
include/linux/pm.h
struct dev_pm_ops {
...
int (*runtime_suspend)(struct device *dev);
int (*runtime_resume)(struct device *dev);
int (*runtime_idle)(struct device *dev);
};

include/linux/device.h
struct device_driver { struct struct bus_type {
... ...
const struct dev_pm_ops *pm; const struct dev_pm_ops *pm;
... ...
}; };

1
For example, see
src/kernels/2.6.34.6-47.fc13.x86_64 . . .

2
Subtleties of runtime power management
framework
Devices run if they please: OS does not, in general, force a
shut-down.
System hibernate and wakeup must bring all devices up and
down.
Settings are configured through /sys/devices/<device>/power.
Event-listener-callback paradigm for wakeup.
A queue holds per-device requests to sleep and wake.
Reference-counting mechanism blocks suspension of devices.

1
Powertop and turbostat
Len Brown, Intel

1
2
Intel’s power measurements
powertop screenshot
Linux trails Windows in idle power management, at least for recent
Intel CPUs.

1
Android wake_lock controversy
Matthew Garrett, Red Hat

Highlights Android’s philosophical difference from Apple:


Loose control of app installation but
Enforce economical power use at OS level instead.
No ACPI, nor APM: wake_locks instead. Requires changes to
drivers.
wake_locks are similar to reference counting: allow processes
to prevent system or device entering idle state.
Nokia, Intel objected to essentially duplicate mechanism with
different license being merged to mainline.

1
Android power management architecture

1
2
Fedora 13
alison@tomales ;-) ls -l /sys/power
-rw-r--r-- 1 root root 4096 Sep 5 16:00 disk
-rw-r--r-- 1 root root 4096 Sep 5 17:41 image_size
-rw-r--r-- 1 root root 4096 Sep 5 17:41 pm_async
-rw-r--r-- 1 root root 4096 Sep 5 17:41 pm_test
-rw-r--r-- 1 root root 4096 Sep 5 17:41 pm_trace
-rw-r--r-- 1 root root 4096 Sep 5 17:41 resume
-rw-r--r-- 1 root root 4096 Sep 5 16:00 state

1
Android 1.6
# ls -l /sys/power
-rw-rw---- radio system 4096 2010-09-04 19:14 state
-rw-rw---- radio system 4096 2010-09-04 19:14 wake_lock
-rw-rw---- radio system 4096 2010-09-04 19:14 wake_unlock
-r--r--r-- root root 4096 2010-09-05 15:11 wait_for_fb_sleep
-r--r--r-- root root 4096 2010-09-05 15:11 wait_for_fb_wake

2
Granularity in Android Power
Management
Flag Value CPU Screen Keyboard
PARTIAL_WAKE_LOCK On* Off Off
SCREEN_DIM_WAKE_LOCK On Dim Off
SCREEN_BRIGHT_WAKE_LOCK On Bright Off
FULL_WAKE_LOCK On Bright Bright

1
Improving Android boot up time
Tim Bird, Sony

1
Improving Android boot up time
Major delay during boot is due to pre-loading of Java classes:
about 1500.
"System And Method For Dynamic Preloading Of Classes . . .
(7,426,720)": Oracle vs. Google lawsuit!
Bird’s attempt to reduce boot-time not exhaustive, but also
not successful so far.

1
One Billion Files: Scalability Limits in
Linux FS
Ric Wheeler, Red Hat

fsck exhausts system memory at less than a billion files


ext4 rules, but Oracle’s btrfs (MeeGo) is hot and xfs (SGI)
and zfs (BSD/Solaris) have supporters.
Features: xfs, enterprise performance and scalability; zfs,
native support for encryption; btrfs, snapshotting and
reversion.
Observed dramatic implementation-specific effects at large
scale:
ext4 is slow where stat() must be run on each file (e.g.
"ls").
1
Some FS do better with larger files, some with many
files.
Hype about btrfs largely justified.

2
Features of btrfs
Chris Mason, Oracle

1
KVM: the Latest from the Development
Team
Chris Wright, Red Hat

kvm has replaced xen as the VM integrated directly with the


kernel.
qemu emulator is heavily reliant on the kvm device driver.
Machine-to-machine paradigm for servers rather than
user-target in embedded.
Support for direct control and communication with host’s
peripherals, esp. PCI, is being added.
Guests can run at 80% native speed although implementation
remains buggy!

1
Challenges include guest-host coordination of memory (via
Nested Page Tables) and scheduling.

2
PC-BSD Running in Qemu-KVM on
Fedora 13

1
2
Invocation of kvm for PCBSD
alison@tomales ;-) sudo /bin/rm /tmp/pcbsd.img; qemu-img create \
-f qcow2 /tmp/pcbsd.img 10G
Formatting ’/tmp/pcbsd.img’, fmt=qcow2 size=10737418240 \
encryption=off cluster_size=0

alison@tomales ;-) sudo qemu-kvm -cdrom /opt/PCBSD8.1-x64-DVD.iso -m \


2048 -vga std -hda /tmp/pcbsd.img -writeconfig pcbsd.config

alison@tomales ;-) cat pcbsd.config


# qemu config file
[drive]
index = "2"
media = "cdrom"
file = "/opt/PCBSD8.1-x64-DVD.iso"
[drive]
index = "0"
media = "disk"
file = "/tmp/pcbsd.img"

1
Summary
Power management is the greatest current area of controversy.
Linux lags other OS’s in energy conservation.
Android presents both problems and opportunities for Linux.
Healthy competition among filesystems leads to rapid
innovation.
Qemu and kvm are both impressive and incredibly useful.

1
Without d_type, must stat() and readdir()
to list files
/usr/include/dirent.h
#ifdef __USE_BSD /* File types for ‘d_type’. */
enum
{ DT_UNKNOWN = 0, # define DT_UNKNOWN DT_UNKNOWN
DT_FIFO = 1, # define DT_FIFO DT_FIFO
DT_CHR = 2, # define DT_CHR DT_CHR
DT_DIR = 4, # define DT_DIR DT_DIR
DT_BLK = 6, # define DT_BLK DT_BLK
DT_REG = 8, # define DT_REG DT_REG
DT_LNK = 10, # define DT_LNK DT_LNK
DT_SOCK = 12, # define DT_SOCK DT_SOCK
DT_WHT = 14 # define DT_WHT DT_WHT
};
1
No concept of file type in POSIX standard.

2
FS Comparative Performance

You might also like