Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp517580rwl; Wed, 9 Aug 2023 19:20:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqnc7ZIe+liX7EEMqsU9KuUwYFWw9h5QoFsOMHuiWdgfeT6qbo9t4yEe7QdsfgdkVR99mF X-Received: by 2002:a19:f506:0:b0:4fe:2d93:2b51 with SMTP id j6-20020a19f506000000b004fe2d932b51mr742420lfb.27.1691634023344; Wed, 09 Aug 2023 19:20:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691634023; cv=none; d=google.com; s=arc-20160816; b=E+La8dv809nH0OjQIk5X3IWmQnLhs9TivwFVTVvrYBy+d1cHOfyAStxqYzpom39B3f tIE+t9vsxlGByihqYmdRhh50L5AVDJoWUO0u58Ghbdu2GlN2hddkIIHqbyRvRMCkH/85 xQbXfJtEOrDknGKFovI5IZ4ty8AuRHhdJ6YQsisJ84W04fq/GBaJ4J5qTK6Of+TocMGD me3nD3kODep8QyANP/6qhGALdaZ0N3kjYuFEtp9SlhpMfUlnezvZkovpZ4q82W5APa+4 nsa8YV+wW1uMwLCGQvNOsNLKVYDmbOo/ZKPODgCDiQ3ogoua8be9jXBJQI+147F1MGWp yWxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=RJQTP/ussXjRAapehZNkVd4+uxVyn1l8TL5dtKGrg+c=; fh=JkBzjH8GFBjT3wI8XhYZOPx0+mqkT3Xjz0zD/v153JE=; b=hV0oV7ZSmdViLJzqJq2crpRZzpKkKIy6RZUicfMgslJZco4cPe8SQ33TxnrsRew7XW LIepnQP0aANGMbASQIKgpE83ed/s9rC4Nk6r4nc8Fxmxo2oF3yKI0CmFld++YJ/NVtFO rMdydsY24p6KKEFd4EURtmgEJvrPCUmOdgtOM1rLc9kJt6dyEYUufNr5Fy2MMLLR/PAz 0CzEr3kGc9k73Noo8WUxvuPJurSE8jdMza4snA6os8gSPyEPFbjmTlunn2C/aaFZFI34 BRSN9LvMotdJ6sqG3nJJSfoyMupXD8rTUBLktiupcGhxfNC6rqbif0oeJVJy9qhZw9TJ FqUg== 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 17-20020a170906059100b0099ca6e1b1f1si499937ejn.1055.2023.08.09.19.19.58; Wed, 09 Aug 2023 19:20:23 -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 S232049AbjHJBtU (ORCPT + 99 others); Wed, 9 Aug 2023 21:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231989AbjHJBtT (ORCPT ); Wed, 9 Aug 2023 21:49:19 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D425810DA for ; Wed, 9 Aug 2023 18:49:17 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RLqXK0Sj2zkXwR; Thu, 10 Aug 2023 09:46:25 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 10 Aug 2023 09:49:15 +0800 Message-ID: <2da95492-079b-43b1-a950-d290984a21c0@huawei.com> Date: Thu, 10 Aug 2023 09:49:14 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/4] mm: migrate: use a folio in add_page_for_migration() Content-Language: en-US To: Mike Kravetz CC: Zi Yan , Naoya Horiguchi , Matthew Wilcox , Andrew Morton , , , Huang Ying , David Hildenbrand References: <001ee9b0-ea25-a896-e3ae-9a9b05a46546@huawei.com> <5BBFF5D3-3416-4C0E-9FDD-655661657D67@nvidia.com> <20230809205316.GA3537@monkey> <20230809224424.GB3537@monkey> From: Kefeng Wang In-Reply-To: <20230809224424.GB3537@monkey> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 2023/8/10 6:44, Mike Kravetz wrote: > On 08/09/23 13:53, Mike Kravetz wrote: >> On 08/09/23 20:37, Kefeng Wang wrote: >>>> >>>> Cc Mike to help us clarify the expected behavior of hugetlb. >>>> >>>> Hi Mike, what is the expected behavior, if a user tries to use move_pages() >>>> to migrate a non head page of a hugetlb page? >>> >>> Could you give some advise, thanks >>> >> >> Sorry, I was away for a while. >> >> It seems unfortunate that move_pages says the passed user addresses >> should be aligned to page boundaries. However, IIUC this is not checked >> or enforced. Otherwise, passing a hugetlb page should return the same >> error. >> >> One thought would be that hugetlb mappings should behave the same >> non-hugetlb mappings. If passed the address of a hugetlb tail page, align >> the address to a hugetlb boundary and migrate the page. This changes the >> existing behavior. However, it would be hard to imagine anyone depending >> on this. >> >> After taking a closer look at the add_page_for_migration(), it seems to >> just ignore passed tail pages and do nothing for such passed addresses. >> Correct? Or, am I missing something? Perhaps that is behavior we want/ >> need to preserve? > > My mistake, status -EACCES is returned when passing a tail page of a > hugetlb page. > As mentioned in previous mail, before e66f17ff7177 ("mm/hugetlb: take page table lock in follow_huge_pmd()") in v4.0, follow_page() will return NULL on tail page for Huagetlb page, so move_pages() will return -ENOENT errno, but after that commit, -EACCES is returned. Meanwhile, the behavior of THP/HUGETLB is different, the whole THP will be migrated on a tail page, but HUGETLB will return -EACCES(after v4.0) or -ENOENT(before v4.0) on tail page. > Back to the question of 'What is the expected behavior if a tail page is > passed?'. I do not think we have defined an expected behavior. If > anything is 'expected' I would say it is -EACCES as returned today. > My question is, Should we keep seem behavior between HUGETLB and THP, or only change the errno from -EACCES to -ENOENT/-EBUSY. I would like to drop PageHead() check for Hugetlb to keep seem behavior, which will keep seem error code if isolate fail or success on head/tail page. Thanks. > BTW - hugetlb pages not migrated due to passing a tail page does not > seem to contribute to a 'Positive return value' indicating the number of > non-migrated pages.