• Dmitry Rokosov's avatar
    samples/cgroup: introduce memcg memory.events listener · becf6529
    Dmitry Rokosov authored
    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.comSigned-off-by: default avatarDmitry 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: default avatarAndrew Morton <akpm@linux-foundation.org>
    becf6529
Makefile 132 Bytes