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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 0A957C433DB for ; Wed, 13 Jan 2021 05:26:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0C9F23120 for ; Wed, 13 Jan 2021 05:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726082AbhAMF0R (ORCPT ); Wed, 13 Jan 2021 00:26:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbhAMF0Q (ORCPT ); Wed, 13 Jan 2021 00:26:16 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B19C061794 for ; Tue, 12 Jan 2021 21:25:36 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id g3so438463plp.2 for ; Tue, 12 Jan 2021 21:25:36 -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=YM0v4j/Vw+PE0j0qtyYxkInLgfChRzFtd1IYXVhtaBs=; b=UMBMQFjAJ/KleNdrCLc87puq8f82M8nlP3Nlp9Htg8u8SfL+gDjlPEqAOMUsZRA/w5 QrOVLDLG5hbF1ZaqfQA/mitoaGSUq1xnqtF0D0VRy1Vy6BR6fk1y3FuHmYKD67VJTN12 g4OQbOdhAYdQQKfuUvvVRWQJqUquk/cSSyhf5/RafWb6WWGaLqAORg6SQ1PsTOpioG5A y5xY0rFuv3pZD/P4JCT39VRYlOb4zqh+i/D6m0IV4+hy8VZOnYjanvBnASOIeJggxtxv mKd/C7VH6yzziINWeIMJBpBH6nOU/SS6SL3ee5Rxy0Id2T5C2R1bemu+l06tCvPOo4Ib FqKA== 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=YM0v4j/Vw+PE0j0qtyYxkInLgfChRzFtd1IYXVhtaBs=; b=FP/7xLa2+5jDV9tw6V6NWfE+g30SQSeVUOS64w8gA+bUV5RTrWgdTtAvIkzXfOtHPG gus1dOff/qQKOYFpygDHGcXE6MTRoH34dCrRKD9z1sX4jAyIM23ytUFGvFqMUUyQJtvg l+dytbh10IBm4twLx0hyDe+ZHbLtO52fk35Rusa1220e0w+vbCjGEmD4K5E5rz6s4pOI jwitl59gb8pLMkmvLwDOzKrGuAYhQoDMUZb3rteIybkm/XYeU/PjnJLdF+k+5/RqVW48 SvzJF1kenW5HOcSy81jcIi3jR+ly/HBxDMQFp1X03j+S5LrMlsmBq7NaF2tI9FLG3H03 iCNg== X-Gm-Message-State: AOAM5337MWzX4NHBzjV3/BUWIWrLQa8zLkXX9Oi3qVI2zLnMlBeofqEH BL9Dh21C9TR/8ra4KRJb2dzVWw== X-Google-Smtp-Source: ABdhPJxHkGLvnYePvtJVAinVs5t2rPLGqeF5cswjO6y60ppYk2XM0JruFQuehDmZQ5o6gWa3rkMO2w== X-Received: by 2002:a17:902:848e:b029:dc:b38:98f0 with SMTP id c14-20020a170902848eb02900dc0b3898f0mr622492plo.82.1610515535725; Tue, 12 Jan 2021 21:25:35 -0800 (PST) Received: from localhost.localdomain ([139.177.225.247]) by smtp.gmail.com with ESMTPSA id x15sm893081pfa.80.2021.01.12.21.25.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jan 2021 21:25:35 -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 Subject: [PATCH v4 1/6] mm: migrate: do not migrate HugeTLB page whose refcount is one Date: Wed, 13 Jan 2021 13:22:04 +0800 Message-Id: <20210113052209.75531-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20210113052209.75531-1-songmuchun@bytedance.com> References: <20210113052209.75531-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; -- 2.11.0