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=-8.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 E638FC4361B for ; Thu, 10 Dec 2020 11:24:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C728B23C18 for ; Thu, 10 Dec 2020 11:24:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C728B23C18 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E9F726B0068; Thu, 10 Dec 2020 06:24:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E4F8A6B006C; Thu, 10 Dec 2020 06:24:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D23A06B006E; Thu, 10 Dec 2020 06:24:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id B6A876B0068 for ; Thu, 10 Dec 2020 06:24:05 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7A304181AEF30 for ; Thu, 10 Dec 2020 11:24:05 +0000 (UTC) X-FDA: 77577138450.06.body64_0b1318b273f7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 551201003DB18 for ; Thu, 10 Dec 2020 11:24:05 +0000 (UTC) X-HE-Tag: body64_0b1318b273f7 X-Filterd-Recvd-Size: 5484 Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by imf21.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Dec 2020 11:24:04 +0000 (UTC) Received: by mail-ej1-f65.google.com with SMTP id ga15so6805684ejb.4 for ; Thu, 10 Dec 2020 03:24:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=+V8lyDZUVYh93FR90drCQziVUnFuKkHHniZbuJrjNsQ=; b=x+TQtS8xMLy5WYwp5LZDk1X/s4l0+elZOsaGmq5PmtTR5NF2MdHiHXsds/Upo7Tq6f 3cpVIFYg/jZqEfCVv/1Kjkn7ixgYxm5Wg3SFOHlOd4X1raw0y59enW1Wwr+BGYhNLdxy k0eGKqjpILZTOB9itqmxYH0c1ycrdrCAkbge7ZhW2DXPKDUV6XxEvoDPmtGGQF05PZWz Z0nJLUXJe/LVkgHoa8nvXiugqw+ajhygxDDeggxBMPtq/H8g7JgrC6Bw64ZHUPbU3E5Y XVMiZQt3z5J3J6kItZNQTh2sa5Nz3YPi8kqKtAVDCIPbenr8yG+9I1HeXI3ZQp2zKGtm Ur2A== 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=+V8lyDZUVYh93FR90drCQziVUnFuKkHHniZbuJrjNsQ=; b=Sjhhb8AL6dGSL0wDIUs682u1i5RlwmYh3kEJG6G0wcaJAvhZGpQ7zPu9e5WCQ2sToO bgrquNxTUN/vXf15SLuHTTmy4Vp7627WTYj1gpHwCikQ+uIJB8fwmKD3XNcMVrVg6NiT 1mWLfLMOHLnwavq8v56vhKlB/DWsQ5A1BCw7L1h87pWPinEfNBaun7LscPXZAZmDcaaA vLNMaLo8vGxvwODvSQTJzbljf0qvUEaDfWH9/2Y4MOzMDqBb6WYT9+6S9ydZVjk0fDBM G8hKgXxvsOelUffFUqmRj8wkMXOkW6/9pIkIu2BPIiUgjx6jand6GitNJ1VZ9UiDLVXz TeUQ== X-Gm-Message-State: AOAM530NREiIJYladdmeNlMsrvTGgskC/vLJHsYrwz4Qju+paSeXwrYI S7mWFQgUxDMhRZRvBKb7urD+wA== X-Google-Smtp-Source: ABdhPJwD/D3e3xAJk8MaAk855pX+/6E6gMpxOiZao7qlMqcWAgG900hpRzIqz8sWQzm4Wd2g7enVPw== X-Received: by 2002:a17:906:814a:: with SMTP id z10mr5786143ejw.96.1607599443329; Thu, 10 Dec 2020 03:24:03 -0800 (PST) Received: from localhost ([163.114.131.1]) by smtp.gmail.com with ESMTPSA id h12sm4274588ejx.81.2020.12.10.03.24.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Dec 2020 03:24:02 -0800 (PST) Date: Thu, 10 Dec 2020 06:21:57 -0500 From: Johannes Weiner To: Vlastimil Babka Cc: Yu Zhao , Andrew Morton , Joonsoo Kim , linux-mm@kvack.org Subject: Re: [PATCH] mm: don't SetPageWorkingset unconditionally during swapin Message-ID: <20201210112157.GB264602@cmpxchg.org> References: <20201209012400.1771150-1-yuzhao@google.com> <805d0032-4f73-cdb8-758a-1c1c1fb73f4c@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <805d0032-4f73-cdb8-758a-1c1c1fb73f4c@suse.cz> 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 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. 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.