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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 B577AC433E0 for ; Fri, 5 Feb 2021 02:32:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5DC9E64FBA for ; Fri, 5 Feb 2021 02:32:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DC9E64FBA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E3D3D6B0072; Thu, 4 Feb 2021 21:32:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DED656B0073; Thu, 4 Feb 2021 21:32:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2BA66B0074; Thu, 4 Feb 2021 21:32:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id C09B36B0072 for ; Thu, 4 Feb 2021 21:32:19 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 906F4180AD817 for ; Fri, 5 Feb 2021 02:32:19 +0000 (UTC) X-FDA: 77782639998.08.shop61_02013d3275e1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 771C71819E772 for ; Fri, 5 Feb 2021 02:32:19 +0000 (UTC) X-HE-Tag: shop61_02013d3275e1 X-Filterd-Recvd-Size: 2813 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Feb 2021 02:32:18 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id BCBC764FB7; Fri, 5 Feb 2021 02:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1612492338; bh=D3win9cBiJAHKxX/4SIDR9bywl+666gt31YejXJeT6s=; h=Date:From:To:Subject:In-Reply-To:From; b=C6qtU7FdiqBuDIIbp8menZfGD5qO+XjkvQaoG4oFqTjwYVB5tfxP15fskXSeDvm0/ fNm7jI3xq4EMYKSaVIqRnJVS0A4DCOFNveC9GNKmtIA0aopziVeRmEPp/nDIJ3ZgZ3 8upn1ZjNAjkrHSf8zNyg+FEocZL5uPOuZ0hLfxq0= Date: Thu, 04 Feb 2021 18:32:17 -0800 From: Andrew Morton To: akpm@linux-foundation.org, david@redhat.com, linux-mm@kvack.org, mhocko@suse.com, mike.kravetz@oracle.com, mm-commits@vger.kernel.org, osalvador@suse.de, shy828301@gmail.com, songmuchun@bytedance.com, torvalds@linux-foundation.org Subject: [patch 05/18] mm: migrate: do not migrate HugeTLB page whose refcount is one Message-ID: <20210205023217.P0pR8PLuH%akpm@linux-foundation.org> In-Reply-To: <20210204183135.e123f0d6027529f2cf500cf2@linux-foundation.org> User-Agent: s-nail v14.8.16 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: Muchun Song Subject: mm: migrate: do not migrate HugeTLB page whose refcount is one All pages isolated for the migration have an elevated reference count and therefore seeing a reference count equal to 1 means that the last user of the page has dropped the reference and the page has became unused and there doesn't make much sense to migrate it anymore. This has been done for regular pages and this patch does the same for hugetlb pages. Although the likelihood of the race is rather small for hugetlb pages it makes sense the two code paths in sync. Link: https://lkml.kernel.org/r/20210115124942.46403-2-songmuchun@bytedance.com Signed-off-by: Muchun Song Reviewed-by: Mike Kravetz Acked-by: Yang Shi Acked-by: Michal Hocko Reviewed-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Andrew Morton --- mm/migrate.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/mm/migrate.c~mm-migrate-do-not-migrate-hugetlb-page-whose-refcount-is-one +++ a/mm/migrate.c @@ -1280,6 +1280,12 @@ static int unmap_and_move_huge_page(new_ return -ENOSYS; } + if (page_count(hpage) == 1) { + /* page was freed from under us. So we are done. */ + putback_active_hugepage(hpage); + return MIGRATEPAGE_SUCCESS; + } + new_hpage = get_new_page(hpage, private); if (!new_hpage) return -ENOMEM; _