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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 3920EC2BB48 for ; Mon, 14 Dec 2020 16:09:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BB3F522581 for ; Mon, 14 Dec 2020 16:09:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB3F522581 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E05286B005C; Mon, 14 Dec 2020 11:09:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D8F5F6B0068; Mon, 14 Dec 2020 11:09:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C58EC6B006C; Mon, 14 Dec 2020 11:09:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id A8A746B005C for ; Mon, 14 Dec 2020 11:09:43 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 36DFC3634 for ; Mon, 14 Dec 2020 16:09:43 +0000 (UTC) X-FDA: 77592373446.26.shade01_2f132fc2741c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 130361804B640 for ; Mon, 14 Dec 2020 16:09:43 +0000 (UTC) X-HE-Tag: shade01_2f132fc2741c X-Filterd-Recvd-Size: 4438 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Dec 2020 16:09:42 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1607962181; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mVw6A+VmEZnGU5UbQJtMjZcuFnEzlOyR2LJ+wH8Rnyo=; b=JWShAHe4y07qCFgY/VCavebi85RCFeNCW1ilZALRkKterJvVPMNVFfKcV+UDHD/uNuZACn VcNAPLqExzO/k2bsCbBG2z3d37N/7ldaww+MWn348HHYKaoXx+qTHnH7tSCyzh7TqqpEGv nA2A88It/bbDmvNZuh1CqqHKNwOTRks= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0A48DAC10; Mon, 14 Dec 2020 16:09:41 +0000 (UTC) Date: Mon, 14 Dec 2020 17:09:39 +0100 From: Michal Hocko To: Johannes Weiner Cc: Vlastimil Babka , Yu Zhao , Andrew Morton , Joonsoo Kim , linux-mm@kvack.org Subject: Re: [PATCH] mm: don't SetPageWorkingset unconditionally during swapin Message-ID: <20201214160939.GJ32193@dhcp22.suse.cz> 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.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu 10-12-20 06:21:57, 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. > > 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. This is a useful information, thanks! Yu Zhao can you make it into the changelog so that we have it for a future reference please? Feel free to add Acked-by: Michal Hocko -- Michal Hocko SUSE Labs