linux-stable/samples
Dmitry Rokosov becf652960 samples/cgroup: introduce memcg memory.events listener
This is a simple listener for memory events that handles counter changes
in runtime.  It can be set up for a specific memory cgroup v2.

The output example:
=====
$ /tmp/memcg_event_listener test
Initialized MEMCG events with counters:
MEMCG events:
	low: 0
	high: 0
	max: 0
	oom: 0
	oom_kill: 0
	oom_group_kill: 0
Started monitoring memory events from '/sys/fs/cgroup/test/memory.events'...
Received event in /sys/fs/cgroup/test/memory.events:
*** 1 MEMCG oom_kill event, change counter 0 => 1
Received event in /sys/fs/cgroup/test/memory.events:
*** 1 MEMCG oom_kill event, change counter 1 => 2
Received event in /sys/fs/cgroup/test/memory.events:
*** 1 MEMCG oom_kill event, change counter 2 => 3
Received event in /sys/fs/cgroup/test/memory.events:
*** 1 MEMCG oom_kill event, change counter 3 => 4
Received event in /sys/fs/cgroup/test/memory.events:
*** 2 MEMCG max events, change counter 0 => 2
Received event in /sys/fs/cgroup/test/memory.events:
*** 8 MEMCG max events, change counter 2 => 10
*** 1 MEMCG oom event, change counter 0 => 1
Received event in /sys/fs/cgroup/test/memory.events:
*** 1 MEMCG oom_kill event, change counter 4 => 5
^CExiting memcg event listener...
=====

Link: https://lkml.kernel.org/r/20231123071945.25811-3-ddrokosov@salutedevices.com
Signed-off-by: Dmitry Rokosov <ddrokosov@salutedevices.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-12-10 16:51:54 -08:00
..
acrn virt: acrn: Replace obsolete memalign() with posix_memalign() 2023-04-20 14:20:51 +02:00
auxdisplay
binderfs
bpf samples/bpf: Allow building with custom bpftool 2023-10-26 15:32:13 +02:00
cgroup samples/cgroup: introduce memcg memory.events listener 2023-12-10 16:51:54 -08:00
configfs
connector
coresight coresight: syscfg: Example CoreSight configuration loadable module 2021-11-26 11:34:07 -07:00
fanotify Add gitignore file for samples/fanotify/ subdirectory 2021-11-07 11:19:24 -08:00
fprobe fprobe: Pass return address to the handlers 2023-06-06 21:39:55 +09:00
ftrace samples: ftrace: Replace bti assembly with hint for older compiler 2023-08-21 22:03:58 -04:00
hid bpf: Replace deprecated -target with --target= for Clang 2023-06-29 15:46:17 +02:00
hidraw
hw_breakpoint samples/hw_breakpoint: mark sample_hbp as static 2023-07-26 11:17:19 -07:00
kdb
kfifo
kmemleak kmemleak-test: drop __init to get better backtrace 2023-06-09 16:25:40 -07:00
kobject samples/kobject: make kobj_type structure constant 2023-02-08 13:34:41 +01:00
kprobes samples: kprobes: Fixes a typo 2023-10-10 01:00:50 +09:00
landlock samples/landlock: Support TCP restrictions 2023-10-26 21:07:17 +02:00
livepatch livepatch: Reorder to use before freeing a pointer 2022-03-23 13:51:11 +01:00
mei
nitro_enclaves
pfsm samples: Add userspace example for TI TPS6594 PFSM 2023-06-15 13:41:53 +02:00
pidfd
pktgen samples: pktgen: fix append mode failed issue 2023-07-03 09:15:26 +01:00
qmi soc: qcom: qmi: use const for struct qmi_elem_info 2022-08-29 17:33:01 -05:00
rpmsg
rust samples: rust: print: Add sample code for Arc printing 2023-04-10 05:05:43 +02:00
seccomp samples/seccomp: Adjust sample to also provide kill option 2022-02-10 19:09:12 -08:00
timers
trace_events tracing: Fix cpumask() example typo 2022-12-14 11:17:55 -05:00
trace_printk
uhid
user_events tracing/user_events: Use write ABI in example 2023-03-29 06:52:09 -04:00
v4l treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_168.RULE (part 2) 2022-06-10 14:51:36 +02:00
vfio-mdev vfio/mtty: Enable migration support 2023-10-24 15:03:10 -06:00
vfs
watch_queue
watchdog
Kconfig samples: introduce new samples subdir for cgroup 2023-12-10 16:51:54 -08:00
Makefile samples: introduce new samples subdir for cgroup 2023-12-10 16:51:54 -08:00