Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1381834pxv; Fri, 2 Jul 2021 02:22:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpg4W++MOG2e4BU5k1FExyMaHxqwsbLRs1a5prCLqr0Hyn0+3vt4gbKf/hdRyx2zdVscDn X-Received: by 2002:a05:6402:1d25:: with SMTP id dh5mr5552527edb.355.1625217739689; Fri, 02 Jul 2021 02:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625217739; cv=none; d=google.com; s=arc-20160816; b=NpsGnBRvfv/uwccyKf4pZ9teb8BxTCUf9Jebbr9KUzqz+bmgeeoj2kvfZrzyfvF/Z3 h+kcPy+pMND0DmQSh3JnByWCRfXbGYSLrls973KdogC3+7Cy1D3VrPSfqJw2+LnEamkG BeLzmmrsfXUo7jzc/Gc8gvyILiGl58SwdZf6ZKYjRhnkoO5dG+WLtzBXY6iITWV20yba f5rJPtoz3XEh7XUX+cW7S4b9FkHNL2TOcrP0wEvSxVyyvHiDciNhMTjSD0jTgI7K/z4F 40KQZqQXO24FVY9pSI34BJz8IVfLPqQo5J4EBkXiFScbT1YILy3uobYaIr4HConbpvny 1UCw== 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=Vy9xdj2QLgIqzr/TgmLE77gLmPWcB0CW7T+Mjh40YGc=; b=VHE5KAiJnOO6Se/I/lUSSKABYjW6yGhEB6zVpcxpmpz6HBuNMQc3JQXmvvkQ5h+H9M bv8vjdBleHLkKeA23KyshRZblCG2xgGFHDWc7LyQYiDW4+YDyRfcVNjF3SSRSYiUjLAg A1VSdnOFDEattTYHQULY1R9QryzWlsHchZAABV1Jrl+l78RQESXFx/tQpC29nYbWEHlZ /Hy6SZSKJVw+HZaEO0euZdpLU5oJlSRoyYp20cTVpp4akYHvkD0P3h6zszvoa2XqxTxe Rt5LVDE/ONOhAaK1ZGy+412oVajAxayibpuzNJgPmyZ40JeNrriQg29g2z1SW9BbFryf RYoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=VAQaWwdM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o21si2293215edc.577.2021.07.02.02.21.54; Fri, 02 Jul 2021 02:22:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=VAQaWwdM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231128AbhGBJKx (ORCPT + 99 others); Fri, 2 Jul 2021 05:10:53 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:46606 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230424AbhGBJKx (ORCPT ); Fri, 2 Jul 2021 05:10:53 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4BD262006A; Fri, 2 Jul 2021 09:08:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1625216900; 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=Vy9xdj2QLgIqzr/TgmLE77gLmPWcB0CW7T+Mjh40YGc=; b=VAQaWwdMVj2o9m81fAuHALE0jIVcwnGjxshViGXKd+wsXn5bTqSdtgFdYG0DDnSmGtE7+u F2s+VgUPZyf2Z8NN1XmybNZgSe0FhTv33uGZZmMsU9Su142BWJIF/s+7Rv6CcvLZVnpuj7 t78uAO9mWgSCzrZheK9G9KPILW5elK4= 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 07E27A3B83; Fri, 2 Jul 2021 09:08:19 +0000 (UTC) Date: Fri, 2 Jul 2021 11:08:19 +0200 From: Michal Hocko To: Krzysztof Kozlowski Cc: Andrew Morton , Johannes Weiner , Vladimir Davydov , linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: Process memory accounting (cgroups) accuracy Message-ID: References: <69ffd3a0-2cb7-8baa-17d0-ae45a52595af@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <69ffd3a0-2cb7-8baa-17d0-ae45a52595af@canonical.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 02-07-21 09:50:11, Krzysztof Kozlowski wrote: [...] > The questions: How accurate are now the cgroup counters? The precision depends on the number of CPUs the workload is running on as we do a per-cpu charge caching to optimize the accounting. This is MEMCG_CHARGE_BATCH (32) pages currently. You can learn more by checking try_charge function (mm/memcontrol.c). > I understood they should charge only pages allocated by the process, so > why mmap(4 kB) causes max_usage_in_bytes=132 kB? Please note that kernel allocations (marked by __GFP_ACCOUNT) are accounted as well so this is not only about mmaped memory. > Why mmap(4 MB) causes max_usage_in_bytes=4 MB + 34 pages? The specific number will depend on the executing - e.g. use up all but 3 pages from CPU0 batch and have 31 pages on another cpu. > What is being accounted there (stack guards?)? > > Or maybe the entire LTP test checking so carefully memcg limits is useless? Well, I haven't really checked details of those tests and their objective but aiming for an absolute precision is not really something that is very useful IMHO. We are very likely to do optimizations like the one mentioned above as the runtime tends to be much more important than to-the-page precision. Hope this clarifies this a bit. -- Michal Hocko SUSE Labs