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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68710C77B73 for ; Mon, 5 Jun 2023 11:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231998AbjFELP0 (ORCPT ); Mon, 5 Jun 2023 07:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231936AbjFELPP (ORCPT ); Mon, 5 Jun 2023 07:15:15 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6839AF2 for ; Mon, 5 Jun 2023 04:15:13 -0700 (PDT) Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QZWF5477wzLmfx; Mon, 5 Jun 2023 19:13:29 +0800 (CST) Received: from [10.174.179.160] (10.174.179.160) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 5 Jun 2023 19:15:09 +0800 Message-ID: <0e567e11-e735-d092-afac-b2a3106d3f9b@huawei.com> Date: Mon, 5 Jun 2023 19:15:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH 2/2] mm/hugetlb: Use a folio in hugetlb_wp() Content-Language: en-US To: Mike Kravetz , Matthew Wilcox CC: , , , , , , , References: <20230602015408.376149-1-zhangpeng362@huawei.com> <20230602015408.376149-3-zhangpeng362@huawei.com> <20230602205239.GB3941@monkey> From: "zhangpeng (AS)" In-Reply-To: <20230602205239.GB3941@monkey> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.160] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/6/3 4:52, Mike Kravetz wrote: > On 06/02/23 21:17, Matthew Wilcox wrote: >> On Fri, Jun 02, 2023 at 09:54:08AM +0800, Peng Zhang wrote: >>> From: ZhangPeng >>> >>> We can replace nine implict calls to compound_head() with one by using >>> old_folio. However, we still need to keep old_page because we need to >>> know which page in the folio we are copying. >> Do we? It's my understanding (and I am far from an expert here ...) >> that the 'pte_t *' we are passed *inside hugetlbfs* is not in fact a pte >> pointer at all but actually a pmd or pud pointer. > That may not be technically true in some arch specific cases such as > arm64 with CONT_PTES and CONT_PMDS. > >> See how we do this: >> >> pte_t pte = huge_ptep_get(ptep); >> >> and so the page we get back is always a head page, and we can go >> directly to a folio. ie this is different from the THP cases. > However, it is true that ptep will always be associated with the head > page. This is because the associated virtual address is hugetlb page > aligned. > > So, I agree with Matthew that there is no need to keep old_page. > Note that if old_page was NOT the head page, then > > copy_user_huge_page(&new_folio->page, old_page, address, vma, > pages_per_huge_page(h)); > > would write beyond the end of range as it assumes old_page is head. Agreed. I'll send a v2 soon. Thanks. Best Regards, Peng