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=-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 1EC9AC433E0 for ; Fri, 15 Jan 2021 12:51:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B06E4223E0 for ; Fri, 15 Jan 2021 12:51:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B06E4223E0 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 3CF3B8D0161; Fri, 15 Jan 2021 07:51:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 37D6D6B0135; Fri, 15 Jan 2021 07:51:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26D2D8D0161; Fri, 15 Jan 2021 07:51:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id 0F1176B0134 for ; Fri, 15 Jan 2021 07:51:18 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CA97D180AD807 for ; Fri, 15 Jan 2021 12:51:17 +0000 (UTC) X-FDA: 77707994994.21.nut69_3c0e1952752f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id ACA2A180445EF for ; Fri, 15 Jan 2021 12:51:17 +0000 (UTC) X-HE-Tag: nut69_3c0e1952752f X-Filterd-Recvd-Size: 4571 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Jan 2021 12:51:16 +0000 (UTC) Received: by mail-pg1-f177.google.com with SMTP id i7so5945848pgc.8 for ; Fri, 15 Jan 2021 04:51:16 -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=wusSjLYakm6+Z6kCpNRodcZYujbXCjpbVczSV3qSR3o=; b=b6lkShudiFwH3nXVrpZX+gqStufxvurJdvxqDVcsPwjtLMN2djbpgCbGywiWqyrga0 M+gaefZbiLj+89pB2Ym76UEVbWAtzoIKFtD9vcTv29FSbXO2UNvefzDUeC5iGKY/o/Zv MFDBbzHCxL4A2Po1RducNPu56GgVGipGd0fA1OchQLbycyi7LY+WPaQfd5ntlO0bwOIV AH6hPW1wqlcg4Wi/nrhzdDWzT1SCAjciK6n+CUEGiuyeET5sIJmZrS19/hpDoL125GAy 77LHlv69plegW8wOEDThn4B2DE2SL7hw1wb2rDt7Xeuv1vmmGCUt8YDIJRKHzEOTUmJ9 v55Q== 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=wusSjLYakm6+Z6kCpNRodcZYujbXCjpbVczSV3qSR3o=; b=eRxilvqaP2LLDVaJ03aBDhpX0Ud4qCMv6AQoAf5k/yCIZW66kQ8QDwbHj1TI4z1B27 3J1mHnTuS8roOaJXf+w4rXRjliJM+JGsFAJP38o9WM/DvUupvoKV2E6B58Zc3KVqSakF xGKfTonqWO1OwaZ3FF9+fAELWLUwh+V732Fdeqyz7NMbq/6Thme+f/anQ7op53lKZ4sT Gg35pimgvpw32ebLgB12iTsUnKoUmO6OruJauA+2lDfpXjvgKirnvHRVAdizM1u6XykL xnxd5SAnbQt0HOBeeEBFPidzuwKAyM1ECymukR2M+qvR3vuIRrXTmtU/TSLMS64KGz9i /9bg== X-Gm-Message-State: AOAM533bWzyJx1TmahwFQxeUq5HE3URgn5i14QT6nrrTHe933tnKyej/ 3t+QDgOuXQvMCJmhLr1DRDt77A== X-Google-Smtp-Source: ABdhPJxGSYg/GU3hqllaplzUHovQRCfeeWtqx+DxFm1YmqgDcB1pUCRHVxptmFPNYm9/Rr6pzhq4hQ== X-Received: by 2002:a63:5fcf:: with SMTP id t198mr12329283pgb.226.1610715075683; Fri, 15 Jan 2021 04:51:15 -0800 (PST) Received: from localhost.localdomain ([139.177.225.247]) by smtp.gmail.com with ESMTPSA id c5sm8193600pjo.4.2021.01.15.04.51.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jan 2021 04:51:15 -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 , Michal Hocko , David Hildenbrand , Oscar Salvador Subject: [PATCH v6 1/5] mm: migrate: do not migrate HugeTLB page whose refcount is one Date: Fri, 15 Jan 2021 20:49:38 +0800 Message-Id: <20210115124942.46403-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210115124942.46403-1-songmuchun@bytedance.com> References: <20210115124942.46403-1-songmuchun@bytedance.com> 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: 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 likelyhood of the race is rather small for hugetlb pages it makes sense the two code paths in sync. 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 --- 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; } =20 + if (page_count(hpage) =3D=3D 1) { + /* page was freed from under us. So we are done. */ + putback_active_hugepage(hpage); + return MIGRATEPAGE_SUCCESS; + } + new_hpage =3D get_new_page(hpage, private); if (!new_hpage) return -ENOMEM; --=20 2.11.0