Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2431625rdf; Mon, 6 Nov 2023 14:09:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IECSj946JOz1I3MGpbrg/8PP30hdolqDrapIMGK2oew+SwTGScJRJ/4ZpLPN5T918joitvK X-Received: by 2002:a05:6358:89e:b0:168:f5e2:b1e0 with SMTP id m30-20020a056358089e00b00168f5e2b1e0mr32274111rwj.31.1699308596973; Mon, 06 Nov 2023 14:09:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699308596; cv=none; d=google.com; s=arc-20160816; b=Yrqu/4WSlo15GuB5OCqc/1/SMXIUaDM2enrej9x86uw7pWVgssCe0TcY0jU5oiW27m spmVD2d+qC61wX54dEE1W+sIAFnB49Z1ijOZjjIcvxgPzliiAdr9kRPu4PCoR5f39FK+ Z78ulpbLbzgM2mmPUk/zFnn6cLhSQU8f/VyZcmEYaNuiqWJ5sChr/6iEGgOBp+PEaL9h Bh/JZ8wzGDeIbxLqUM4S7IL022h/uvs4tuEv9kN78DpFAV3y5RlXZAw1pKG4iPnKFxCG OgdMDwIP8PNAkuur+OzPr5gtf9UfPeFewDWk4FPsXJ6LbIaZS8/+1l+tmoa+1iX+B+u6 UT7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=oHKj578ZqnSwXQwTkojaIUHR/MjAjN6+KDTUvfUfFak=; fh=9F7SzeZZdxDcqHXToJo9H4JaITeZihUfoBnTMdcOQaI=; b=luBkVnuQV4GFrcF83lzWHgnLHzIN/pw6JVhY6Vx9epj7bx2Bkz3LK8V4cSI0EiGChL 0F6yNi0jafEhtmaWrgh/Ibnp64ic6kVzTEa0r32gzHurPrlo/je+YvVQZKjzwD6ZhLwM SJWHqpSvTrP9jDiyQkPVs93ZYIVE+Mvzwey7SHQ6o92kEbD/S94dy6WdKMAR2jBDR2B/ cDIxLKRCRxRBnD3PGjxTfTlAVCcsPtDjSzlsmKdQmIbg3kirdS0VojbSoImBAazP1RcU aYduI4UbsR6ZjgbmJseqKKLKQYt95gqrTcQmXQks6Df5QszqxQuc47OsLtyn2WzmHX5W Bysw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=SbKYPCgK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id h191-20020a636cc8000000b005b8ac0af52csi582522pgc.1.2023.11.06.14.09.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 14:09:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=SbKYPCgK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 61569802FA3F; Mon, 6 Nov 2023 14:09:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233244AbjKFWJk (ORCPT + 99 others); Mon, 6 Nov 2023 17:09:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233169AbjKFWJj (ORCPT ); Mon, 6 Nov 2023 17:09:39 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0596183 for ; Mon, 6 Nov 2023 14:09:35 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8C18C433C8; Mon, 6 Nov 2023 22:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1699308575; bh=IYP87mPslCnQl/9LQiXvTbko+eNuU/TJe/cJTwCnwiU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SbKYPCgKGr9KACWJJS6bLYB/tEMKq+JVzVmgV5457dZ5/4owurxJXB9SOlDerCIrE MF8DZWFbn5ggyJ/fnlUm6AZ6zPnZacX3M1oa0z7Q2W4l8PKgioBAX8YcaQSE1rLhF/ Pn5nzm0L9CpSMuvj/QZXPVeRgwlDqmEaT43OH4Qc= Date: Mon, 6 Nov 2023 14:09:34 -0800 From: Andrew Morton To: Dmitry Rokosov Cc: , , , , , , , , , , Subject: Re: [PATCH v1] tools/cgroup: introduce cgroup v2 memory.events listener Message-Id: <20231106140934.3f5d4960141562fe8da53906@linux-foundation.org> In-Reply-To: <20231013184107.28734-1-ddrokosov@salutedevices.com> References: <20231013184107.28734-1-ddrokosov@salutedevices.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLACK autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 06 Nov 2023 14:09:52 -0800 (PST) On Fri, 13 Oct 2023 21:41:07 +0300 Dmitry Rokosov wrote: > 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/cgroup_v2_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 > > ... > Looks nice to me. Perhaps it should be under ./samples/? I suggest adding a comment to __memory_events_show() reminding people to update this code if new events are added.