Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp620704ioo; Thu, 26 May 2022 10:40:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNJ8NXb1pooNsJ1/fQLYy0IN6qVPKDH0W6gjuCwajAFQdpdBcfst7oPLS/2bXGRi8lvY/j X-Received: by 2002:aa7:c38a:0:b0:42a:ab63:c5a3 with SMTP id k10-20020aa7c38a000000b0042aab63c5a3mr41089734edq.303.1653586833517; Thu, 26 May 2022 10:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653586833; cv=none; d=google.com; s=arc-20160816; b=JwemlPcCFx5auPoHooOrkjHseDT9uUivtDcM6GiJxzVYJkr1Y7HsDY5rfdYLExf1Mv OM9un1FmsoW+vTTXlMRz/jTL9heQEhP1gu93VwRjOTVy75Vtp2Dy3hn8UtGBhsTP2Ezy ZgLZ4tI8HHqSmj/4Re1bpGLqrS6SBOo8tXLHSqtpJLQcVloCYORjjk8ToWEzJ4r3ZDf8 89KQHL4NJm//YFmh+gAXZuvDi0bAaMOOAf9CzKQrPDo/gAn5PNN7K+Zj3bct0F7jITLN GPR55cT8sD5RB5JSzgE1n2EzVI9qJwjWYi6ElLb8Q1UEoJpT+OamvBDyGFCtXro5+GYW 9TUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=jEfTYlGwq8q5icyHryST8Hf4nFK62/qIlD4l6gUdZ4k=; b=a/UOmMKnFNAns5nmusoPdVG7HgICPdtu8N+53V7RwVqPeBFLMUuDc2E1CIC1Bzq5r3 leJsik7Y3+Qt3jTbG3FJj8IS7TIFSr34MgHbe/jD8RYH0fcRh8lVT2IgLqkaR960Xn2b 2l/st+lQ+Za8o8betzSyV4F0Ey/b/yniMDDakM3xVQ/1nGHtjn4MJQoR2HQIlUCQK4K3 bRpbEk51KxppE2WXUDh46gSW6WEnMRDftEBOOBqTbcKq4+3SfPURCBm4JzPc0KEWgzPL 8RTUsMpKOeg9nqiyAiZigaD9L+2qxUhFl+uwX4sASN8eHgH9wo46kh5zSKnuMkAy9VlO sEnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w22-20020a056402269600b0042b514e3d3csi2774108edd.32.2022.05.26.10.40.05; Thu, 26 May 2022 10:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240340AbiEZBxZ (ORCPT + 99 others); Wed, 25 May 2022 21:53:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235094AbiEZBxT (ORCPT ); Wed, 25 May 2022 21:53:19 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA161A76E7 for ; Wed, 25 May 2022 18:53:17 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4L7rXw1mvHzjX5h; Thu, 26 May 2022 09:52:32 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 26 May 2022 09:53:15 +0800 Subject: Re: [PATCH v3 3/4] mm/migration: return errno when isolate_huge_page failed To: Oscar Salvador CC: , , , , , , , , , , , , References: <20220525081822.53547-1-linmiaohe@huawei.com> <20220525081822.53547-4-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: <5ed70fbc-c582-6e85-22bc-3ccafa0d7a3f@huawei.com> Date: Thu, 26 May 2022 09:53:15 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/5/25 16:41, Oscar Salvador wrote: > On Wed, May 25, 2022 at 04:18:21PM +0800, Miaohe Lin wrote: >> We might fail to isolate huge page due to e.g. the page is under migration >> which cleared HPageMigratable. We should return errno in this case rather >> than always return 1 which could confuse the user, i.e. the caller might >> think all of the memory is migrated while the hugetlb page is left behind. >> We make the prototype of isolate_huge_page consistent with isolate_lru_page >> as suggested by Huang Ying and rename isolate_huge_page to isolate_hugetlb >> as suggested by Muchun to improve the readability. >> >> Fixes: e8db67eb0ded ("mm: migrate: move_pages() supports thp migration") >> Suggested-by: Huang Ying >> Signed-off-by: Miaohe Lin > > Looks good to me, one thing below though: > >> --- >> include/linux/hugetlb.h | 6 +++--- >> mm/gup.c | 2 +- >> mm/hugetlb.c | 11 +++++------ >> mm/memory-failure.c | 2 +- >> mm/mempolicy.c | 2 +- >> mm/migrate.c | 5 +++-- >> 6 files changed, 14 insertions(+), 14 deletions(-) >> > ... >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -1627,8 +1627,9 @@ static int add_page_for_migration(struct mm_struct *mm, unsigned long addr, >> >> if (PageHuge(page)) { >> if (PageHead(page)) { >> - isolate_huge_page(page, pagelist); >> - err = 1; >> + err = isolate_hugetlb(page, pagelist); >> + if (!err) >> + err = 1; >> } > > We used to always return 1 which means page has been queued for migration, as we > did not check isolate_huge_page() return value. > Now, we either return 1 or 0 depending on isolate_hugetlb(). Return 1 or -EBUSY just as normal page case. > I guess that was fine because in the end, if isolate_huge_page() failed, > the page just does not get added to 'pagelist', right? So, it is just > confusing for the user because he might not get an error so he thinks > the page will be migrated, and yet will not? Yes, the hugetlb page might not be migrated due to error while it's not reported in the __user *status. So the caller might think all of the memory is migrated and thus does not retry to migrate the hugetlb page in the next round. Many thanks for your review and comment! :) > >