From patchwork Mon Dec 14 23:12:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11973311 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, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 3C84CC4361B for ; Mon, 14 Dec 2020 23:12:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AE66622510 for ; Mon, 14 Dec 2020 23:12:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE66622510 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 19D746B005D; Mon, 14 Dec 2020 18:12:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 174896B0068; Mon, 14 Dec 2020 18:12:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08B886B006C; Mon, 14 Dec 2020 18:12:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id E6A326B005D for ; Mon, 14 Dec 2020 18:12:56 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A99291F06 for ; Mon, 14 Dec 2020 23:12:56 +0000 (UTC) X-FDA: 77593439952.01.boats51_0b0a5c02741e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 8B165100502B1 for ; Mon, 14 Dec 2020 23:12:56 +0000 (UTC) X-HE-Tag: boats51_0b0a5c02741e X-Filterd-Recvd-Size: 5321 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Dec 2020 23:12:55 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id e68so13479233yba.7 for ; Mon, 14 Dec 2020 15:12:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=WuiZdhFN+3VfOkc9nEWM9V1iavP+4Ch84hh2OEQti94=; b=I3TgwrofnV7UOzNtUH80caWigd6nsaWXjZYSUsz8nHyOw6Vt7rd5VXNHdeCFlOgeOU 8DdjHZNaasi4f8TIrtyW+oHFJkuK1lQwv8qzatHCP0J54/7ioOdCavEfVPXrm0kW8AGN hf82cyEFMqjqhgInrF/kF36d65x/PdC4oFkOWwd+VyZTWtRw+wEAvjEwqQur198o3sP/ cjATw7si5mWudUCgmlN7YZm0ADkmFqf5JFz/bbeTAd5jIESHjB+pvgZmf+cLlvdwYf/r n5qdkxhQ+dPHFOY2Jphf8Go9lingGyYuCoYC9+2UXqWW1gityIEZdsLTS/ltikFV3l4C 3lcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WuiZdhFN+3VfOkc9nEWM9V1iavP+4Ch84hh2OEQti94=; b=nrchXpfU4LxQi1OXthsJvnVGuEg8QavWsJFP5Hbz5fdSSHWgsbCIR4+RVgD/2xoHVo hU2IwY75pkJB31w5TVi+XCg2GLfks834IeCQ3DpHv2elrD3kS/9Vda49bBvpO5uO8ZgO B2erZZUtmTgN/eZkbS+oNfia9iOB1+TStr7apQppXxaMmel3A4WaMcF73fKnRcEVTZCI SKXcEc+6eHvbwsGlAgG2wRs4kXdO8rLItjIZkCOemndPA7k5EdRKQ7rZweJi2KsEJLyQ 7MfFVzgMJnXk4nfN52tIwf8U5kk14oGoSUY3QQ4CGJzwUkQHwiSopjCKZ7eJpu2C6myc CFLg== X-Gm-Message-State: AOAM530RcvmcGu/PKGAZrhXURhwrmkT81tV2oijf08WpyJGy86j4MkyP kEFpn6OfPZNyeoQ8IQxzQIiVVSj9OCg= X-Google-Smtp-Source: ABdhPJw/E3fNCN6TpmRv6pqkn7POhQvm3Oi69LNTBe7Csml9AxUGsPXeGLOR00mnaRvVRF/Hugn7mfYwfnk= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:7220:84ff:fe09:2d90]) (user=yuzhao job=sendgmr) by 2002:a25:ab30:: with SMTP id u45mr17788085ybi.516.1607987575272; Mon, 14 Dec 2020 15:12:55 -0800 (PST) Date: Mon, 14 Dec 2020 16:12:53 -0700 In-Reply-To: <20201214160939.GJ32193@dhcp22.suse.cz> Message-Id: <20201214231253.62313-1-yuzhao@google.com> Mime-Version: 1.0 References: <20201214160939.GJ32193@dhcp22.suse.cz> X-Mailer: git-send-email 2.29.2.684.gfbc64c5ab5-goog Subject: [PATCH] mm/swap: don't SetPageWorkingset unconditionally during swapin From: Yu Zhao To: Andrew Morton Cc: Johannes Weiner , Joonsoo Kim , Vlastimil Babka , Michal Hocko , linux-mm@kvack.org, Yu Zhao 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: 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 only once 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 indicate they were part of the working set. Historically, SetPageWorkingset was added as part of the PSI series, and Johannes said: "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." Link: https://lkml.kernel.org/r/20201209012400.1771150-1-yuzhao@google.com Signed-off-by: Yu Zhao Acked-by: Vlastimil Babka Acked-by: Johannes Weiner Acked-by: Joonsoo Kim Acked-by: Michal Hocko --- mm/swap_state.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index 1a01235156d1..6ecc84448d75 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -536,7 +536,6 @@ struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, workingset_refault(page, shadow); /* Caller will initiate read into locked page */ - SetPageWorkingset(page); lru_cache_add(page); *new_page_allocated = true; return page;