Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp366509iof; Mon, 6 Jun 2022 05:08:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzY5epkIKgIMAYA+Rpuj9bMZSrosC2dxYmtKlYKcViDwl6nzXKbuBxpKXqCp+PMmTMr9mdp X-Received: by 2002:aa7:8691:0:b0:51c:db9:4073 with SMTP id d17-20020aa78691000000b0051c0db94073mr7485020pfo.72.1654517321930; Mon, 06 Jun 2022 05:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654517321; cv=none; d=google.com; s=arc-20160816; b=1H3tf4eVeahCL/TIrTgb1kbEyLuUXzlg0g9sx/xfESz6o7RSV4e91sD0SxVvVjLyaa 8hDAZdOgB8L0E/Sh4ZBUOJ0jTzdkCIMOnxBPwFqOhd2u9R+/dvw0F5MITuslkxgtz05u oroJ4xWV0hnNfQEXTCZmByv6oQ1h1tAeUgBl17KxNyfn1SiZqwlWhhEaBbAN4G+WMuKR kkJMt4/jy2Z0r9kxdqLld3fOtMEOZRUQ+jYzbYgOJdghQSpT2A/tCYIeYSHmvNtGcanT AfaIvotyHjN4KTstheD6uL3ve9PD4RWjq6aBNir6oYOGau3PKblLJl7bCgjaeSljTkJ4 GLsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CZfbvYWKjKsB+23H/W7org8aRzTVXyVE8kdib5DA8+A=; b=OTtO8bjI9UtEsCArni97d+ds3lSFH5gww7kxfR9J6ibRwDV7rdUSkNjLywg1aAYy9j gYP7JkD6DEPhWpTSu1/2nJU9X05/wZFL/lWy7FnjGDt2YtE2xd2VVy0zjDZa/tHPLrjR 9MTqVrfrNgzg9ywRTGL0cfw1wQmc4zIgJ3OE5jiJFEVCj8Ibc2F31ED55pLEnjdIRPCb pQ6yAfLG/bahiRwbagvmQw2sZOWmNUW9q+4TVrxwfaLAydGXKcEfz7YTyaaNAM2t7ibW skz+CaqiXxDXBJ4ruEbipX+o/sLf2xAMvRqlxIdynoTm7TkU30155vFJtCJmeE8iIXQi dQTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=jcF8iBoG; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h17-20020a170902f55100b0015d0f3a4ac5si21610559plf.300.2022.06.06.05.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 05:08:41 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=jcF8iBoG; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A8B4515A27; Mon, 6 Jun 2022 05:04:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236150AbiFFMEG (ORCPT + 99 others); Mon, 6 Jun 2022 08:04:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235894AbiFFMEE (ORCPT ); Mon, 6 Jun 2022 08:04:04 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C3E513E16; Mon, 6 Jun 2022 05:04:02 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C0AE821A5C; Mon, 6 Jun 2022 12:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1654517040; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CZfbvYWKjKsB+23H/W7org8aRzTVXyVE8kdib5DA8+A=; b=jcF8iBoG9VE/bG+eSReaeL4gfHyFGDthvx6RiW/gjsDWzhaqrw7aX+dln8LJCEc0kxKXNQ tyrPd/7VLmrP8u6mmCPTTALWmexNRou2t6Y6LcmvJS88QN5wnv2mgh4iJ/LDFNbMpcSesH 50BPh3SjLuQOz4bNH+m3HkCt5KOCqew= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3C6362C141; Mon, 6 Jun 2022 12:04:00 +0000 (UTC) Date: Mon, 6 Jun 2022 14:03:56 +0200 From: Michal Hocko To: Qi Zheng Cc: hannes@cmpxchg.org, roman.gushchin@linux.dev, shakeelb@google.com, songmuchun@bytedance.com, akpm@linux-foundation.org, corbet@lwn.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v2] mm: memcontrol: add {pgscan,pgsteal}_{kswapd,direct} items in memory.stat of cgroup v2 Message-ID: References: <20220604082209.55174-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220604082209.55174-1-zhengqi.arch@bytedance.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 04-06-22 16:22:09, Qi Zheng wrote: > There are already statistics of {pgscan,pgsteal}_kswapd and > {pgscan,pgsteal}_direct of memcg event here, but now only the > sum of the two is displayed in memory.stat of cgroup v2. > > In order to obtain more accurate information during monitoring > and debugging, and to align with the display in /proc/vmstat, > it better to display {pgscan,pgsteal}_kswapd and > {pgscan,pgsteal}_direct separately. > > Also, for forward compatibility, we still display pgscan and > pgsteal items so that it won't break existing applications. I do not remember why we have chosen to report cumulative stats rather than the direct and kswapd parts. Looking back when Roman has introduced those (http://lkml.kernel.org/r/1494530183-30808-1-git-send-email-guro@fb.com) I do not see any discussion around that. So it was likely just not a priority. I have just one question. Say we even decide to have a per memcg kswapd in some form, would we report that into the same counter? > Signed-off-by: Qi Zheng > Acked-by: Johannes Weiner > Acked-by: Roman Gushchin > Acked-by: Muchun Song In any case Acked-by: Michal Hocko One nit below [...] > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 0d3fe0a0c75a..fd78c4d6bbc7 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1460,6 +1460,28 @@ static inline unsigned long memcg_page_state_output(struct mem_cgroup *memcg, > return memcg_page_state(memcg, item) * memcg_page_state_unit(item); > } > I would just add the following for clarity /* Subset of vm_event_item to report for memcg event stats */ > +static const unsigned int memcg_vm_event_stat[] = { > + PGSCAN_KSWAPD, > + PGSCAN_DIRECT, > + PGSTEAL_KSWAPD, > + PGSTEAL_DIRECT, > + PGFAULT, > + PGMAJFAULT, > + PGREFILL, > + PGACTIVATE, > + PGDEACTIVATE, > + PGLAZYFREE, > + PGLAZYFREED, > +#if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP) > + ZSWPIN, > + ZSWPOUT, > +#endif > +#ifdef CONFIG_TRANSPARENT_HUGEPAGE > + THP_FAULT_ALLOC, > + THP_COLLAPSE_ALLOC, > +#endif > +}; -- Michal Hocko SUSE Labs