From patchwork Wed Aug 12 04:04:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11710223 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 5D043618 for ; Wed, 12 Aug 2020 04:04:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 25D4320768 for ; Wed, 12 Aug 2020 04:04:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="csaCe0hu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25D4320768 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 13FF66B00AD; Wed, 12 Aug 2020 00:04:34 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0C9806B00AE; Wed, 12 Aug 2020 00:04:34 -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 EAD406B00AF; Wed, 12 Aug 2020 00:04:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id D2BCF6B00AD for ; Wed, 12 Aug 2020 00:04:33 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4D972180AD806 for ; Wed, 12 Aug 2020 04:04:33 +0000 (UTC) X-FDA: 77140574826.10.way28_2810da926fe8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 1F6E716A0C3 for ; Wed, 12 Aug 2020 04:04:33 +0000 (UTC) X-Spam-Summary: 1,0,0,ef71572da4091c34,d41d8cd98f00b204,3t2ozxwykcpaqmrzsgyggydw.ugedafmp-eecnsuc.gjy@flex--yuzhao.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:966:973:988:989:1260:1277:1313:1314:1345: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:3867:3870:3871:3872:4321:4385:5007:6119:6120:6261:6653:6742:7901:7903:9010:9969:10004:10400:11026:11658:11914:12043:12297:12438:12555:12679:12895:13069:13311:13357:14096:14097:14181:14394:14659:14721:21080:21212:21444:21627:30054:30079:30091,0,RBL:209.85.219.202:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04ygebq54y64rcfirjfd9tahq1xnhoc4b3x4x833xqiw31idko7tuy43kpja8su.5rgta1hfn6j5ap94w4g94cwnycqoyzw94y8b1qzckzxrutzwk556d3ked1izwdy.h-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_rules:0:0:0,LFtime:23,LUA_SUMMARY: none X-HE-Tag: way28_2810da926fe8 X-Filterd-Recvd-Size: 3988 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Wed, 12 Aug 2020 04:04:32 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id p138so1416539yba.12 for ; Tue, 11 Aug 2020 21:04:32 -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=v1Nsq9N+YQMLR2jVkYck8gxTVP3hZK8QOU/HVFJRBuQ=; b=csaCe0hu/9JP+zZ//ozPOmHL0XLWrT5paJCyufD/RjSWZqGoymXuR8bYKZwSQ1xuZU vIRZSMK8FDns62Qcd5FuuBDWnbNstU2ZV3QKwHO4SKL9M153Ij5kZ4jAm0EicHVAYUdH k/4Zp5xdQLxCmW1c14Jo+q3jtnrXto5cI0aIfUTZ0m/iJrfRU2zIe56v7fK2poN4b/h8 u5JFRJTCIIHeXq6HQhlgkpYbk4E43h4brKG+y5t+/+qraGWTrPcKitVVNIXAtw5uDYzS +zsRCwUeR8tA9RcYzpoeNggIOfI4bIGICR619BYk6opbVjwcQhA5S2W8uqHf8wRDQ1xY cG9Q== 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=v1Nsq9N+YQMLR2jVkYck8gxTVP3hZK8QOU/HVFJRBuQ=; b=rEi+q53B9lpN6VG2xzsF4iTWgIIVPoPNMWpQVbSElElRcFH7N7eWHYLigxDPSjQUnR 1sdvKJHDAuZojsZywTwDIUlmv09hTn7TU9yovoF4A+AN0Q//wJslPZX1o2jE2pjr4ukC e0zRahxUfaVqDInwqDXEf6aiNYmNnprZGdr7mFfpAzvbEcudrHXitMLHj02XVpGUwmxi 1onDO2AwQTMvjoCYiL6V7GnAboAGfpHNvLgY6J0qMO2reYNaOBNYfMfKo58PyLyCkXqb sye5Ob+WnREIGq7HMJgIuxUgw6KBsPLQns2UG5l+LVR7SHc4RpFC3QewcclfWOhn88lk I9fQ== X-Gm-Message-State: AOAM533mTc3pDjoVXsLdz2CdT8K78rz9YkogMNeYHfBclSKtE2RDvew5 4Mn2xG1S3u/z8VvuJqoGuVCs+oGARTg= X-Google-Smtp-Source: ABdhPJzgKSVVawICdS1/tR2l0UkUBVuqBVVkP81T13b/A37jSsQT9YvQyxxxCErkAdkeK4g0XQL0xeV+dhs= X-Received: by 2002:a05:6902:4c6:: with SMTP id v6mr25855740ybs.499.1597205071788; Tue, 11 Aug 2020 21:04:31 -0700 (PDT) Date: Tue, 11 Aug 2020 22:04:23 -0600 Message-Id: <20200812040423.2707213-1-yuzhao@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [PATCH 1/3] mm: don't call activate_page() on new ksm pages 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, Yu Zhao X-Rspamd-Queue-Id: 1F6E716A0C3 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: lru_cache_add_active_or_unevictable() already adds new ksm pages to active lru. Calling activate_page() isn't really necessary in this case. Signed-off-by: Yu Zhao --- mm/swapfile.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 6c26916e95fd..cf115ea26a20 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1913,16 +1913,16 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, pte_mkold(mk_pte(page, vma->vm_page_prot))); if (page == swapcache) { page_add_anon_rmap(page, vma, addr, false); + /* + * Move the page to the active list so it is not + * immediately swapped out again after swapon. + */ + activate_page(page); } else { /* ksm created a completely new copy */ page_add_new_anon_rmap(page, vma, addr, false); lru_cache_add_active_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 Wed Aug 12 04:05:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11710225 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 C6202174A for ; Wed, 12 Aug 2020 04:06:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8967620678 for ; Wed, 12 Aug 2020 04:06:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PQ79oX9p" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8967620678 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 D01366B00AF; Wed, 12 Aug 2020 00:06:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CB1046B00B0; Wed, 12 Aug 2020 00:06:08 -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 BC6B26B00B1; Wed, 12 Aug 2020 00:06:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id A6EF86B00AF for ; Wed, 12 Aug 2020 00:06:08 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5B91A3629 for ; Wed, 12 Aug 2020 04:06:08 +0000 (UTC) X-FDA: 77140578816.06.crown21_3c0c53626fe8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 3267E10057B8B for ; Wed, 12 Aug 2020 04:06:08 +0000 (UTC) X-Spam-Summary: 1,0,0,34581e337cce9049,d41d8cd98f00b204,3rmozxwykcfehdi0t7z77z4x.v75416dg-553etv3.7az@flex--yuzhao.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:966:973:988:989:1201:1260:1277:1313:1314:1345: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: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.219.201:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04ygtiyhrkhdskjrmy6dpqyr45nepop91dsjo5kz9o9i46kno4pqfpg7usufpcj.ex9nm6iare9k1k9u7o4tix9kh588fsrb9w1xddhdkqagy54ibzoc8e14gy8qoxn.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:f p,MSBL:0 X-HE-Tag: crown21_3c0c53626fe8 X-Filterd-Recvd-Size: 4471 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Wed, 12 Aug 2020 04:06:07 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id o8so1404773ybg.16 for ; Tue, 11 Aug 2020 21:06:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:message-id:mime-version:subject:from:to:cc; bh=iTZlcV/HDVMBUj3vIm/BeqimkSAgE6ss1JTWwnLuV7w=; b=PQ79oX9ptj1DcJboGkk/u9/eQM7QFOR6pkv9sTiA01Hwr5+qHsW4r3uy0R08hjkTKp /CGVUpYvsZpiJSP2BZd8pHrisgM8KQ/93wShpsQgZewNcxXZtwvTJy3EZbNkz8elsegd NrNHbhn5UVyj8Ud8kqsD+vrD4izt8H0g0wlNhXYkSPW8zXa+KuWeLMUpzZM+0UKzVpqh MLwOcLIFz/2gLQcW1Eq51kH5i8/duG99bp7CxDzAxr3VucjSC6RJ65ntwLr7r2S/87wm dLFTWtK0LNRLAYYEzUx75mVivIuScTZ7ZR55V1k1A/+PdAjWzSy97ogq+Qz9S1n1k4KA tA2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:message-id:mime-version:subject :from:to:cc; bh=iTZlcV/HDVMBUj3vIm/BeqimkSAgE6ss1JTWwnLuV7w=; b=U11jcE5m+yfSbXbdMR1dBObbFtxdmCAq/a45ufkkXc+aMburiYEpKIJot3NqJVNEQr sI39d+koVvjqXG2vwP0Tfl7XlEp7xvo79GzVHrVFems2qbOcP96ZO4yfT/ggrTnHLjAB YH6DsLDX/lQ05c77AVJv3LVAoeGlIZcwOk5F3saMwIKhMC6GvdBUJVyB7j4CMVJCwNX4 hBVCaqbzUioC7aPaJKNY+CLhR3wyf9xizARe/G5pb28xLKcx5OBrd6kP3ranEV2LJd0l sXCi8yrCvXqlke1IRb8JHp4bHse6wN085FSdLYN/oqKYPzD2nzGxbQVDYFDbyCI4L6Mn U2Gg== X-Gm-Message-State: AOAM532LYdppkrop/s1W8Cu6SqHDO0yayRXwH1AkSKn1/arbdZ6I3WbI o9L0aoO/aK0GI49cDRX0hRoKfbGYsfo= X-Google-Smtp-Source: ABdhPJzfk920y7QXdilL0gnKVShIBZWvJH75i46mC6Pu2Hx2kdFQ86wy4FJrpeAKB11/nSfL2M/Q++UqnJY= X-Received: by 2002:a25:bdc4:: with SMTP id g4mr52297610ybk.187.1597205166994; Tue, 11 Aug 2020 21:06:06 -0700 (PDT) Reply-To: <20200812040454.2708263-1-yuzhao@google.com> Date: Tue, 11 Aug 2020 22:05:50 -0600 Message-Id: <20200812040550.2708444-1-yuzhao@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [PATCH 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, Yu Zhao X-Rspamd-Queue-Id: 3267E10057B8B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 can't call SetPageActive() on a page that doesn't have any reference left. Therefore, the race is impossible, not 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 de257c0a89b1..1f223a02549d 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -898,8 +898,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 Wed Aug 12 04:06:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 11710227 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 19ACE14F6 for ; Wed, 12 Aug 2020 04:06:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D06A220678 for ; Wed, 12 Aug 2020 04:06:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ux5Uu8bQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D06A220678 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 203B76B00B1; Wed, 12 Aug 2020 00:06:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1B5196B00B2; Wed, 12 Aug 2020 00:06:35 -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 0CA3F6B00B3; Wed, 12 Aug 2020 00:06:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id EB0FB6B00B1 for ; Wed, 12 Aug 2020 00:06:34 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A73DF8248047 for ; Wed, 12 Aug 2020 04:06:34 +0000 (UTC) X-FDA: 77140579908.02.sign20_590c69426fe8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 78FCD10045539 for ; Wed, 12 Aug 2020 04:06:34 +0000 (UTC) X-Spam-Summary: 1,0,0,33e679b058c60110,d41d8cd98f00b204,3ywozxwykcgwiejrkyqyyqvo.mywvsxeh-wwufkmu.ybq@flex--yuzhao.bounces.google.com,,RULES_HIT:41:152:355:379:541:800:960:966:968:973:988:989:1201:1260:1277:1313:1314:1345: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:12438:12555:12895:12986:14096:14097:14181:14394:14659:14721:21080:21324:21444:21627:21939:21987:21990:30054:30090,0,RBL:209.85.219.202:@flex--yuzhao.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04yf71gku4kqheupdrhsmogrz58ykoc9kwwxhqhmrinogdqi18osc8qftek9rsm.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:neutral,C ustom_ru X-HE-Tag: sign20_590c69426fe8 X-Filterd-Recvd-Size: 5585 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Wed, 12 Aug 2020 04:06:33 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id l13so1450176ybf.5 for ; Tue, 11 Aug 2020 21:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:message-id:mime-version:subject:from:to:cc; bh=FIDHeBVsxOsjTSA4w3NTw9Tbo6FlzORttBwxcXHesPo=; b=ux5Uu8bQKrzTp3HdJ4kJsnBlROLefp/k9fpAqAOEUdQCbrkbaMwDrum/ZlZvBSAvI0 3g1wg6FghbYkoDYlmie3Tr8cLXl1nBR20e2mXExEEErvtoLGTMTuApukeAjegxF/R9o5 Z01vMuGk80s052RBzwQFTGqcOU3yogmOINf/19ezFHhUypIDKY+kDHzsd+gh0CGMV+Qk s5OgPUsfbMCq1LG1HE/j+UxYS1/F6pbtcTkgoT+mBFvUn85xmd27KWsMdSiMZh0cBVjX I/cpckvsX2JUf+KAT/xtyVk8afH10m2yi3pgn0Lzz7kFDQEAflnCV5f0cN4XjIScOU2r Y8CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:message-id:mime-version:subject :from:to:cc; bh=FIDHeBVsxOsjTSA4w3NTw9Tbo6FlzORttBwxcXHesPo=; b=nB80QGY9g2ciaw514NK7iOlr2eBAzyqhn42OW6nubj0f5PoKsokKZuRpcdsPRFnIAp 4CzHDpn3YzvIC6RZQpODRUvZ3MR6p4Fd8naNCHvf/A51mVn75ESHMj2S+7Q/1s5gT5Ry ykpTuTntHRuf6JlfGxOQy+wBx8F3iRR9ErqqaCTcKH/xRZnkM7ccOW+z0Hm2shOm8Tjd 8eIxZwWoGOa7SCqpzefhbZvGNHTwREZP4cwx80jNxfOvF34nyNYPMJ321EavtBIHO6Qd zvhNybZdETk0rIEFGlwftFEvkuS5QnX/EWErL/9ngSxOSmkEVsKknoa+W0CInsuDCDmZ YsXA== X-Gm-Message-State: AOAM530nLVFizJGy5U8TyCxXjMlMKDBhql9mf+aD6HNIP1Vmdv00ZBvP o4sdjXSoCq00mwPshDrkz07gv638JjM= X-Google-Smtp-Source: ABdhPJzUzwFvnMR3FToe6QoDQuvIwCq7pGDkgNw1NnVna6H//Q1976w39eSM3NOkYmiN1L3BjTLJrLyy8rI= X-Received: by 2002:a5b:70d:: with SMTP id g13mr52265619ybq.160.1597205193285; Tue, 11 Aug 2020 21:06:33 -0700 (PDT) Reply-To: <20200812040454.2708263-1-yuzhao@google.com> Date: Tue, 11 Aug 2020 22:06:30 -0600 Message-Id: <20200812040630.2710064-1-yuzhao@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog Subject: [PATCH 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, Yu Zhao X-Rspamd-Queue-Id: 78FCD10045539 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 f2bb5ff0293d..8a096844ddad 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 1f223a02549d..6129692752a5 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) @@ -898,8 +897,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)