From patchwork Tue Aug 18 18:47:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11722099 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F512138C for ; Tue, 18 Aug 2020 18:47:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DF387206B5 for ; Tue, 18 Aug 2020 18:47:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JVho9R3B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF387206B5 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 834E68D0001; Tue, 18 Aug 2020 14:47:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7BE056B0093; Tue, 18 Aug 2020 14:47:14 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AE5D8D0001; Tue, 18 Aug 2020 14:47:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id 517DE6B0092 for ; Tue, 18 Aug 2020 14:47:14 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 174BB181AC9B6 for ; Tue, 18 Aug 2020 18:47:14 +0000 (UTC) X-FDA: 77164571988.29.smash47_1104ae627021 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id C414418086CD2 for ; Tue, 18 Aug 2020 18:47:13 +0000 (UTC) X-Spam-Summary: 1,0,0,6162655261e76915,d41d8cd98f00b204,3mci8xwykcgubxckdrjrrjoh.frpolqxa-ppnydfn.ruj@flex--yuzhao.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:966:968:973:988:989:1260:1277:1313:1314:1345:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2897:3138:3139:3140:3141:3142:3152:3353:3865:3867:3868:3870:3871:3872:4321:4385:4419:4605:5007:6119:6261:6653:6742:7903:8957:9010:9969:10004:10400:11026:11658:11914:12043:12296:12297:12438:12555:12679:12895:12986:13161:13229:14096:14097:14181:14394:14659:14721:21080:21444:21451:21627:21740:21990:30054:30091,0,RBL:209.85.219.201:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04y8h7jthihzc7ke539k7r8bmgradypafthehxooa3w497pniaoddxka5qmq11x.ke4pj6bcauwswxmusr4acg5g1qth4kqcxakhhz13pxkmmuasr9wz51uznduiuuu.4-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rul es:0:0:0 X-HE-Tag: smash47_1104ae627021 X-Filterd-Recvd-Size: 5248 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 18 Aug 2020 18:47:13 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id d26so23209506yba.20 for ; Tue, 18 Aug 2020 11:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=/E5eAbEMdGecxil6UrL49SnbBNTAteYJO6ZYPEM5dLY=; b=JVho9R3BbAEAJN3/ABbAA0Q8qoaA4DB7htuEZjfa/UrhMXpsJYFmC7+ZhNNZwKO2NQ PUc5iLYdObTaoIIro8tIsaxuloxbDtq2BRHvJ4HImEh99kGzHSMlwGqvrpFkSNH5ILjH 7OMrfDapLBjDBr/Ron5FwpH8Ed9zJSRBQoNzjeni2Bb9CZZZzkBMHI6Mo9WOMW9GV3Ks hGjjHW9qk302727BeP4WxexH6OJY479SyLXh2AXO/Et+r5tnXqWS8TzIEF24kDQVSBkz TVXnU9sXK1hSVqkA4lJrmI7dZxvQJSTmBveDUy51OpONWhUYv5f7/rdQAsba4BdwvKED meng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=/E5eAbEMdGecxil6UrL49SnbBNTAteYJO6ZYPEM5dLY=; b=pCmtTnkQQGwTrRF0t8VC5YVkI/NSg54I92WtPck/mT4pWw0mINpyyHDE5L4NBwH3li Hp24/DL5+AZtxs7GV3oQKJREmGpIPSEjuiTfDWmn76ElOv+E9uz35GOd+GKbIjFaWuBB JfI5cB837CEyJaJJY6ZIHjqVAuuEJvdQXmrRUxbz0HzzxYxG97/JcZbFLHogLk8cF5od GOab/ZlISEmNaPmfbHsCH4Ld+tWx3hmEQnRpWI04q/mW5gaJVofGLekdHg945oQ0YW4o OcdNNIvbSgDS2tlGgy4DDcZ+WhH4m9u87LQmBpl5QLLH94dn3677qn1EwiMi9eiAFBS4 LNnQ== X-Gm-Message-State: AOAM533+rVh+nEbJHZnoZVZsbmkQI8m4wbizgMqAxhiYbcTP765J9xgo NStF+5Bvbl5E5YVSuvaVxVl3AI+OnLI= X-Google-Smtp-Source: ABdhPJzU4R0PcrHVEc2b75WaWjsd33ALQzPjuw40VrEB0Drky/Odddmf1lW46QmY6IDqhw2oeSJVIkW1ZK8= X-Received: by 2002:a25:3b0d:: with SMTP id i13mr28488393yba.314.1597776432330; Tue, 18 Aug 2020 11:47:12 -0700 (PDT) Date: Tue, 18 Aug 2020 12:47:02 -0600 Message-Id: <20200818184704.3625199-1-yuzhao@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH v2 1/3] mm: remove activate_page() from unuse_pte() From: Yu Zhao To: Andrew Morton Cc: Alexander Duyck , Huang Ying , David Hildenbrand , Michal Hocko , Yang Shi , Qian Cai , Mel Gorman , Nicholas Piggin , " =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= " , Hugh Dickins , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Joonsoo Kim , Yu Zhao X-Rspamd-Queue-Id: C414418086CD2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 don't initially add anon pages to active lruvec after commit b518154e59aa ("mm/vmscan: protect the workingset on anonymous LRU"). Remove activate_page() from unuse_pte(), which seems to be missed by the commit. And make the function static while we are at it. Before the commit, we called lru_cache_add_active_or_unevictable() to add new ksm pages to active lruvec. Therefore, activate_page() wasn't necessary for them in the first place. Signed-off-by: Yu Zhao Reviewed-by: Yang Shi --- include/linux/swap.h | 1 - mm/swap.c | 4 ++-- mm/swapfile.c | 5 ----- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 661046994db4..df6207346078 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -340,7 +340,6 @@ extern void lru_note_cost_page(struct page *); extern void lru_cache_add(struct page *); extern void lru_add_page_tail(struct page *page, struct page *page_tail, struct lruvec *lruvec, struct list_head *head); -extern void activate_page(struct page *); extern void mark_page_accessed(struct page *); extern void lru_add_drain(void); extern void lru_add_drain_cpu(int cpu); diff --git a/mm/swap.c b/mm/swap.c index d16d65d9b4e0..25c4043491b3 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -348,7 +348,7 @@ static bool need_activate_page_drain(int cpu) return pagevec_count(&per_cpu(lru_pvecs.activate_page, cpu)) != 0; } -void activate_page(struct page *page) +static void activate_page(struct page *page) { page = compound_head(page); if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) { @@ -368,7 +368,7 @@ static inline void activate_page_drain(int cpu) { } -void activate_page(struct page *page) +static void activate_page(struct page *page) { pg_data_t *pgdat = page_pgdat(page); diff --git a/mm/swapfile.c b/mm/swapfile.c index 12f59e641b5e..c287c560f96d 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1925,11 +1925,6 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, lru_cache_add_inactive_or_unevictable(page, vma); } swap_free(entry); - /* - * Move the page to the active list so it is not - * immediately swapped out again after swapon. - */ - activate_page(page); out: pte_unmap_unlock(pte, ptl); if (page != swapcache) { From patchwork Tue Aug 18 18:47:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11722101 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79951913 for ; Tue, 18 Aug 2020 18:47:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4539E20772 for ; Tue, 18 Aug 2020 18:47:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bQ/GzzWC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4539E20772 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 725336B0092; Tue, 18 Aug 2020 14:47:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6ADD28D0003; Tue, 18 Aug 2020 14:47:15 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48DC56B0095; Tue, 18 Aug 2020 14:47:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id 2285B6B0092 for ; Tue, 18 Aug 2020 14:47:15 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DDB8C8248047 for ; Tue, 18 Aug 2020 18:47:14 +0000 (UTC) X-FDA: 77164571988.13.egg30_0e12bcb27021 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id B379918140B67 for ; Tue, 18 Aug 2020 18:47:14 +0000 (UTC) X-Spam-Summary: 1,0,0,caa0f743681cbce5,d41d8cd98f00b204,3msi8xwykcgycydlesksskpi.gsqpmryb-qqozego.svk@flex--yuzhao.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:966:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3152:3352:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:4385:5007:6261:6653:6742:8660:8957:9969:10004:10400:10450:10455:11026:11638:11658:11914:12043:12050:12296:12297:12438:12555:12895:13069:13148:13161:13229:13230:13311:13357:14096:14097:14181:14394:14659:14721:19904:19999:21080:21444:21627:21939:21987:21990:30054,0,RBL:209.85.222.201:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yrw4n93u84q8z69ogbjhsh5d7sdychxd8gnrr69o9i46kno4gangiinnuphaw.asma4uiare9k1k9u7o4tix9kh588fsrb9w1xddhdkqagy34h1z43oy14gy8qoxn.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk ,SPF:fp, X-HE-Tag: egg30_0e12bcb27021 X-Filterd-Recvd-Size: 4613 Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Tue, 18 Aug 2020 18:47:14 +0000 (UTC) Received: by mail-qk1-f201.google.com with SMTP id f18so13799284qke.0 for ; Tue, 18 Aug 2020 11:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=gehHRqDo170D8ggpcqt5L8gyM4hpiP3lcUb1NEGWSW0=; b=bQ/GzzWCVMuhyt2laZU2VxcoEcEJ0awKHw177BB3iK9JBuhbMoqOMb55rEFzzispi4 ywbPZWNcaLgifIEPXSTOz563MWK+2uyPYoJ0xUHlueLw8MgtrLdr8wbNjMFUN+Or3S0P iFQIqxP58WduRybClJ8bhoc927M7lCiLlkV056WLQRc3mFjEth5caAjZwDkc0tSlDRK7 PR4W0wMOT8pAoPiyhV5ylKxZPeOSn9Qj6yms7eHC9/mfODiKNLp2EDPyQcC/1OlsvYma q9N9WYkzvVBiWbNQ07qYsS7ND29LTFcqHnC9eCJY4qJyPTjUgMP56T2G8gvL5L+zvWDx lx8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=gehHRqDo170D8ggpcqt5L8gyM4hpiP3lcUb1NEGWSW0=; b=fvmFfa6vwp4REilJx4z3GxYreeEIQSNp/YEj3TfyPfV9wCSdDru5V7+jy0ESKOmi8T fLL+cwkrutGqFYsfhUu4f+1YmlCeVa3N4lRTs/ubCt995bNZWvjsH/9cIgBZBzw9AsVf diRwyXzY6rKbB1UgBEUvJslgPkOhlDIM5AUy2qT6HVw6hyo5rTo26MF6savhNQ6QSlMH GyhoTFbh6YcxH2ruUGApAUl3Z0ivSuP3zhMlYu2pKQgOJN3HIDCa2Nd3OV2x3SckyT8s BnCjKpz8HDq7TCLItyTE+Idn8p6xgYskiUTCZTqv23Ri03UMFbgtEok76LoDZgLShUPl 7Ciw== X-Gm-Message-State: AOAM530Toos3Baray+m0nuY/5D3mMjR5Ow06Q7lNnbZCcGv1Rh2a1BA5 CkK47/eX24H98hwPcv+pLbRx3Anmigo= X-Google-Smtp-Source: ABdhPJyX7PxrdwZp8JKMZ0YQglNCQFusxUHnYaz351dVMOTyN3ebFvNOcxIaiSUrRohWV46bcjlxOvwE/VU= X-Received: by 2002:ad4:54c6:: with SMTP id j6mr20694395qvx.126.1597776433446; Tue, 18 Aug 2020 11:47:13 -0700 (PDT) Date: Tue, 18 Aug 2020 12:47:03 -0600 In-Reply-To: <20200818184704.3625199-1-yuzhao@google.com> Message-Id: <20200818184704.3625199-2-yuzhao@google.com> Mime-Version: 1.0 References: <20200818184704.3625199-1-yuzhao@google.com> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH v2 2/3] mm: remove superfluous __ClearPageActive() From: Yu Zhao To: Andrew Morton Cc: Alexander Duyck , Huang Ying , David Hildenbrand , Michal Hocko , Yang Shi , Qian Cai , Mel Gorman , Nicholas Piggin , " =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= " , Hugh Dickins , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Joonsoo Kim , Yu Zhao X-Rspamd-Queue-Id: B379918140B67 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: To activate a page, mark_page_accessed() always holds a reference on it. It either gets a new reference when adding a page to lru_pvecs.activate_page or reuses an existing one it previously got when it added a page to lru_pvecs.lru_add. So it doesn't call SetPageActive() on a page that doesn't have any reference left. Therefore, the race is impossible these days (I didn't brother to dig into its history). For other paths, namely reclaim and migration, a reference count is always held while calling SetPageActive() on a page. SetPageSlabPfmemalloc() also uses SetPageActive(), but it's irrelevant to LRU pages. Signed-off-by: Yu Zhao --- mm/memremap.c | 2 -- mm/swap.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/mm/memremap.c b/mm/memremap.c index 03e38b7a38f1..3a06eb91cb59 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -451,8 +451,6 @@ void free_devmap_managed_page(struct page *page) return; } - /* Clear Active bit in case of parallel mark_page_accessed */ - __ClearPageActive(page); __ClearPageWaiters(page); mem_cgroup_uncharge(page); diff --git a/mm/swap.c b/mm/swap.c index 25c4043491b3..999a84dbe12c 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -900,8 +900,6 @@ void release_pages(struct page **pages, int nr) del_page_from_lru_list(page, lruvec, page_off_lru(page)); } - /* Clear Active bit in case of parallel mark_page_accessed */ - __ClearPageActive(page); __ClearPageWaiters(page); list_add(&page->lru, &pages_to_free); From patchwork Tue Aug 18 18:47:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11722103 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EBA8138C for ; Tue, 18 Aug 2020 18:47:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C2A6206B5 for ; Tue, 18 Aug 2020 18:47:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CIx7kMWb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C2A6206B5 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 A0E508D000D; Tue, 18 Aug 2020 14:47:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 948BA8D0003; Tue, 18 Aug 2020 14:47:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 723E48D000D; Tue, 18 Aug 2020 14:47:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0094.hostedemail.com [216.40.44.94]) by kanga.kvack.org (Postfix) with ESMTP id 5A0318D0003 for ; Tue, 18 Aug 2020 14:47:16 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 162561F1B for ; Tue, 18 Aug 2020 18:47:16 +0000 (UTC) X-FDA: 77164572072.25.fact20_4609c2927021 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id DB5871804E3A1 for ; Tue, 18 Aug 2020 18:47:15 +0000 (UTC) X-Spam-Summary: 1,0,0,5bdd08b525844ecb,d41d8cd98f00b204,3mii8xwykcgcdzemftlttlqj.htrqnszc-rrpafhp.twl@flex--yuzhao.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:966:968:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1535:1542:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3152:3353:3608:3865:3866:3867:3868:3870:3871:3872:3874:4321:4385:4605:5007:6261:6653:6742:7903:8957:9592:9969:10004:10400:11026:11473:11638:11639:11658:11914:12043:12297:12438:12555:12895:12986:14096:14097:14181:14394:14659:14721:21080:21324:21444:21627:21939:21987:21990:30054:30090,0,RBL:209.85.219.201:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04ygmufjycyqcsgihummdkzzoqji7yc9kwwxhqhmrinogdqi18osc8qftek9rsm.cbz7ak6faa67srf713gms5onf5wq93rydf8gam77knjr3ghnxxcfmtm9jwfgcua.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neu tral,Cus X-HE-Tag: fact20_4609c2927021 X-Filterd-Recvd-Size: 5730 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Tue, 18 Aug 2020 18:47:15 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id l67so23102490ybb.7 for ; Tue, 18 Aug 2020 11:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=bfVQLroskM5Wc4DhZMIyj9jgHc+j8RHZ/garHr4Fpmo=; b=CIx7kMWbB8VmYnYBEoD4nNQsaSQZt1zzWgyHBo9TmOh+81P13Aq4a+yETjPZEdKzHt 6xhM+il6SYmrYbNG1IV7d069OMSWVqj57ViYi+dViNBbqPDo4foz1/sXg+neeEwOnROJ b3vK60iuFFWLcpf66/+S0SZnj2eh8Khpc1C4Awp23aYoNw3Hn2ktDyYyIqmyY/lLuNWy 0KsGsEIVRDT/ZcJr7rljERS6QGsxhldWu58VpPBprIVTjCTNGFYgQ/jP9PX7jqtcNwYD yHdVBEoP2GYwds522u6f/lZ7QVEz357iUqWtZYvud/ZMRq5iE6U6JD54o1RFc5iL68P9 PFUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bfVQLroskM5Wc4DhZMIyj9jgHc+j8RHZ/garHr4Fpmo=; b=WBa+m3LuIyCL3gyUzPiNOZ3Y2UFlSoYUuzldbiyw22XxpZovuBwZEVY1+xX8ziFsny MCM8FzfioiWjcxhHZiG58p01uOJkPXVhDiuKnqUQFZUyufim1BW7Huigr+8det/m128D 5CX7qY23yyoR5VOfWc7Bwkax+aU7GKL4FgZu4v3khhdHj58Aph4fHFUShdRovweevxtz 0W1q2Cyn7wPU+i0NfYiHzMNDf68AYJYqZeMlMefdAgpmdfzK5gM2a0unAhVs1q8IBvOH B2SFNq7TvUAXuWsw4YyS7rjCo/bxyYksxo92PshstNagl8wwvB20kKx5fmS6sL6mg8qu 8WEA== X-Gm-Message-State: AOAM531b+5s+Uuice2P0SlsAVBltt7KI102o+m0yAM6Dpo26I6KbLKIZ lo0bb+wYpnATeVRNeBijqrP5bpIUDtY= X-Google-Smtp-Source: ABdhPJxZwwFPlarZ3LoosIXt55p8uBBCrvGv9J5VLrCxYXf9wPeT384wi+a1vkBEDJm/7ct0Z09BbNo6pl0= X-Received: by 2002:a25:a091:: with SMTP id y17mr28606051ybh.82.1597776434643; Tue, 18 Aug 2020 11:47:14 -0700 (PDT) Date: Tue, 18 Aug 2020 12:47:04 -0600 In-Reply-To: <20200818184704.3625199-1-yuzhao@google.com> Message-Id: <20200818184704.3625199-3-yuzhao@google.com> Mime-Version: 1.0 References: <20200818184704.3625199-1-yuzhao@google.com> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH v2 3/3] mm: remove superfluous __ClearPageWaiters() From: Yu Zhao To: Andrew Morton Cc: Alexander Duyck , Huang Ying , David Hildenbrand , Michal Hocko , Yang Shi , Qian Cai , Mel Gorman , Nicholas Piggin , " =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= " , Hugh Dickins , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Joonsoo Kim , Yu Zhao X-Rspamd-Queue-Id: DB5871804E3A1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: Presumably __ClearPageWaiters() was added to follow the previously removed __ClearPageActive() pattern. Only flags that are in PAGE_FLAGS_CHECK_AT_FREE needs to be properly cleared because otherwise we think there may be some kind of leak. PG_waiters is not one of those flags and leaving the clearing to PAGE_FLAGS_CHECK_AT_PREP is more appropriate. Signed-off-by: Yu Zhao --- include/linux/page-flags.h | 2 +- mm/filemap.c | 2 ++ mm/memremap.c | 2 -- mm/swap.c | 3 --- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 6be1aa559b1e..dba80a2bdfba 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -318,7 +318,7 @@ static inline int TestClearPage##uname(struct page *page) { return 0; } TESTSETFLAG_FALSE(uname) TESTCLEARFLAG_FALSE(uname) __PAGEFLAG(Locked, locked, PF_NO_TAIL) -PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) +PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL) PAGEFLAG(Referenced, referenced, PF_HEAD) TESTCLEARFLAG(Referenced, referenced, PF_HEAD) diff --git a/mm/filemap.c b/mm/filemap.c index 1aaea26556cc..75240c7ef73f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1079,6 +1079,8 @@ static void wake_up_page_bit(struct page *page, int bit_nr) * other pages on it. * * That's okay, it's a rare case. The next waker will clear it. + * Otherwise the bit will be cleared by PAGE_FLAGS_CHECK_AT_PREP + * when the page is being freed. */ } spin_unlock_irqrestore(&q->lock, flags); diff --git a/mm/memremap.c b/mm/memremap.c index 3a06eb91cb59..a9d02ffaf9e3 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -451,8 +451,6 @@ void free_devmap_managed_page(struct page *page) return; } - __ClearPageWaiters(page); - mem_cgroup_uncharge(page); /* diff --git a/mm/swap.c b/mm/swap.c index 999a84dbe12c..40bf20a75278 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -90,7 +90,6 @@ static void __page_cache_release(struct page *page) del_page_from_lru_list(page, lruvec, page_off_lru(page)); spin_unlock_irqrestore(&pgdat->lru_lock, flags); } - __ClearPageWaiters(page); } static void __put_single_page(struct page *page) @@ -900,8 +899,6 @@ void release_pages(struct page **pages, int nr) del_page_from_lru_list(page, lruvec, page_off_lru(page)); } - __ClearPageWaiters(page); - list_add(&page->lru, &pages_to_free); } if (locked_pgdat)