Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp451079iof; Mon, 6 Jun 2022 06:40:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz58gi/CSBG/rsl+CXIwXiHptKBdiT8yCIeVnePqOryipEfr2TolbZlHeRtAD3/+N+cbZyN X-Received: by 2002:a17:90b:4c07:b0:1e8:2961:e318 with SMTP id na7-20020a17090b4c0700b001e82961e318mr20513289pjb.151.1654522830792; Mon, 06 Jun 2022 06:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654522830; cv=none; d=google.com; s=arc-20160816; b=Y/rZApuSlNMGVQdcAnT30MZzylUmCVm3SBk1FRveeHPt2yhaRX6/R/6UGKLRSd9IDv 3a3Ov5CPNYv+ax7aZfxByIvIfu+kGfOpg1+/detCOqn9cxe9BPOAof8Uwul7UJh4/twW bkLG9SwV/CW+pX6inOTw5A0FsClCxZTO/XtziSKBJEdS+dybyU8MnFzP2URMtYix8B1c 8RAIAKEgDSgETO6D5dGwh2xQNIx9bhZ6MRreoTqZrNPvuDQnxwIk6PKujKAUqTSLGZjR 9gwYLv1c8bvq6JwKr1JBiOmsJeEXEOS1Br/BHgfAgB+lYE73mYXJfZ8mky5ubFcjOH0b 6hHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=a6THwbekRoD/OZeM515RpGdmDznAEQ2m0S86eTQP2nM=; b=vZDWiB2TlLb7d9LifkYjFyWypesomS/Qw4qOVRKNqsL6TQ+rcYBdGMo6Lwm60nLioP SmLcHCmJqJLHM8Yea8/be2SNUfrkk9ihsTusiOLtpV87O3Ox8/SJCgv8o6X3Ta/N49Fj EUd4+wKj/qg9LDSY68F9ACUza2Y3NVcyEt/yqDVKV3/rNLC0XVlSb5QfP+xuOjonO+v0 RH/hgcxryVcVOUwmrJdqgt6XPDuBVc/Hoo5SAvaKwYU93DVwfEzaSM8mgJGYzrstxdbM /nNdEKrId6jhYt+0ZL3+41m+N/a5tECaNxZIsS/XjbxEqF4KYMPPnYlRI/XVDNmFjJgT AFaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="1/DASdY+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p5-20020a17090ab90500b001e34955c638si19998183pjr.166.2022.06.06.06.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 06:40:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="1/DASdY+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4FA48CCA66; Mon, 6 Jun 2022 06:30:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238933AbiFFNaJ (ORCPT + 99 others); Mon, 6 Jun 2022 09:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239121AbiFFNaH (ORCPT ); Mon, 6 Jun 2022 09:30:07 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A64ECFE1E for ; Mon, 6 Jun 2022 06:30:05 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id g205so12691661pfb.11 for ; Mon, 06 Jun 2022 06:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=a6THwbekRoD/OZeM515RpGdmDznAEQ2m0S86eTQP2nM=; b=1/DASdY+kvY8TlD39JuG2crsUbgapeBdNKmyGXcC8hEVF0+ZsqmHt218btZ87BxpUX k765uHjOIiz/IreEUQItmAku9D9qgTnHcO4Ixh2fCyqF+pbbRPv6cK2StQ5L8KIHYOTq Z0W4iO1OWOm0+uF8e9W8wcyRjN1IXWICP59YrmWvZcJ7RakN84CR5I78NDGeRiKsdpnn MPQSKyEXrTfqLVZp5wOk8F3kIUyMNZjaRQ1oDvos8sSPfAFTb8RkCDQbOvKeJIXmyKnB KbiWe3/syU27gCzg2IWL55UQ6wMwgOQ9yHfEbxnCe0m8tpGpWzW+5mVDaSu49CovRs/N RpFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=a6THwbekRoD/OZeM515RpGdmDznAEQ2m0S86eTQP2nM=; b=NaMry+4IfZ875BbyNiuoJ5L5P0VkH1dCkimpxzYbpcV1Np+N1MihG2kpWLRCMNKeqi n/Bv46l/A1YSVRKxsTNs+QA6OvVdcvIzp8Xn6/12olmmkTk+V8Zg/bqSQlF3OtsIFnpM 9VF0eNvMZnjQtW+g53ozmxzZR1KGasWjMwspDw5r1w6nbg0l5wcJmyLCyUAsPGUwqdDJ +Wuk8zPbvs0SYc6OsiaMVPmgujObVaC1C5mtBccscrlELMcve8TcZcRryuuS/QQ5bwWL AJzogXEHqCgMJEzAt4JAYILJVuWNVd+PeySznhSqjiJ1N1ru6yGgYONPDyU4IzaR5I0k /27A== X-Gm-Message-State: AOAM533jKRaBhfpdN5KUo5gGT2QX97od2dXWr0oj89rZnoUygCwY1hYn wGYdkyP0iQ/R8WrBL/zob3EXbQ== X-Received: by 2002:aa7:9217:0:b0:518:367d:fa85 with SMTP id 23-20020aa79217000000b00518367dfa85mr90933633pfo.9.1654522204614; Mon, 06 Jun 2022 06:30:04 -0700 (PDT) Received: from [10.254.91.102] ([139.177.225.230]) by smtp.gmail.com with ESMTPSA id f10-20020a17090ace0a00b001e31803540fsm10010260pju.6.2022.06.06.06.30.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 Jun 2022 06:30:04 -0700 (PDT) Message-ID: Date: Mon, 6 Jun 2022 21:29:58 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v2] mm: memcontrol: add {pgscan,pgsteal}_{kswapd,direct} items in memory.stat of cgroup v2 Content-Language: en-US To: Michal Hocko 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 References: <20220604082209.55174-1-zhengqi.arch@bytedance.com> From: Qi Zheng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 2022/6/6 8:03 PM, Michal Hocko wrote: > 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? IMO, I would like it can be reported 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 Thanks. > > 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 OK, will do. > > /* 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 >> +}; > -- Thanks, Qi