From patchwork Wed Mar 27 14:10:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13606717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02EC1C47DD9 for ; Wed, 27 Mar 2024 14:13:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9002D6B0092; Wed, 27 Mar 2024 10:13:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8ADE56B0095; Wed, 27 Mar 2024 10:13:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7290F6B0096; Wed, 27 Mar 2024 10:13:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5388E6B0092 for ; Wed, 27 Mar 2024 10:13:23 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 13C6F160DFF for ; Wed, 27 Mar 2024 14:13:23 +0000 (UTC) X-FDA: 81943011486.15.2437F56 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf05.hostedemail.com (Postfix) with ESMTP id C333A100014 for ; Wed, 27 Mar 2024 14:13:20 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711548801; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lk/APelPic84s/Ofn0uIL0rf5ARcImvrvKUTuVPHucs=; b=YorKycOztXG5K7ruhW6UhTVtxZW1nHhCO3JPIVKZO9kvwx/3N6Xe/EJVhSnWY62wiTj65z dtRdqlPL+zBeGvmmSgNX80tRwYBebOZLXqsaZdxgzzMkvdpTSmDJaH4skrpCTPzWfy4gag AWkKh2ZrSncE+8Gkdeo0cF84OeG0OyY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711548801; a=rsa-sha256; cv=none; b=L6OKjMHkg0dRBEWHZKLsvDM7lDragVu4W6a+3Bl2IroQ+QmIk2neL1xrCAxgxFhvHHCUXS +fe4IGrDwNKz3mHbSbW/BAWA3P61EtTu/O5sE9+qHPRnxep2VaOmtvhNYyNkbGeFcJzg48 23Q8t8L7fjTOvL5eK44uwNDo7rQ/PPs= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V4TCK5yRZz1GD8d; Wed, 27 Mar 2024 22:12:45 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id D64A21400DA; Wed, 27 Mar 2024 22:13:16 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 27 Mar 2024 22:13:16 +0800 From: Kefeng Wang To: Andrew Morton CC: , Miaohe Lin , Naoya Horiguchi , David Hildenbrand , Oscar Salvador , Zi Yan , Hugh Dickins , Jonathan Corbet , , , Baolin Wang , Kefeng Wang Subject: [PATCH 4/6] mm: compaction: use isolate_movable_folio() in isolate_migratepages_block() Date: Wed, 27 Mar 2024 22:10:32 +0800 Message-ID: <20240327141034.3712697-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240327141034.3712697-1-wangkefeng.wang@huawei.com> References: <20240327141034.3712697-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Stat-Signature: g17nb9guqzeh9b4aecrsqnnhnnddxj6g X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C333A100014 X-HE-Tag: 1711548800-531842 X-HE-Meta: U2FsdGVkX18UoW8HjUkn9cgs8sTVu+R0z53krVAzCH2FgcK3mnVaLlYwWi1d9RtrX0VWXqNvIhZgNmfYzULYKk+herwbOr2CunRVY2kuLqzKpepHhR5X2NKLPuRX08b/lOxtqJvLbmUJFrJ+qpLJTH4Xa3/jTCJKauPf9oSFep36oIJ/7k56qdFXJfiD4C8lgSQR5XgN3fI+RfZvNyIlHYJ+cnSkyIGchRKQvWCZeg97BlEe0xVTru+YVERso6vFi8EdvkVadgCe+DX0uTHTX+D7O8JyqfWwqKPj4IhS7id8IaslGj69aKt2goaMZMoIngLQFRYPlqNVWkJkBEP4IZHinP4o2fkjKRFOOuYd7RZSu9cnGH6ix3w/CnJG377udKJuy8NgCObrXSmDSo2E9ljj2r4TKVdTO5geSWrqpv7JuD7/Pk5c4SYVAfuLVBvkTqxJoabQ+eEb9LVUM4BJ/PFZJ1ktr45lviW2deqFc3saaHEOCEgHzbKy4dHcRrMHtWOOsChRI/N9I5mO+/T6JpyzUf7/0i8xtZj5RbD2vyZ+V6NxAHJpBocQXzM0OAw9uUf5ftquxep9SqwSBuw/08SXs2KZkrwpHZFeCxgj/aq9Xj0VEqSst51bv7sgL2bX9RH/IrCfOd/EoeFlXj2NICroFLnbF9BBHUo9zOJ0hyMtgM6IEnsBnpNxg7y/E5xM5b+3nYXysKNnUQIMfNadK62KF8TONvW0ItyD3ysg84CsFn3Ks3fHeaOGrQeGKWgh+TFn3AjVj38nFXEvmFJNSVyAB60W5qaShVUx/y2LGVbn+kE+08Dxmc17IMs2Jj6yDkvVKGSt/P94Kn0bnv6j/gsclVRnnWCJ1XaEw/R427iwlyKD2NuPqNRzpZOtLJusz/CqZ0NwjAOeu60nmaN5t+dQnmfuViPUzpiLPJ2VTNKXUqDyXbzJCD7c69oqRn3daNcITtxkYqIg5pVhXSr +w+QwJbw n2kpgI9cj7Z79xNi9j+yFYYOkSZMNn1atEVlFip7Kaszt1gPrh9PL7zOL1VB63WgVy2kwm8+P62U3DmGPQsbR6jN0c8tsYQMT4TjkLdAKsZ24idWeXfHZ62DLIyWusUx0sSBD4TRKiXNHuCbGWxVnRytzBxaYUExo2SNqueedzysI3/RKKhtx9Qpb4RehApP2JnY5skY93RowyhkL+03oc+mpxgByEFm+P5tx8ByKBSldwcE= 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: List-Subscribe: List-Unsubscribe: This moves folio_get_nontail_page() before non-lru movable pages check, and directly call isolate_movable_folio() to save compound_head() calls, since the reference count of the non-lru movable page is increased, a folio_put() is need() whether the folio is isolated or not. Signed-off-by: Kefeng Wang --- mm/compaction.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 807b58e6eb68..74ac65daaed1 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1097,41 +1097,41 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, } } + /* + * Be careful not to clear PageLRU until after we're + * sure the page is not being freed elsewhere -- the + * page release code relies on it. + */ + folio = folio_get_nontail_page(page); + if (unlikely(!folio)) + goto isolate_fail; + /* * Check may be lockless but that's ok as we recheck later. * It's possible to migrate LRU and non-lru movable pages. * Skip any other type of page */ - if (!PageLRU(page)) { + if (!folio_test_lru(folio)) { /* * __PageMovable can return false positive so we need * to verify it under page_lock. */ - if (unlikely(__PageMovable(page)) && - !PageIsolated(page)) { + if (unlikely(__folio_test_movable(folio)) && + !folio_test_isolated(folio)) { if (locked) { unlock_page_lruvec_irqrestore(locked, flags); locked = NULL; } - if (isolate_movable_page(page, mode)) { - folio = page_folio(page); + if (isolate_movable_folio(folio, mode)) { + folio_put(folio); goto isolate_success; } } - goto isolate_fail; + goto isolate_fail_put; } - /* - * Be careful not to clear PageLRU until after we're - * sure the page is not being freed elsewhere -- the - * page release code relies on it. - */ - folio = folio_get_nontail_page(page); - if (unlikely(!folio)) - goto isolate_fail; - /* * Migration will fail if an anonymous page is pinned in memory, * so avoid taking lru_lock and isolating it unnecessarily in an