From patchwork Wed Apr 24 13:59:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13641919 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 B95A5C4345F for ; Wed, 24 Apr 2024 13:59:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A3538D001A; Wed, 24 Apr 2024 09:59:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 120E48D0012; Wed, 24 Apr 2024 09:59:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D66CD8D0017; Wed, 24 Apr 2024 09:59:43 -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 85F5A8D0010 for ; Wed, 24 Apr 2024 09:59:43 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E9B9A1A0262 for ; Wed, 24 Apr 2024 13:59:42 +0000 (UTC) X-FDA: 82044583404.30.851E3D9 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf09.hostedemail.com (Postfix) with ESMTP id 1190C14002C; Wed, 24 Apr 2024 13:59:38 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713967180; 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=9Xogj8tkPJgc13hmp0EWgxmC3HKBDn3Wr1krWpw+Nk4=; b=iQGGxyNOkFDTPgcwsTSgL6x4LcJaMV1dPo8yXuJjLTPMBtct2THW6fJdbiGLtRcJLh/e/t 7D7e/DlAI9mVlKaw6E6ix7uQcT6wK157owQlTuDviTnVimtK3dIZyDGanJWOM8WwhTlBZX fHHzpZvoH8hbxBnK94Z9UrcliA7BFVM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713967180; a=rsa-sha256; cv=none; b=2BjrgvPpBsYHQJNxpUBxeZHSatID5Z8R8vZ3S2fM+jGQ4TlaA5dIQwpr6ZWVMJfe5F8K4L SWil31B4rFsWKxZOmVxTFAX3pziZImkqxeKts086eR/N+mTeeK4edjuk9xX0QrjfG53R7l jehc2lho5JEjDrs6u8GNajFb88Fie3Q= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VPgYz1RCnzShcs; Wed, 24 Apr 2024 21:58:31 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id CFF1F18006B; Wed, 24 Apr 2024 21:59:35 +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, 24 Apr 2024 21:59:35 +0800 From: Kefeng Wang To: Andrew Morton , CC: Tony Luck , Miaohe Lin , Naoya Horiguchi , Matthew Wilcox , David Hildenbrand , Muchun Song , Benjamin LaHaise , , , , Zi Yan , Jiaqi Yan , Hugh Dickins , Vishal Moola , Kefeng Wang Subject: [PATCH v2 03/10] mm: migrate_device: unify migrate folio for MIGRATE_SYNC_NO_COPY Date: Wed, 24 Apr 2024 21:59:22 +0800 Message-ID: <20240424135929.2847185-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240424135929.2847185-1-wangkefeng.wang@huawei.com> References: <20240424135929.2847185-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-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 1190C14002C X-Stat-Signature: bp63s5wi1aza91ne3od7wo8fj898erz4 X-Rspam-User: X-HE-Tag: 1713967178-526896 X-HE-Meta: U2FsdGVkX1+q+25tNNNZayI877Dtt2kW09nVFfFFMxhJw3eYydLY+hBJNIom5B4usQ2zMKSSmhWI44YyQw51yZYJMhuLf6e7UDyErgtnZnHbAu8SznrQSd67Oo767hMnKcv8IeE7kElVChzEgdV7CV/fyQO0rs+8qy4lgwPE6y7tgHXB+4c/QO7xZ5gr5NdEfh5nr8c43xVYqC4rVvQbpfnns0z+Zi4ePIIJpZ1Kudprlh5GvSpmjy79wkVfwUloCq5qUplcE0S4HJ1zQ15SvnJWn+skqDSu8WyufInFViIUAP1AJyGjTmG9RRo09Wmj9mtx/MyqVkrUc7xY8Ro4KMSGx+OWIvB89ruVC73wkZaj/RqamT2swKX3GkFmuwRc/ZNHyfzkkkK/+sgsBVLPOlk5GgdtN+aYs64VZjFGjc6Wk0XAcoSkUQLDoFtzvr6Tuc2kqw63rFfJKG1Pl57PqOWL6Rq5PdsTLl98+hYMOSvsYKOG7SN+4IL7bVyKISoxEOZYmVG6+5dtxHVS1+q9TF7WehR0cpynJwHQDX8U9sp1+f1TDfXLfniGULseifO4Q+vgtqlu8QI74+9TU93I7AVWq56tNocSiRQbl9nyRIRIOyAaUOgZEE5nKChsCovPIJFVLEr4TZzQMkpA9GM1RS31ZuWw0amB67BRZV46kqbsRP7CQn9Ex/PwlPVbQg2Tq/xctMJzQlPk6DYcMWTmQarFIpE1ubw0+jufCk0zS5NKJVq2nIeymFZRlT91bj011Yoznm62hKI4aym5bjKTZfGjBr0E7bfKBG+nzgNjqUbsuBz3Q4WFXQuKEc8/gShLvdT+cdc0g5aCgfwyvM1L/W0s9unSe9LOtUMefo+S4XAs6F4AorCxkLGhHOUqyq/iRTzWolthZdV5TNYUFuN/11C9mXvyA8dVOT/OMDcWNvf7vQOT4agcr0J9N5beYM6Rp63GzuOoNhcuSx4IScf ertus4sP U+vY3RXDpAfw73kSEgr/4ADtKFvgZcIMrPG6u+CuBuffVk/bXBNgCfDGzLPWtlr6aG/bWQf1WySktNuRJB2tILWcJQDeHX0hxG06JC+SsxZFCno7JKn6Pqm6Bal/Ow4tU2Hwu+gcpLMIq0LjvgroA8yGRmTlqzimGnVANIjTfogu0aHBm+3cQV44u97NZ+MmCpOVA6fqys54qSwxXmfWijA6I+dap4Cahl9cmR3MnLdWreSDDrdpW27dc8xI1xcfEgGffs16ipDpIuFg= 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: The __migrate_device_pages() won't copy page so MIGRATE_SYNC_NO_COPY passed into migrate_folio()/migrate_folio_extra(), actually a easy way is just to call folio_migrate_mapping()/folio_migrate_flags(), converting it to unify and simplify the migrate device pages, which also remove the only call for MIGRATE_SYNC_NO_COPY. Signed-off-by: Kefeng Wang --- mm/migrate_device.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 1b6658519f64..5c0237b7f26b 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -691,7 +691,7 @@ static void __migrate_device_pages(unsigned long *src_pfns, struct page *page = migrate_pfn_to_page(src_pfns[i]); struct address_space *mapping; struct folio *newfolio, *folio; - int r; + int r, extra_cnt = 0; if (!newpage) { src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; @@ -753,14 +753,15 @@ static void __migrate_device_pages(unsigned long *src_pfns, continue; } + BUG_ON(folio_test_writeback(folio)); + if (migrate && migrate->fault_page == page) - r = migrate_folio_extra(mapping, newfolio, folio, - MIGRATE_SYNC_NO_COPY, 1); - else - r = migrate_folio(mapping, newfolio, folio, - MIGRATE_SYNC_NO_COPY); + extra_cnt = 1; + r = folio_migrate_mapping(mapping, newfolio, folio, extra_cnt); if (r != MIGRATEPAGE_SUCCESS) src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; + else + folio_migrate_flags(newfolio, folio); } if (notified)