From patchwork Wed Jan 6 08:47:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12001131 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 30428C433E0 for ; Wed, 6 Jan 2021 08:49:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B82A423107 for ; Wed, 6 Jan 2021 08:49:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B82A423107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 469438D00F5; Wed, 6 Jan 2021 03:49:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 418958D0090; Wed, 6 Jan 2021 03:49:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E0A18D00F5; Wed, 6 Jan 2021 03:49:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0047.hostedemail.com [216.40.44.47]) by kanga.kvack.org (Postfix) with ESMTP id 1293E8D0090 for ; Wed, 6 Jan 2021 03:49:45 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D548E365C for ; Wed, 6 Jan 2021 08:49:44 +0000 (UTC) X-FDA: 77674727088.19.lift93_3e00da8274e0 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id B781E1AD1BA for ; Wed, 6 Jan 2021 08:49:44 +0000 (UTC) X-HE-Tag: lift93_3e00da8274e0 X-Filterd-Recvd-Size: 3979 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Jan 2021 08:49:44 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id t6so1234739plq.1 for ; Wed, 06 Jan 2021 00:49:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EFKJSs8Uw2qVkTfChSTguLsyINtR2C6KwmPPD3vJNks=; b=QzxUz3LBxD+LD/LGS4gpuONiFu9PnmrSYsvkGbjhKmkC0fdySJgrgsYNQv3nFsJebo bx4ZKaHKV2z0UWknW0n1ym6XrnwJKBaQdvIHyKZXlf+G74/SrbpSBaqDLvkLqrsRHquu Yb5StZdj/bzOJxEaJzoXfqaKI/SmEbyiouldh1715V8vizroo2STwOpl3kIHk4lGkdFH eKAofVYlGutq5/36516cYdj7QZ2HP44H5eU8k/EgffGlxfRMLmFXd0hbMsZ81QWL9uYb EF2XOODsnxnNAFph2UbvKRYBGWyCV23dMBuOMq3bpwa/1uGecxzOGPo4CCyoz3gcj2FB PRzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EFKJSs8Uw2qVkTfChSTguLsyINtR2C6KwmPPD3vJNks=; b=fAyMrKYu4pI/Neq7L0NhQpMYxad3wBPjnRicIbrGIHitCkyw9dDh1DIaO5mxLKJ1Lk EfUUyxY6HDUYRJCtDyLKe/3nvKUduM8Ds6pp82GSHdveQefNsfy9Me212gKTblMFWiJf mf8CnqqlbnD5EiTC6gnYj/dw/hoYODyfuDlbjPuIj/Am4GcwA+uFeeyrsykgDFNXjEFX WDNBGph2GBndYdy2UVVrc/Owlz+Ibxke7miAnoi06ElqXcR7TN7nnGd66MwojVjzjzF5 Z56JgIN/FtOwndxTWZQ2ToCFE+ECIZ6Jc5blZ03QySQDu9MYnpNga8/WIblXNKG/Xk3t q0VQ== X-Gm-Message-State: AOAM532+mVI0iE32UbY6vJWvplTan4XS8HivyGCqCHq1Wc1njmlVnofa y3XADmJDeSBuA7h1Eoz1ZcW9pQ== X-Google-Smtp-Source: ABdhPJzITf3AUbohjO7HdzweaiVQS+Z3gBxO7k/zuZ+qw6GyYiCTZN5Voph+bWWIdBlBn4zEEtPVqg== X-Received: by 2002:a17:90a:6587:: with SMTP id k7mr3379913pjj.154.1609922983278; Wed, 06 Jan 2021 00:49:43 -0800 (PST) Received: from localhost.localdomain ([139.177.225.232]) by smtp.gmail.com with ESMTPSA id h8sm1851806pjc.2.2021.01.06.00.49.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jan 2021 00:49:42 -0800 (PST) From: Muchun Song To: mike.kravetz@oracle.com, akpm@linux-foundation.org Cc: n-horiguchi@ah.jp.nec.com, ak@linux.intel.com, mhocko@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song , Yang Shi Subject: [PATCH v2 1/6] mm: migrate: do not migrate HugeTLB page whose refcount is one Date: Wed, 6 Jan 2021 16:47:34 +0800 Message-Id: <20210106084739.63318-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210106084739.63318-1-songmuchun@bytedance.com> References: <20210106084739.63318-1-songmuchun@bytedance.com> MIME-Version: 1.0 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: If the refcount is one when it is migrated, it means that the page was freed from under us. So we are done and do not need to migrate. Signed-off-by: Muchun Song Reviewed-by: Mike Kravetz Acked-by: Yang Shi --- mm/migrate.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/migrate.c b/mm/migrate.c index 4385f2fb5d18..a6631c4eb6a6 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1279,6 +1279,12 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, 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;