Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2501830rwi; Fri, 28 Oct 2022 07:49:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4SEaZFhKbslP2AyneuQ7rZDMcn/7ECS/tDpACDXL+a03ia5DmxLPKiVmQqtdZeyN4v3Q58 X-Received: by 2002:a05:6402:2791:b0:461:c5b4:d114 with SMTP id b17-20020a056402279100b00461c5b4d114mr24836060ede.357.1666968542656; Fri, 28 Oct 2022 07:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666968542; cv=none; d=google.com; s=arc-20160816; b=ilv7DODhXurBkX0lHHN0lgkiS56+i5IifdSor++8PMNmS8qRHQ3zj1m6ABgnl/Fvyw 1Cgwwmvg5EY+3DQFe3l6GpSDL4Y+gj1LTcAaTSf0HADI0xWfCGQIiarmkeiGYcQFvHLu EwjyWNC7At2/i2ps9rSzRizLJWm1qUUsUE087W5NxKbUErlY8XbprPDdCP1XOF+HkFXD NkBccdtSn+lsY+sRdxJ4+g+HhZSvt8oVsBYSq64xqvmdEOoFdA0fVC+VoWrXSvWHXR+u jfUhJPj3+F2+LfKdnMxndjUvEsej0ie+27OeuLNd7KIFOZaE3R7sjBsZKZ1B9HfUF8U4 rPuQ== 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=dBCtjSxtj1jp0cjAy0wlS6C+ZFHd66+P95yTGOU8r4I=; b=ZVHQA5f7PgfhwM7jmeqOUmY7GCrcRB4fQItBy7TkRc3Veoxh7LOVvptXwqYZMxXXbb cKJJ+tJrdMFAEw9KBfCs24VUodUs6GfIEgvr9VWvJbJbj3Nq1a5Prp6x3GzgjF1fGvLD 6kne31J7J38IzKmo5FduVbeQsY4s5XxAwdTkXLm2W2IWtrD6mKEtZDJGkqcbZjzSnljy SxAXs3pxOxO1PdMkXhvg3eBLsxgxHFEKXeWrgpt7Znq9J0D66vytQVeGSU2XeSdS3evq BwPJy4HkOeZVvFFKPQ/h+tuSd7yBti0NP2CsAuEpGScZPqHwqLNXwucn+e8WNatvSv67 sgNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=edzmOuuY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg8-20020a170907970800b0078dcd448f97si1691029ejc.801.2022.10.28.07.48.35; Fri, 28 Oct 2022 07:49:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=edzmOuuY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229773AbiJ1OkK (ORCPT + 99 others); Fri, 28 Oct 2022 10:40:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbiJ1Ojp (ORCPT ); Fri, 28 Oct 2022 10:39:45 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8030C1A39E for ; Fri, 28 Oct 2022 07:39:41 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id j6so4153050qvn.12 for ; Fri, 28 Oct 2022 07:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=dBCtjSxtj1jp0cjAy0wlS6C+ZFHd66+P95yTGOU8r4I=; b=edzmOuuY3YIwYEwDSYZfp6u2vQbVY9m85M3yA9Z6k1GH7Cx3U4Mr8YF7BYf1LQKc/c 7aSzB5JyRLguKzMy2j7ANrS/KJULur1dH0RL4S1FrhYhwwbQD7gwZmo00JeH/r9HiCO5 +tXdyuwfXDCiMFZrgQKRi3wXi08AV9bmbQQyv5v7Z0v4TMWfFEXKJtRzkdBm6Z7SxR3H XlJU9vO5k+fNcvZrfoJMIhdLuPBpF6RsrsBusRyUpAksFRQNxc3CjNZYVnubtDTGpkN2 Wr9T/8LwvAK7uQzWErg55cOeRwA9iyOmSorh7y9KISqs6QIVQfhYmqCqhhSiRGzlUr8F AQgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dBCtjSxtj1jp0cjAy0wlS6C+ZFHd66+P95yTGOU8r4I=; b=4IF/WvN2CORBpCabweTyGV536zjbSMI1YRm8Dr7SbWV9lqWoPSgJHu4pUnDR0+qcCQ qAO7EpwMiWELypl2syOd/mo7Nt2nnrX4dR4KHxEOzNPQsXtOe8T2t5nWJCo36c+/thZd tnAJeNtvzcyVgH9tagHZVQSNVXACQW5cb0SJk5mwm0wSdRvDP1fL7hBhkYOvM1UG10qq 2Yoo+1v0ijwWaW6wQ8ys/aQBcAX0ojcfBuAYQtEZvC4laKR5Q2AsJVi/AwmVo9Fe7hd1 s5hrZ3GLoXvG+RgW+8AgqgzZ1i+8LGyIb6bjKv/HIe5W5x+YhpLkNJrd7UIdBpTBP0d9 15Lg== X-Gm-Message-State: ACrzQf3LlBrHyhAoGwORK1me+KEHT5KKh3G6gn1NJ3tn4B6RXRMnGpHN +GU6t0gUP+YOt7Ufl3iCRQMgYZDaT9MPTA== X-Received: by 2002:ad4:574c:0:b0:4bb:7477:f13d with SMTP id q12-20020ad4574c000000b004bb7477f13dmr21410870qvx.39.1666967980492; Fri, 28 Oct 2022 07:39:40 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::25f1]) by smtp.gmail.com with ESMTPSA id f2-20020ac84702000000b003a50c9993e1sm509704qtp.16.2022.10.28.07.39.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 07:39:39 -0700 (PDT) Date: Fri, 28 Oct 2022 10:39:40 -0400 From: Johannes Weiner To: Yosry Ahmed Cc: Yang Shi , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Eric Bergen Subject: Re: [PATCH] mm: vmscan: split khugepaged stats from direct reclaim stats Message-ID: References: <20221025170519.314511-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Thu, Oct 27, 2022 at 01:43:24PM -0700, Yosry Ahmed wrote: > On Thu, Oct 27, 2022 at 7:15 AM Johannes Weiner wrote: > > On Wed, Oct 26, 2022 at 07:41:21PM -0700, Yosry Ahmed wrote: > > > My 2c, if we care about direct reclaim as in reclaim that may stall > > > user space application allocations, then there are other reclaim > > > contexts that may pollute the direct reclaim stats. For instance, > > > proactive reclaim, or reclaim done by writing a limit lower than the > > > current usage to memory.max or memory.high, as they are not done in > > > the context of the application allocating memory. > > > > > > At Google, we have some internal direct reclaim memcg statistics, and > > > the way we handle this is by passing a flag from such contexts to > > > try_to_free_mem_cgroup_pages() in the reclaim_options arg. This flag > > > is echod into a scan_struct bit, which we then use to filter out > > > direct reclaim operations that actually cause latencies in user space > > > allocations. > > > > > > Perhaps something similar might be more generic here? I am not sure > > > what context khugepaged reclaims memory from, but I think it's not a > > > memcg context, so maybe we want to generalize the reclaim_options arg > > > to try_to_free_pages() or whatever interface khugepaged uses to free > > > memory. > > > > So at the /proc/vmstat level, I'm not sure it matters much because it > > doesn't count any cgroup_reclaim() activity. > > > > But at the cgroup level, it sure would be nice to split out proactive > > reclaim churn. Both in terms of not polluting direct reclaim counts, > > but also for *knowing* how much proactive reclaim is doing. > > > > Do you have separate counters for this? > > Not yet. Currently we only have the first part, not polluting direct > reclaim counts. > > We basically exclude reclaim coming from memory.reclaim, setting > memory.max/memory.limit_in_bytes, memory.high (on write, not hitting > the high limit), and memory.force_empty from direct reclaim stats. > > As for having a separate counter for proactive reclaim, do you think > it should be limited to reclaim coming from memory.reclaim (and > potentially memory.force_empty), or should it include reclaim coming > from limit-setting as well? A combined counter seems reasonable to me. We *have* used the limit knobs to drive proactive reclaim in production in the past, so it's not a stretch. And I can't think of a scenario where you'd like them to be separate. I could think of two ways of describing it: pgscan_user: User-requested reclaim. Could be confusing if we ever have an in-kernel proactive reclaim driver - unless that would then go to another counter (new or kswapd). pgscan_ext: Reclaim activity from extraordinary/external requests. External as in: outside the allocation context.