Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6838445ybi; Wed, 29 May 2019 14:09:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1fFFcnctWW0bzTQc1QhHjke8p4+N4o3z3mMX81it2glrHGTG3CMO/pkhJsRvclPi4sDnK X-Received: by 2002:a17:902:b089:: with SMTP id p9mr26796444plr.38.1559164178862; Wed, 29 May 2019 14:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559164178; cv=none; d=google.com; s=arc-20160816; b=rStskK9Nip6y/qlYQV3MAWhLFqNYINY55b9vgn3nZybHRLBfPzvdO6qTD34ndCn4AC 4w+9VKYMFRIoNWucS1cdUGJ/1NksS1JCLdZcRX+p1FLNAFufu2338imUhrhbbAPxTvxD 6ezrM0KZAwzI3W8XhgBWsjJh8jZp5oapAZEsKx3S+3suwUK8vIy2K8LgydsQkSUmTSQC RIyOYoDaSphaAQG9qdhy7YMqYiD1lDwEIBl94ScIILKeVAitzqINABUEzavvJI6XJx8B zhv5PccHxbZ6yYbvNW2Nlbj7wjpuciiiMcHWaMzl3sgh6VLBnWaVk1pUO8fWmM0IgZxH yOHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature; bh=JDuSTehyNdkjsOxtouLoAdMdAueINAK3K8uBz+p0jwg=; b=C/gtktwqeuDp0SHS0lhue7vCd+GyGkoWTP5ZI0nGzIREa0fzwTaE8DGV26yimHdklA Ze+JjIA4xJMgU/KSDr4+kWyReRhzjUxmwD5fNefJjWiPWE7nOvum/bTD2Ga47T8VTCzX eJGIJTFG5a2efghE1dNGd4xm7F+Nk00YOcL0q/3l8n3Px0YBWEvJNXPCW4BmgSuAjFKi Q7qzAsh9qZbnozBCHgQBI/m+YBeeLoTBK/37EdMzbNaSQOSYrpWdjZnD6xvv365nunve voL5k0cXgnpihAXY8FGb8p8oTzSDps6aw5y7ezhReb+f41OS3eZTeJkhIARqF6Ox+S9X GnjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iCu9MPsy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si915728pgl.310.2019.05.29.14.09.23; Wed, 29 May 2019 14:09:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iCu9MPsy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726581AbfE2VIC (ORCPT + 99 others); Wed, 29 May 2019 17:08:02 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43689 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726428AbfE2VIC (ORCPT ); Wed, 29 May 2019 17:08:02 -0400 Received: by mail-pg1-f193.google.com with SMTP id f25so597109pgv.10 for ; Wed, 29 May 2019 14:08:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=JDuSTehyNdkjsOxtouLoAdMdAueINAK3K8uBz+p0jwg=; b=iCu9MPsyqSyo52dk3bz2YcMkQmNZYRBnUvKfoC/4nlsyxR2kImqL5WSQ/tyUgbQGS5 tWRxoAuFxGICRlXINV3c2tZaoNnVTDCu3AQWUlvkm0C+fQdRbz4FGqR1DvMkNENEbQCo 4mLnFfcmw7g7RiFYFM3uP/L9kskO6vNvXIOsYcoEhUccyXOhOgTv1ZIoqlt4GkhouIyt NoatEjQ0v842w1+LfUE6qcm/wVA+RI1gtWZSmg7y9eYS/xmE8gKbr0HdmnWyXfEA8pYA D2roDVoI+GkFybcqvS37aJdhvvXWEunPHYJZmGU1JBmPeR7muDxlo4h6jHkWn7gz9wTu D19Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=JDuSTehyNdkjsOxtouLoAdMdAueINAK3K8uBz+p0jwg=; b=PZINtSUWLZCN2hIEn4jKmOnae1IfUjduYoqJkE4jwwGNIjmW77xxUlH868LHKfo08Y YeSKIeX8QZsPBdRka0+noTtxHj8eG0Yw3kz9Wi3TPIAl5kMVKPou/XC2f+mmPn6+kD5K rSKi/oK1WxV4LCN32DpfauutXsgvJmIa1MA+5GM+FPNCrSHwsR+S3ZzFlhoG80CHVxM/ DxZkfYFUdu3tiFV6OZb8toqcbPTG6SljiRpJ1sNr66mm4biaEypk6f0sBzR0qCVGjFe0 5b4KhvdeK+o+1KpGTq/vE1sdQOxN9DIFvkZIhLUydIpLGZP4EtMVjyhlPGjwUG0B++k1 S18Q== X-Gm-Message-State: APjAAAUQRd3qahqXekKXz4wVfEIWu8CkeFvKFbIUx1y05R+xupqhLtF3 jZvepmoUJWlUlERrccfSqqmXAQ== X-Received: by 2002:a62:e303:: with SMTP id g3mr150555799pfh.220.1559164080811; Wed, 29 May 2019 14:08:00 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id 25sm574143pfp.76.2019.05.29.14.07.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 14:07:58 -0700 (PDT) Date: Wed, 29 May 2019 14:07:58 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Yang Shi cc: ktkhai@virtuozzo.com, hannes@cmpxchg.org, mhocko@suse.com, kirill.shutemov@linux.intel.com, hughd@google.com, shakeelb@google.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 0/3] Make deferred split shrinker memcg aware In-Reply-To: <2e23bd8c-6120-5a86-9e9e-ab43b02ce150@linux.alibaba.com> Message-ID: References: <1559047464-59838-1-git-send-email-yang.shi@linux.alibaba.com> <2e23bd8c-6120-5a86-9e9e-ab43b02ce150@linux.alibaba.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 29 May 2019, Yang Shi wrote: > > Right, we've also encountered this. I talked to Kirill about it a week or > > so ago where the suggestion was to split all compound pages on the > > deferred split queues under the presence of even memory pressure. > > > > That breaks cgroup isolation and perhaps unfairly penalizes workloads that > > are running attached to other memcg hierarchies that are not under > > pressure because their compound pages are now split as a side effect. > > There is a benefit to keeping these compound pages around while not under > > memory pressure if all pages are subsequently mapped again. > > Yes, I do agree. I tried other approaches too, it sounds making deferred split > queue per memcg is the optimal one. > The approach we went with were to track the actual counts of compound pages on the deferred split queue for each pgdat for each memcg and then invoke the shrinker for memcg reclaim and iterate those not charged to the hierarchy under reclaim. That's suboptimal and was a stop gap measure under time pressure: it's refreshing to see the optimal method being pursued, thanks! > > I'm curious if your internal applications team is also asking for > > statistics on how much memory can be freed if the deferred split queues > > can be shrunk? We have applications that monitor their own memory usage > > No, but this reminds me. The THPs on deferred split queue should be accounted > into available memory too. > Right, and we have also seen this for users of MADV_FREE that have both an increased rss and memcg usage that don't realize that the memory is freed under pressure. I'm thinking that we need some kind of MemAvailable for memcg hierarchies to be the authoritative source of what can be reclaimed under pressure. > > through memcg stats or usage and proactively try to reduce that usage when > > it is growing too large. The deferred split queues have significantly > > increased both memcg usage and rss when they've upgraded kernels. > > > > How are your applications monitoring how much memory from deferred split > > queues can be freed on memory pressure? Any thoughts on providing it as a > > memcg stat? > > I don't think they have such monitor. I saw rss_huge is abormal in memcg stat > even after the application is killed by oom, so I realized the deferred split > queue may play a role here. > Exactly the same in my case :) We were likely looking at the exact same issue at the same time. > The memcg stat doesn't have counters for available memory as global vmstat. It > may be better to have such statistics, or extending reclaimable "slab" to > shrinkable/reclaimable "memory". > Have you considered following how NR_ANON_MAPPED is tracked for each pgdat and using that as an indicator of when the modify a memcg stat to track the amount of memory on a compound page? I think this would be necessary for userspace to know what their true memory usage is.