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 D1F24EB64DD for ; Wed, 5 Jul 2023 13:45:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5853A8D0002; Wed, 5 Jul 2023 09:45:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 535278D0001; Wed, 5 Jul 2023 09:45:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 426318D0002; Wed, 5 Jul 2023 09:45:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 31FDA8D0001 for ; Wed, 5 Jul 2023 09:45:48 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 06240B05FF for ; Wed, 5 Jul 2023 13:45:48 +0000 (UTC) X-FDA: 80977681176.12.39F2866 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) by imf01.hostedemail.com (Postfix) with ESMTP id 24DCF40006 for ; Wed, 5 Jul 2023 13:45:45 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=1YaPE2cN; spf=pass (imf01.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.180 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688564746; 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=vhVVYDS8SeKVHr9R1nEvh9jKIZzXtU+coyKWJqnnG/4=; b=2qtbrH4JycTY0XvuTW2OP+TPrBWiv0ua+22EwFvYHqckyFD3ZBhAa2EgmOSJ33iZ1FkEMq DWwQgtFU0fz5mpWRPBqxS7K9FHzybP92Zw+F3dYi/RdM4ulFCi+R132EazCc8g/1Fec4GT SZ+8HDvw7RZXt3lUpErFkfrQNIZQ7Kw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688564746; a=rsa-sha256; cv=none; b=JAW6nDmWhZxcqDrur5XVzLD8aMV3iG417a1iTh9+IrLAsPZBZ/+txtPGyiq+uKpxSsp0bu u3G+0B9Z+F1qTfN1uC8xx/iLLSxu6kgo5DHm+TFfyGhpggv7v6E0y2luhDfcmkhEuIfrOg 8O46KzcZwcKXLcG8lVqdPKFRBYJfhPg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=cmpxchg-org.20221208.gappssmtp.com header.s=20221208 header.b=1YaPE2cN; spf=pass (imf01.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.180 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-76571dae5feso601298385a.1 for ; Wed, 05 Jul 2023 06:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20221208.gappssmtp.com; s=20221208; t=1688564745; x=1691156745; 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=vhVVYDS8SeKVHr9R1nEvh9jKIZzXtU+coyKWJqnnG/4=; b=1YaPE2cNCl6KjPwF/B9ho3gStPjZTWQAoK46cJUhHQuuKdcuOSq7ePJCcJuVPxIBPc A6H2tQW0Knsxo3rQ0i8Z0L2HGQYHnGuZ0G3cFUQJgJqe5djxD+twFRQ2zZgCMROBuEw2 noCqssAYYqTCIgp1Loz+sNLEb3y5uBXB9NR2MlbjMHJUG6fGebZRuyfDA4PwlRr58Fmd JfHsKjI4XnKgXmLsWH3hIS/N+EXAcdOGu3Fhgn5rhpwutz5bL89Jt3VnnEoYi0qvve+j 3c3tSj0yWySAa2lER2dV9S8/MgJIjr/k9xcb2uDhsiSe5izglZLXq5rYIjzawa3bUHHX bxJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688564745; x=1691156745; 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=vhVVYDS8SeKVHr9R1nEvh9jKIZzXtU+coyKWJqnnG/4=; b=RRsyIiLvlUriQ5qE9duEXfRjOdrLedlChWiSf25wzAVhuFY3ENJc2/qzeY7SoGXNGm fNCtfZck5KsGkig0ZANwasIz96YSq3SiHJUVqS96yrTRUg79i+lRZegtkI5QL+CKcsP3 kLhQE97C8I3sgytfJVOzFYTTvfWFwmeTZ8oPgdTUHy7TRCFT93LLP8jtZwGOHjdQ88lj UCieEtgNqkMNWovsq5dSVVoXYh1YBM3SNMNHc6qMD5FTBNda7nrEM6EBrLTRZox8WadB 9mLOgoxsQMQOy43fUyU5+PcWHZCx0SF6BVm3Mc6h3vpLeP6q4W8aNPp0/+j655oBG+LP az9Q== X-Gm-Message-State: AC+VfDyE9s5MMBl6eMZyYDzVdo8ehm4fPWXWoHucG1J7Z7lvOzOIJtrV WcvcAKDxSGavHCvYcGH5hn3BkQ== X-Google-Smtp-Source: ACHHUZ7mlgtrJCdxWcClgY0y50S27TG/hIFeDTqIUNJW13mzTvtpAxaRi6M5hIYSJJ4s3LSMXeWVlg== X-Received: by 2002:a05:620a:280d:b0:767:2a7e:1dbc with SMTP id f13-20020a05620a280d00b007672a7e1dbcmr15290826qkp.17.1688564744876; Wed, 05 Jul 2023 06:45:44 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-8f57-5681-ccd3-4a2e.res6.spectrum.com. [2603:7000:c01:2716:8f57:5681:ccd3:4a2e]) by smtp.gmail.com with ESMTPSA id d3-20020a05620a166300b007678ee16016sm820747qko.45.2023.07.05.06.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 06:45:44 -0700 (PDT) Date: Wed, 5 Jul 2023 09:45:43 -0400 From: Johannes Weiner To: Charan Teja Kalla Cc: akpm@linux-foundation.org, surenb@google.com, minchan@kernel.org, quic_pkondeti@quicinc.com, quic_smanapra@quicinc.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V3] mm: madvise: fix uneven accounting of psi Message-ID: <20230705134543.GB156754@cmpxchg.org> References: <1688393201-11135-1-git-send-email-quic_charante@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1688393201-11135-1-git-send-email-quic_charante@quicinc.com> X-Rspamd-Queue-Id: 24DCF40006 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: fakore1qsp1j3qftbc7u3spptz84et36 X-HE-Tag: 1688564745-24356 X-HE-Meta: U2FsdGVkX19WiR+lyFGUKtYMEaXptG29qmseRljVI/nkl7MBxzP4JKikLev7KpOOoaa0dc+KOXVBMtBC4WtAZoqWhRpTMRpJRKQukj6DO5XSTpHtOjivISBDskRGItPm2VtxtcjPI+TYWSIOGBOLHDUb5E6EC/8Ga1G/Ffnolzx6f+bzAFiMOr29pez1LYd/FHsXg7E/nr2v3JPf5SA4nmpIwd9FVxokIwXZlFNoc6FwDo6+gu3fiJmWRQK5GM7F3vNRyxIPksJWx+23TMF1QNDqFdUn2WLjjWKANym1S0BHUvULRTNOE4RQaL79+UXrsoxHxM6V4Yd17lbrF2iJBrtnngqQq615kZTyIDvOWq/sbdiFh4GWoBiYXUWAUFtecfJ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LQQQOzEdk0T/U7+vcTBfD2h4b/JBp4I21BWDOogkn+utBmxSrmChQQbRV+Q70xhUOOU7RKXo246fOMY20hKRVGi76BOFFn9QRZ82j5z2RscwD43nkglW8srns9SrVWZdQpvu X-Bogosity: Ham, tests=bogofilter, spamicity=0.000029, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jul 03, 2023 at 07:36:41PM +0530, Charan Teja Kalla wrote: > A folio turns into a Workingset during: > 1) shrink_active_list() placing the folio from active to inactive list. > 2) When a workingset transition is happening during the folio refault. > > And when Workingset is set on a folio, PSI for memory can be accounted > during a) That folio is being reclaimed and b) Refault of that folio, > for usual reclaims. > > This accounting of PSI for memory is not consistent for reclaim + > refault operation between usual reclaim and madvise(COLD/PAGEOUT) which > deactivate or proactively reclaim a folio: > a) A folio started at inactive and moved to active as part of accesses. > Workingset is absent on the folio thus refault of it when reclaimed > through MADV_PAGEOUT operation doesn't account for PSI. > > b) When the same folio transition from inactive->active and then to > inactive through shrink_active_list(). Workingset is set on the folio > thus refault of it when reclaimed through MADV_PAGEOUT operation > accounts for PSI. > > c) When the same folio is part of active list directly as a result of > folio refault and this was a workingset folio prior to eviction. > Workingset is set on the folio thus the refault of it when reclaimed > through MADV_PAGEOUT/MADV_COLD operation accounts for PSI. > > d) MADV_COLD transfers the folio from active list to inactive > list. Such folios may not have the Workingset thus refault operation on > such folio doesn't account for PSI. > > As said above, refault operation caused because of MADV_PAGEOUT on a > folio is accounts for memory PSI in b) and c) but not in a). Refault > caused by the reclaim of a folio on which MADV_COLD is performed > accounts memory PSI in c) but not in d). These behaviours are > inconsistent w.r.t usual reclaim + refault operation. Make this PSI > accounting always consistent by turning a folio into a workingset one > whenever it is leaving the active list. Also, accounting of PSI on a > folio whenever it leaves the active list as part of the > MADV_COLD/PAGEOUT operation helps the users whether they are operating > on proper folios[1]. > > [1] https://lore.kernel.org/all/20230605180013.GD221380@cmpxchg.org/ > > Suggested-by: Suren Baghdasaryan > Reported-by: Sai Manobhiram Manapragada > Reported-by: Pavan Kondeti > Signed-off-by: Charan Teja Kalla Acked-by: Johannes Weiner Thanks Charan