From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A724C433EF for ; Thu, 5 May 2022 17:27:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B17A06B0071; Thu, 5 May 2022 13:27:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC7856B0073; Thu, 5 May 2022 13:27:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B6516B0074; Thu, 5 May 2022 13:27:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8DA496B0071 for ; Thu, 5 May 2022 13:27:43 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 70315121AB8 for ; Thu, 5 May 2022 17:27:43 +0000 (UTC) X-FDA: 79432371606.02.AFBD167 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) by imf06.hostedemail.com (Postfix) with ESMTP id 1496E1800A2 for ; Thu, 5 May 2022 17:27:39 +0000 (UTC) Received: by mail-io1-f42.google.com with SMTP id z26so5456083iot.8 for ; Thu, 05 May 2022 10:27:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zsF+kn83mNqrMxbS9TzRocPMWDU65sPUevlcCkR0pr0=; b=QOOvGNSB2CcE2vA0mwKhSu3u77etXDnR3iIJvPwzvnl7ScQ+6VWb3TFM6EwGqlAPO0 cYcV3gTjSab/nDBsg6safyBYjUDkSiH3Irz6oBZD1t0InszqFZtGfHilSGaW3cZHgljR 1r7dIUPtTqBHfMPU2NhUZqkF22aV2GqjWTGAHW1+Gho1zOL6kr0J3SsYM84bfncvJi1I LVlc+VJCUdj9gDHyBNAE9zndwCzC58ikYSrPP/Rqv+uj84lCKpTA5qQ/PG2ogq9t53+q 3faNtN41LW3s0tLWPEE65+itf70mt6NG2HRuqpv79OfYVXRJXuX+3NrWNtvix1xkWpL0 kEkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zsF+kn83mNqrMxbS9TzRocPMWDU65sPUevlcCkR0pr0=; b=XOTfXlJGrqsxYssl4jfc22+FpVokHLgP2xSyxP1SBzWzjtCPlWeky4CcC6njsN7gFr J8Ph+q0ftlQRJnl63eCpM5aaPfmT4rgcnFCyVJWeGN+ooruhQZflNs10SNXTf9tqnOgH +X4aSsgAXSpR8Gi8X3TF9eZ97pvT91QH8kETn+CrFldH28NIlC7JFhb7b5Wa83fYI9ES tfLkwzkuvHNPaMorf/duXVO3gezEQYrxAIcXSSr/uZaG7GmSVaQFh4Qbs/hxpxkwqVQs 6+Pmk6ufQyNqR5WwmczqkEbWwpJq7aQ/BAJYdtW0y/7CoU4ujpwfZKWsEXRiPve/aFPg idOA== X-Gm-Message-State: AOAM5301ihyR2IGYXAIrxzdM7D+EYTJTfs/29I+cMtIjRxOavaEPFc/1 rJxdY9d5OWBTJXfiW66JnshCjMH2qj8OM17qUtXFhB0kko1kYw== X-Google-Smtp-Source: ABdhPJzTAV0Z/nQEEkMh9yiYW4RKcUHjVc9JaDjRr0t/up16kvUiiHUDz4jUmyXpxongaok395P+ZuBbQuR1Yc+ruJU= X-Received: by 2002:a6b:f411:0:b0:657:b73f:8e97 with SMTP id i17-20020a6bf411000000b00657b73f8e97mr11117665iog.68.1651771661067; Thu, 05 May 2022 10:27:41 -0700 (PDT) MIME-Version: 1.0 References: <20220505121329.GA32827@us192.sjc.aristanetworks.com> In-Reply-To: From: Ganesan Rajagopal Date: Thu, 5 May 2022 22:57:03 +0530 Message-ID: Subject: Re: [PATCH] mm/memcontrol: Export memcg->watermark via sysfs for v2 memcg To: Shakeel Butt Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Cgroups , Linux MM Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=arista.com header.s=google header.b=QOOvGNSB; dmarc=pass (policy=reject) header.from=arista.com; spf=none (imf06.hostedemail.com: domain of rganesan@arista.com has no SPF policy when checking 209.85.166.42) smtp.mailfrom=rganesan@arista.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1496E1800A2 X-Rspam-User: X-Stat-Signature: znpj71exiyhaatmkqcjksj8ahmkcurxd X-HE-Tag: 1651771659-362840 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000055, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, May 5, 2022 at 9:42 PM Shakeel Butt wrote: > > On Thu, May 5, 2022 at 5:13 AM Ganesan Rajagopal wrote: > > > > v1 memcg exports memcg->watermark as "memory.mem_usage_in_bytes" in > > *max_usage_in_bytes Oops, thanks for the correction. > > sysfs. This is missing for v2 memcg though "memory.current" is exported. > > There is no other easy way of getting this information in Linux. > > getrsuage() returns ru_maxrss but that's the max RSS of a single process > > instead of the aggregated max RSS of all the processes. Hence, expose > > memcg->watermark as "memory.watermark" for v2 memcg. > > > > Signed-off-by: Ganesan Rajagopal > > Can you please explain the use-case for which you need this metric? > Also note that this is not really an aggregated RSS of all the > processes in the cgroup. So, do you want max RSS or max charge and for > what use-case? We run a lot of automated tests when building our software and used to run into OOM scenarios when the tests run unbounded. We use this metric to heuristically limit how many tests can run in parallel using per test historical data. I understand this isn't really aggregated RSS, max charge works. We just need some metric to account for the peak memory usage. We don't need it to be super accurate because there's significant variance between test runs anyway. We conservatively use the historical max to limit parallelism. Since this metric is not exposed in v2 memcg, the only alternative is to poll "memory.current" which would be quite inefficient and grossly inaccurate. Ganesan