forked from Minki/linux
c4843a7593
When modifying PG_Dirty on cached file pages, update the new
MEM_CGROUP_STAT_DIRTY counter. This is done in the same places where
global NR_FILE_DIRTY is managed. The new memcg stat is visible in the
per memcg memory.stat cgroupfs file. The most recent past attempt at
this was http://thread.gmane.org/gmane.linux.kernel.cgroups/8632
The new accounting supports future efforts to add per cgroup dirty
page throttling and writeback. It also helps an administrator break
down a container's memory usage and provides evidence to understand
memcg oom kills (the new dirty count is included in memcg oom kill
messages).
The ability to move page accounting between memcg
(memory.move_charge_at_immigrate) makes this accounting more
complicated than the global counter. The existing
mem_cgroup_{begin,end}_page_stat() lock is used to serialize move
accounting with stat updates.
Typical update operation:
memcg = mem_cgroup_begin_page_stat(page)
if (TestSetPageDirty()) {
[...]
mem_cgroup_update_page_stat(memcg)
}
mem_cgroup_end_page_stat(memcg)
Summary of mem_cgroup_end_page_stat() overhead:
- Without CONFIG_MEMCG it's a no-op
- With CONFIG_MEMCG and no inter memcg task movement, it's just
rcu_read_lock()
- With CONFIG_MEMCG and inter memcg task movement, it's
rcu_read_lock() + spin_lock_irqsave()
A memcg parameter is added to several routines because their callers
now grab mem_cgroup_begin_page_stat() which returns the memcg later
needed by for mem_cgroup_update_page_stat().
Because mem_cgroup_begin_page_stat() may disable interrupts, some
adjustments are needed:
- move __mark_inode_dirty() from __set_page_dirty() to its caller.
__mark_inode_dirty() locking does not want interrupts disabled.
- use spin_lock_irqsave(tree_lock) rather than spin_lock_irq() in
__delete_from_page_cache(), replace_page_cache_page(),
invalidate_complete_page2(), and __remove_mapping().
text data bss dec hex filename
8925147 1774832 1785856 12485835 be84cb vmlinux-!CONFIG_MEMCG-before
8925339 1774832 1785856 12486027 be858b vmlinux-!CONFIG_MEMCG-after
+192 text bytes
8965977 1784992 1785856 12536825 bf4bf9 vmlinux-CONFIG_MEMCG-before
|
||
---|---|---|
.. | ||
ABI | ||
accounting | ||
acpi | ||
aoe | ||
arm | ||
arm64 | ||
auxdisplay | ||
backlight | ||
blackfin | ||
block | ||
blockdev | ||
bus-devices | ||
cdrom | ||
cgroups | ||
cma | ||
connector | ||
console | ||
cpu-freq | ||
cpuidle | ||
cris | ||
crypto | ||
development-process | ||
device-mapper | ||
devicetree | ||
dmaengine | ||
DocBook | ||
driver-model | ||
dvb | ||
early-userspace | ||
EDID | ||
extcon | ||
fault-injection | ||
fb | ||
filesystems | ||
firmware_class | ||
fmc | ||
frv | ||
gpio | ||
hid | ||
hwmon | ||
i2c | ||
ia64 | ||
ide | ||
infiniband | ||
input | ||
ioctl | ||
isdn | ||
ja_JP | ||
kbuild | ||
kdump | ||
ko_KR | ||
laptops | ||
leds | ||
locking | ||
m68k | ||
memory-devices | ||
metag | ||
mic | ||
mips | ||
misc-devices | ||
mmc | ||
mn10300 | ||
mtd | ||
namespaces | ||
netlabel | ||
networking | ||
nfc | ||
nios2 | ||
parisc | ||
PCI | ||
pcmcia | ||
phy | ||
platform | ||
power | ||
powerpc | ||
pps | ||
prctl | ||
pti | ||
ptp | ||
rapidio | ||
RCU | ||
s390 | ||
scheduler | ||
scsi | ||
security | ||
serial | ||
sh | ||
sound | ||
spi | ||
sysctl | ||
target | ||
thermal | ||
timers | ||
tpm | ||
trace | ||
usb | ||
vDSO | ||
video4linux | ||
virtual | ||
vm | ||
w1 | ||
watchdog | ||
wimax | ||
x86 | ||
xtensa | ||
zh_CN | ||
00-INDEX | ||
applying-patches.txt | ||
assoc_array.txt | ||
atomic_ops.txt | ||
bad_memory.txt | ||
basic_profiling.txt | ||
bcache.txt | ||
binfmt_misc.txt | ||
braille-console.txt | ||
bt8xxgpio.txt | ||
btmrvl.txt | ||
BUG-HUNTING | ||
bus-virt-phys-mapping.txt | ||
cachetlb.txt | ||
Changes | ||
circular-buffers.txt | ||
clk.txt | ||
coccinelle.txt | ||
CodeOfConflict | ||
CodingStyle | ||
cpu-hotplug.txt | ||
cpu-load.txt | ||
cputopology.txt | ||
crc32.txt | ||
dcdbas.txt | ||
debugging-modules.txt | ||
debugging-via-ohci1394.txt | ||
dell_rbu.txt | ||
devices.txt | ||
digsig.txt | ||
DMA-API-HOWTO.txt | ||
DMA-API.txt | ||
DMA-attributes.txt | ||
dma-buf-sharing.txt | ||
DMA-ISA-LPC.txt | ||
dontdiff | ||
dynamic-debug-howto.txt | ||
edac.txt | ||
efi-stub.txt | ||
eisa.txt | ||
email-clients.txt | ||
flexible-arrays.txt | ||
futex-requeue-pi.txt | ||
gcov.txt | ||
gdb-kernel-debugging.txt | ||
highuid.txt | ||
HOWTO | ||
hsi.txt | ||
hw_random.txt | ||
hwspinlock.txt | ||
init.txt | ||
initrd.txt | ||
intel_txt.txt | ||
Intel-IOMMU.txt | ||
io_ordering.txt | ||
io-mapping.txt | ||
iostats.txt | ||
IPMI.txt | ||
IRQ-affinity.txt | ||
IRQ-domain.txt | ||
IRQ.txt | ||
irqflags-tracing.txt | ||
isapnp.txt | ||
java.txt | ||
kasan.txt | ||
kernel-doc-nano-HOWTO.txt | ||
kernel-docs.txt | ||
kernel-parameters.txt | ||
kernel-per-CPU-kthreads.txt | ||
kmemcheck.txt | ||
kmemleak.txt | ||
kobject.txt | ||
kprobes.txt | ||
kref.txt | ||
kselftest.txt | ||
ldm.txt | ||
local_ops.txt | ||
lockup-watchdogs.txt | ||
logo.gif | ||
logo.txt | ||
lzo.txt | ||
magic-number.txt | ||
mailbox.txt | ||
Makefile | ||
ManagementStyle | ||
md-cluster.txt | ||
md.txt | ||
media-framework.txt | ||
memory-barriers.txt | ||
memory-hotplug.txt | ||
module-signing.txt | ||
mono.txt | ||
nommu-mmap.txt | ||
numastat.txt | ||
oops-tracing.txt | ||
padata.txt | ||
parport-lowlevel.txt | ||
parport.txt | ||
percpu-rw-semaphore.txt | ||
phy.txt | ||
pi-futex.txt | ||
pinctrl.txt | ||
pnp.txt | ||
preempt-locking.txt | ||
printk-formats.txt | ||
pwm.txt | ||
ramoops.txt | ||
rbtree.txt | ||
remoteproc.txt | ||
rfkill.txt | ||
robust-futex-ABI.txt | ||
robust-futexes.txt | ||
rpmsg.txt | ||
rtc.txt | ||
SAK.txt | ||
SecurityBugs | ||
serial-console.txt | ||
sgi-ioc4.txt | ||
SM501.txt | ||
smsc_ece1099.txt | ||
sparse.txt | ||
stable_api_nonsense.txt | ||
stable_kernel_rules.txt | ||
static-keys.txt | ||
SubmitChecklist | ||
SubmittingDrivers | ||
SubmittingPatches | ||
svga.txt | ||
sysfs-rules.txt | ||
sysrq.txt | ||
this_cpu_ops.txt | ||
unaligned-memory-access.txt | ||
unicode.txt | ||
unshare.txt | ||
vfio.txt | ||
VGA-softcursor.txt | ||
vgaarbiter.txt | ||
video-output.txt | ||
vme_api.txt | ||
volatile-considered-harmful.txt | ||
workqueue.txt | ||
xillybus.txt | ||
xz.txt | ||
zorro.txt |