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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7ED19C54E67 for ; Thu, 28 Mar 2024 05:08:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E4BC6B009C; Thu, 28 Mar 2024 01:08:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 095B36B009D; Thu, 28 Mar 2024 01:08:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC58E6B009E; Thu, 28 Mar 2024 01:08:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CFE506B009C for ; Thu, 28 Mar 2024 01:08:14 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A49D71C1086 for ; Thu, 28 Mar 2024 05:08:14 +0000 (UTC) X-FDA: 81945266508.04.0BD6697 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf03.hostedemail.com (Postfix) with ESMTP id F162920012 for ; Thu, 28 Mar 2024 05:08:11 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1711602492; 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=ab9i4h0+NuhdKhzBlDX2R0FtCnNyI7G7+Bet533UQ1U=; b=fnVNX4sXxtkMNTgh+OXVxHbJ7QHTVUTY7seAKT1t8iAb/8mBnRbWOqSDvpesPR9gQHF1cD lGPfCZq91MkSr27Nnh/8RLfB7lP8y0hOa6LgqCzI7MJo3J3fYxyM/VY/WDDvcLBQUOKt9q e26tuLXK8rFelCBHKOX1C88XDp6QZHs= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf03.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711602492; a=rsa-sha256; cv=none; b=I96a4JFEplP4EjEM51XvH9+Iwjfd7Y0fL2o1nl2bvCLf0eYebTgBcKzxe6oyN+Q5KAevzW P8dqqitr1x/O8zdWFutuj8+Lytc6Ny89sZScA2oKldJmC6Of7/RHSUIJInkkJ0CE+acgui tvcWLAOgn597rmsJIumpRgcTn7YzS2c= Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4V4s1d47c8ztQW4; Thu, 28 Mar 2024 13:05:41 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id D017E1404DB; Thu, 28 Mar 2024 13:08:07 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) 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; Thu, 28 Mar 2024 13:08:07 +0800 Message-ID: <3839b0b2-e980-4ea1-93f3-f37367af1a66@huawei.com> Date: Thu, 28 Mar 2024 13:08:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/6] mm: migrate: add isolate_movable_folio() Content-Language: en-US To: Vishal Moola CC: Andrew Morton , , Miaohe Lin , Naoya Horiguchi , David Hildenbrand , Oscar Salvador , Zi Yan , Hugh Dickins , Jonathan Corbet , , , Baolin Wang References: <20240327141034.3712697-1-wangkefeng.wang@huawei.com> <20240327141034.3712697-2-wangkefeng.wang@huawei.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: F162920012 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5a98wjmh1k7zbfpzz6kochj4sgkfyi7r X-HE-Tag: 1711602491-341116 X-HE-Meta: U2FsdGVkX19KDm+L36t0+mMbhI5xOQ1sqAQQdphyzW/bnK8v12p5strEVsR65ThwgyyHo1KxdE4i9O9+uom0dHxP3LSeQqs0UtRMuHx0IXSOzxe9IX4QLmz6D1cXVWEFWDwsxXgFghouTXpOfcjnbsf6J6MZl/bVEEeiF1Yp7lQiUmyKVk0BZgqJ9+kCEIyteRyVuBXQ3LdJ29JLutmNxI9J5j6rBrGzbvFET4NKemtFfBuZgb9nIcUbvY3h2zprcKfE2xvD977xczgm/4yecPLwGTfEqCKVMq4HM5hi+FdGhk83oIiXYqYVPETF7XAFvX49M2qalwQBbJJCh5bt5Rg4Vms+XusixnoVOf9UOYdb0AIKXiTElTZkjBrN7oI7PiIMPuZBaChARCOZQHEpbFe8O9LyLDz8Ph34UQF4gSTOr3r1gIs9kCNT03l0f0JDAxCefb0koV/mcYEWbtfcjZzi1of7sJ7An4kjsLbueTNIlz0i1iiYQWbwQ/XNXiF4ywZEGRBlxfan+4IbzvRUQtqAiMgclsv7/LM855n+MmgBLjyZoBBfewpj9ZYoszg8FzhmT1rLRujEKE9YqF5P6FQbTPhmuT1+EmOxICFQIa0rmP+DfOJY9VyBQBaWVgGr82Is9Dyst6sfZGy8BwuluC3D8PgPYynFDJanPZ9n6g6VF8hnkkXi7jjW+bWsT7T4Ys9wTz5hNOJRYO9X29XOERSWJQRhl1iHzDXjoLMT3T/NebCvCdwsfUHlFE79/c96HL8AvDxjMQPsNhX9pQIwCAlIdTvCGoXJ8J518Dr1R9bzyp3RUdr7Y9hrQ6lWrBFn7PtX5AE5L3mHuml0GvRZfo+W2GBUap3aycO0U8xg5lB7/Ou/BzWQA0ohnPnbJhENjukQkCqWPy35hRFSqxggQ9g5KmJbXpEsnaU81FXDBxwpdkOax0REuXpU+g/XevN4aa+71romCDAcuGswQGm aUEmBV9x 3DLwacw80FAOxGYlUz5cXkpWY6oF6g34YUw4el57IH0lnfg23zKoWtkRFhH8X+xSJbI5hzt84rc1RVTWjSyLFZPUdY0htBRVWRJKlcal+P8u48ItEmn6wwFPG2zxIExvmzIu/E17uiab20lAdpv4VtLHdZzu0qaVZUe6U6WMoZFyxNGILueFcE0QwggVcgsBbU8dwcznD2BuWquQZLOhVpLe+16Vdvm2aU/T87N4pWXbIGD2cF3DwakIUeSP9xQkCPzy6GBwXalUM3+fa+8QSrgY7oeU5iGsvwttXDd3IrfQFvGkCvM/9UG8oXMwNzThafHws 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: On 2024/3/28 2:59, Vishal Moola wrote: > On Wed, Mar 27, 2024 at 10:10:29PM +0800, Kefeng Wang wrote: >> Like isolate_lru_page(), make isolate_movable_page() as a wrapper >> around isolate_lru_folio(), since isolate_movable_page() always >> fails on a tail page, add a warn for tail page and return immediately. >> >> Signed-off-by: Kefeng Wang >> --- >> include/linux/migrate.h | 3 +++ >> mm/migrate.c | 41 +++++++++++++++++++++++------------------ >> 2 files changed, 26 insertions(+), 18 deletions(-) >> >> diff --git a/include/linux/migrate.h b/include/linux/migrate.h >> index f9d92482d117..a6c38ee7246a 100644 >> --- a/include/linux/migrate.h >> +++ b/include/linux/migrate.h >> @@ -70,6 +70,7 @@ int migrate_pages(struct list_head *l, new_folio_t new, free_folio_t free, >> unsigned int *ret_succeeded); >> struct folio *alloc_migration_target(struct folio *src, unsigned long private); >> bool isolate_movable_page(struct page *page, isolate_mode_t mode); >> +bool isolate_movable_folio(struct folio *folio, isolate_mode_t mode); >> >> int migrate_huge_page_move_mapping(struct address_space *mapping, >> struct folio *dst, struct folio *src); >> @@ -91,6 +92,8 @@ static inline struct folio *alloc_migration_target(struct folio *src, >> { return NULL; } >> static inline bool isolate_movable_page(struct page *page, isolate_mode_t mode) >> { return false; } >> +static inline bool isolate_movable_folio(struct page *page, isolate_mode_t mode) >> + { return false; } > > Wrong argument here. Mistake, will fix. > >> >> static inline int migrate_huge_page_move_mapping(struct address_space *mapping, >> struct folio *dst, struct folio *src) >> diff --git a/mm/migrate.c b/mm/migrate.c >> index 2228ca681afb..b2195b6ff32c 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -57,31 +57,29 @@ >> >> #include "internal.h" >> >> -bool isolate_movable_page(struct page *page, isolate_mode_t mode) >> +bool isolate_movable_folio(struct folio *folio, isolate_mode_t mode) >> { >> - struct folio *folio = folio_get_nontail_page(page); >> const struct movable_operations *mops; >> >> /* >> - * Avoid burning cycles with pages that are yet under __free_pages(), >> + * Avoid burning cycles with folios that are yet under __free_pages(), >> * or just got freed under us. >> * >> - * In case we 'win' a race for a movable page being freed under us and >> + * In case we 'win' a race for a movable folio being freed under us and >> * raise its refcount preventing __free_pages() from doing its job >> - * the put_page() at the end of this block will take care of >> - * release this page, thus avoiding a nasty leakage. >> + * the folio_put() at the end of this block will take care of >> + * release this folio, thus avoiding a nasty leakage. >> */ >> - if (!folio) >> - goto out; >> + folio_get(folio); >> >> if (unlikely(folio_test_slab(folio))) >> goto out_putfolio; >> /* Pairs with smp_wmb() in slab freeing, e.g. SLUB's __free_slab() */ >> smp_rmb(); >> /* >> - * Check movable flag before taking the page lock because >> - * we use non-atomic bitops on newly allocated page flags so >> - * unconditionally grabbing the lock ruins page's owner side. >> + * Check movable flag before taking the folio lock because >> + * we use non-atomic bitops on newly allocated folio flags so >> + * unconditionally grabbing the lock ruins folio's owner side. >> */ >> if (unlikely(!__folio_test_movable(folio))) >> goto out_putfolio; >> @@ -91,13 +89,13 @@ bool isolate_movable_page(struct page *page, isolate_mode_t mode) >> goto out_putfolio; >> >> /* >> - * As movable pages are not isolated from LRU lists, concurrent >> - * compaction threads can race against page migration functions >> - * as well as race against the releasing a page. >> + * As movable folios are not isolated from LRU lists, concurrent >> + * compaction threads can race against folio migration functions >> + * as well as race against the releasing a folio. >> * >> - * In order to avoid having an already isolated movable page >> + * In order to avoid having an already isolated movable folio >> * being (wrongly) re-isolated while it is under migration, >> - * or to avoid attempting to isolate pages being released, >> + * or to avoid attempting to isolate folios being released, >> * lets be sure we have the page lock >> * before proceeding with the movable page isolation steps. >> */ >> @@ -113,7 +111,7 @@ bool isolate_movable_page(struct page *page, isolate_mode_t mode) >> if (!mops->isolate_page(&folio->page, mode)) >> goto out_no_isolated; >> >> - /* Driver shouldn't use PG_isolated bit of page->flags */ >> + /* Driver shouldn't use PG_isolated bit of folio->flags */ >> WARN_ON_ONCE(folio_test_isolated(folio)); >> folio_set_isolated(folio); >> folio_unlock(folio); >> @@ -124,10 +122,17 @@ bool isolate_movable_page(struct page *page, isolate_mode_t mode) >> folio_unlock(folio); >> out_putfolio: >> folio_put(folio); >> -out: >> return false; >> } >> >> +bool isolate_movable_page(struct page *page, isolate_mode_t mode) >> +{ >> + if (WARN_RATELIMIT(PageTail(page), "trying to isolate tail page")) >> + return false; > > This warning doesn't make sense. As of now, we still isolate_movable_page() > to be able to take in a tail page, we just don't want to operate on it. Zi replied too, I will remove it. Thanks. > >> + return isolate_movable_folio((struct folio *)page, mode); >> +} >> + >> static void putback_movable_folio(struct folio *folio) >> { >> const struct movable_operations *mops = folio_movable_ops(folio); >> -- >> 2.27.0 >>