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 717A8C38A02 for ; Fri, 28 Oct 2022 14:39:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A8E46B0074; Fri, 28 Oct 2022 10:39:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8592F6B0075; Fri, 28 Oct 2022 10:39:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 722A56B0078; Fri, 28 Oct 2022 10:39:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6479D6B0074 for ; Fri, 28 Oct 2022 10:39:43 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3D416ABCA4 for ; Fri, 28 Oct 2022 14:39:43 +0000 (UTC) X-FDA: 80070617046.10.3E6A074 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) by imf19.hostedemail.com (Postfix) with ESMTP id 51CD71A0007 for ; Fri, 28 Oct 2022 14:39:41 +0000 (UTC) Received: by mail-qv1-f54.google.com with SMTP id w10so4176264qvr.3 for ; Fri, 28 Oct 2022 07:39:40 -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=NIOtfcG07loQ0/lQp1sSmRNk0FJkCjXcqCvThs97+Xz7VOKA2yUWF5Ep6lSL2TcXN4 qrwHLMhg/fW9ztS5/rF/jb/sUcCDxmw2K0Qs3nPWBIVZvmezinv7LaB335COWNDmhq5f Y6vPlpXSihn7wrtQb9Ve+kmw3Yu8Hut+ANO61SLkROMlKuGYLJME5k1JfWSD4OqVWR7j fkjOwHF4ARGEJsJSeGR47l57qsDYDSUT6obV6JEzRXpcs/uKj0aHaVpshT/q69RooEef Ldj1g617s084kP9YPkZ//+OTYfYXrKVqk4UROJq75MZVxDdJmCz/7wfm22UGVNhm7hsJ h6tQ== X-Gm-Message-State: ACrzQf3FGuUf8QW6PXRLe0qwDlyhDrA/novqfhW5SsVKqswTKjh/SupQ ltjFSUo6dM717Ndgb+HF+XLFxg== X-Google-Smtp-Source: AMsMyM7ZMF8C2IdV3u0R8roPa1lWIi39iEVAGYABmSKIQLm0dA3mCkwgONkiC5lWSV12aiYnccmPaA== 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: ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=edzmOuuY; spf=pass (imf19.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.54 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666967981; a=rsa-sha256; cv=none; b=uxl/FCU6fQZ5saHh2uhL+4hWbW8E1KI9SCKZUqnwiq9LBnX5ecpQzXikvAC6negTWgN6Nh ZtOCikg1RI8Q7aRtmt+cMh0uL1cQRdUeXxK2DQmXViYKUSZpF+Udfq6W5zpB+M7rLwqxSP yIMp93zUBDQlxAtob6XWgxYGwO1HT8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666967981; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dBCtjSxtj1jp0cjAy0wlS6C+ZFHd66+P95yTGOU8r4I=; b=kp/Ht5yXkVaZVUCmmsTWPPXxpRvC4q8o2Ad93wL/xeKXKwvDP6Swy7TZPDV9QeGQtYK5ak wOQcZ5OgTEawsRBmK592P0OBzvGgZSYBwIQnlcAGV/WVN2JE+q6k3SMS3W1lfkSOeS5Yz6 Dgg9C65Wcy6UkWbRND7l1GevXKjzLX4= X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=edzmOuuY; spf=pass (imf19.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.54 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org X-Rspamd-Server: rspam07 X-Stat-Signature: erzo4ykp7psysi19cfh5cbfurnau4t8i X-Rspamd-Queue-Id: 51CD71A0007 X-HE-Tag: 1666967981-218512 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.