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 X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E428C433FE for ; Thu, 10 Dec 2020 22:44:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EF744235F7 for ; Thu, 10 Dec 2020 22:44:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF744235F7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 52C3D6B0036; Thu, 10 Dec 2020 17:44:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DB626B005D; Thu, 10 Dec 2020 17:44:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C9E66B0068; Thu, 10 Dec 2020 17:44:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id 22AF56B0036 for ; Thu, 10 Dec 2020 17:44:45 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D9E12180AD83A for ; Thu, 10 Dec 2020 22:44:44 +0000 (UTC) X-FDA: 77578853688.28.flag72_370e462273fc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id BA5466D71 for ; Thu, 10 Dec 2020 22:44:44 +0000 (UTC) X-HE-Tag: flag72_370e462273fc X-Filterd-Recvd-Size: 5760 Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Dec 2020 22:44:44 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id r9so7457208ioo.7 for ; Thu, 10 Dec 2020 14:44:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZQ6TDQDqqmutEQ+7fq+xgpMKl1n5P7G0kcLiBnrfpvs=; b=ICztUFiOrInYPK01CVxY5RnPzF/UGyhzgAfdmqqt4M2FiZOHRpCDh+aj70Z6c4O0cA fm2DXMFa+4jqCqIC2H5LkBGPHMkYL72bNE0ph0sj548+f6SECAc2dNMt9YPXsTD0nWLc pYcafddS2vokU+tn0FtguaUb3YTV6s09XITIQdxSOJZUDnt+BaBTDam87nnyf33lYYxb 1XXvAbgMtNHsH1CvqmYr2M2+Hq48Ix2vn5a9QIYk7tLA27HYsKQQ4cTfvED4cCOsu1i0 RHV9tn3ZE+ZlVh3PDWeYcyKnCIBSRizgp8p3kTRo3GyntiYfvWkduU1DaUHpUBXsVL6P DaEw== 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:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZQ6TDQDqqmutEQ+7fq+xgpMKl1n5P7G0kcLiBnrfpvs=; b=KAQyJvxUDX7c25b+7NB5AYYSCeJN5fCsS4JnjpCn/gWu6fOrHcM68W5ELQPi/t+/bw unS3OvMbkjP0SI5s2WizlKLyctMEX4RDE0k9Ioj0AjD+/W2odHGUutawM2tmKx8oxcRu SiKN0lmYhgolgd/S4kLN+oKKRKMpikiS9F5fH+zcU4m3ybeIXDKwK0xnhGe8i7k89bur fJ6jUXTUyhDRfHeoyjRydhXsyULxsVL2hTPWhQiznzWmlhVncguo+GgfTmTXuCNDOaLq a6DvgiT20mQtvq9/fG8lp9iASFFZLELW7jgFULoW8DZ9yUcoTALZ+A2xVptSvvLEDCr7 B8sQ== X-Gm-Message-State: AOAM53145Q4vrp9lpLjNXJQ/bMvwvL6REbQlqw+clpp1ajpLITHS4KMr T+9kQ2POxh79a3hIbnV+/sIzQw== X-Google-Smtp-Source: ABdhPJzm0vIRptwZPdCVtMk3UdRaFKLTwVIGKlllxfCCfpVFOB+38yailcdIrliUHkRjRqryiDTiDw== X-Received: by 2002:a6b:6016:: with SMTP id r22mr10929297iog.93.1607640283462; Thu, 10 Dec 2020 14:44:43 -0800 (PST) Received: from google.com ([2620:15c:183:200:7220:84ff:fe09:2d90]) by smtp.gmail.com with ESMTPSA id z13sm3316926iof.19.2020.12.10.14.44.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Dec 2020 14:44:42 -0800 (PST) Date: Thu, 10 Dec 2020 15:44:38 -0700 From: Yu Zhao To: Johannes Weiner Cc: Vlastimil Babka , Andrew Morton , Joonsoo Kim , linux-mm@kvack.org Subject: Re: [PATCH] mm: don't SetPageWorkingset unconditionally during swapin Message-ID: References: <20201209012400.1771150-1-yuzhao@google.com> <805d0032-4f73-cdb8-758a-1c1c1fb73f4c@suse.cz> <20201210112157.GB264602@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201210112157.GB264602@cmpxchg.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000396, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Dec 10, 2020 at 06:21:57AM -0500, Johannes Weiner wrote: > On Wed, Dec 09, 2020 at 10:18:22AM +0100, Vlastimil Babka wrote: > > On 12/9/20 2:24 AM, Yu Zhao wrote: > > > We are capable of SetPageWorkingset based on refault distances after > > > commit aae466b0052e ("mm/swap: implement workingset detection for anonymous LRU") > > > This is done by workingset_refault(), which is right above the > > > unconditional SetPageWorkingset deleted by this patch. > > > > > > The unconditional SetPageWorkingset miscategorizes pages that are > > > read ahead or never belonged to the working set (e.g., tmpfs pages > > > accessed by fd). When those pages are swapped in (after they were > > > swapped out) for the first time, they skew PSI (when using > > > async swap). When this happens again, depending on their refault > > > distances, they might skew workingset_restore_anon counter in > > > addition to PSI because their shadows say they were part of the > > > working set. > > > > > > Signed-off-by: Yu Zhao > > > > Acked-by: Vlastimil Babka > > > > Makes sense, especially now that we have anonymous LRU support. The flag setting > > in this context seems to go back all the way to 1899ad18c607 ("mm: workingset: > > tell cache transitions from workingset thrashing") where I'm not sure why it was > > even used on the anonymous page, when workingset was only implemented for the > > page cache. Maybe Johannes remembers? > > I just double checked that commit and the changelog is indeed > incomplete and doesn't mention the swap aspect. :( > > That patch was part of the psi series. It was meant to mark incoming > pages under IO with SetPageWorkingset when waiting for them > constituted a memory stall. > > On the page cache side, because we HAVE workingset detection, this was > specific to recently evicted pages that had been active in their > previous life. On the anon side, the aging algorithm had no > distinction between workingset and sporadically used pages. Given the > choice between a) no swapin stalls are pressure and b) all swapin > stalls are pressure, I went with the latter in order to detect swap > storms. The false positive case - high rate of swapin without severe > memory pressure - was relatively unlikely, because we tried to avoid > swapping until everything was completely on fire in the first place. This was my guess too -- and it makes sense to go with b) at that time. Thanks for confirming. > With the lru balancing rework, more prevalent use of proactive reclaim > etc. the distinction between hot and cold swapins became more > important. Thankfully, Joonsoo's patches made that possible.