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 X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B968C3F2D7 for ; Tue, 3 Mar 2020 03:37:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AF6B92173E for ; Tue, 3 Mar 2020 03:37:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF6B92173E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1D8126B0005; Mon, 2 Mar 2020 22:37:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1885B6B0006; Mon, 2 Mar 2020 22:37:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09D866B0007; Mon, 2 Mar 2020 22:37:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0207.hostedemail.com [216.40.44.207]) by kanga.kvack.org (Postfix) with ESMTP id E4F9A6B0005 for ; Mon, 2 Mar 2020 22:37:03 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B9B771359A for ; Tue, 3 Mar 2020 03:37:03 +0000 (UTC) X-FDA: 76552639926.06.fight14_5aae4690e574d X-HE-Tag: fight14_5aae4690e574d X-Filterd-Recvd-Size: 3968 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Mar 2020 03:37:02 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2020 19:37:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,509,1574150400"; d="scan'208";a="232132380" Received: from yhuang-dev.sh.intel.com ([10.239.159.23]) by fmsmga007.fm.intel.com with ESMTP; 02 Mar 2020 19:36:58 -0800 From: "Huang, Ying" To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huang Ying , Dave Hansen , David Hildenbrand , Mel Gorman , Vlastimil Babka , Zi Yan , Michal Hocko , Minchan Kim , Johannes Weiner , Hugh Dickins Subject: [PATCH] mm, migrate: Check return value of try_to_unmap() Date: Tue, 3 Mar 2020 11:36:45 +0800 Message-Id: <20200303033645.280694-1-ying.huang@intel.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: From: Huang Ying During the page migration, try_to_unmap() is called to replace the page table entries with the migration entries. Now its return value is ignored, that is generally OK in most cases. But in theory, it's possible that try_to_unmap() return false (failure) for the page migration after arch_unmap_one() is called in unmap code. Even if without arch_unmap_one(), it makes code more robust for the future code changing to check the return value. Known issue: I don't know what is the appropriate error code for try_to_unmap() failure. Whether EIO is OK? Signed-off-by: "Huang, Ying" Cc: Dave Hansen Cc: David Hildenbrand Cc: Mel Gorman Cc: Vlastimil Babka Cc: Zi Yan Cc: Michal Hocko Cc: Minchan Kim Cc: Johannes Weiner Cc: Hugh Dickins --- mm/migrate.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 3900044cfaa6..981f8374a6ef 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1116,8 +1116,11 @@ static int __unmap_and_move(struct page *page, str= uct page *newpage, /* Establish migration ptes */ VM_BUG_ON_PAGE(PageAnon(page) && !PageKsm(page) && !anon_vma, page); - try_to_unmap(page, - TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS); + if (!try_to_unmap(page, + TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS)) { + rc =3D -EIO; + goto out_unlock_both; + } page_was_mapped =3D 1; } =20 @@ -1337,8 +1340,11 @@ static int unmap_and_move_huge_page(new_page_t get= _new_page, goto put_anon; =20 if (page_mapped(hpage)) { - try_to_unmap(hpage, - TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS); + if (!try_to_unmap(hpage, + TTU_MIGRATION|TTU_IGNORE_MLOCK|TTU_IGNORE_ACCESS)) { + rc =3D -EIO; + goto unlock_both; + } page_was_mapped =3D 1; } =20 @@ -1349,6 +1355,7 @@ static int unmap_and_move_huge_page(new_page_t get_= new_page, remove_migration_ptes(hpage, rc =3D=3D MIGRATEPAGE_SUCCESS ? new_hpage : hpage, false); =20 +unlock_both: unlock_page(new_hpage); =20 put_anon: @@ -2558,8 +2565,7 @@ static void migrate_vma_unmap(struct migrate_vma *m= igrate) continue; =20 if (page_mapped(page)) { - try_to_unmap(page, flags); - if (page_mapped(page)) + if (!try_to_unmap(page, flags)) goto restore; } =20 --=20 2.25.0