Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3105576rwb; Mon, 16 Jan 2023 03:55:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXt1+LjihVweJpOAfKccO5wmGjxSQCRS05MPCPjOH+sBjrRb6BP0LVN09ZjpjiNXyfGsfm8/ X-Received: by 2002:a17:90b:a47:b0:229:77f:6d2f with SMTP id gw7-20020a17090b0a4700b00229077f6d2fmr15652019pjb.44.1673870113795; Mon, 16 Jan 2023 03:55:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673870113; cv=none; d=google.com; s=arc-20160816; b=xf6/nHQMyJDQ+c1dPh1B6M0s5qkLqJ9Z8uLxW1m9MY8Dzg1Vay8PSKJr8aK5EnVQOp GuWKJT3u/7g/HOgzxXNNcksQO1fbH5wvgPNAMHcYLkC2C/JmCP0dNQNX3kCk80LU1HqD P05JrvfXj/9iUnIOG1j0lDoVeYuTvhoF99fIWTDN9Gms9/iDvJ65x/sl80716bP1w2F8 eaIq3jIn+hlY9swrQ8PMZkASUbUHVjKT0lwOJwvVL1rR+MmGSkQIXO5hkZzArs+l0NZF 4whxOPNCMiKtdicmNM7BDn8DVcM8fMvlELlxGa3XBJL/hIBB89b8bVlzoF3wZA9b+ch/ BZIQ== 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=0vdl7Vmg6gRgprdTodPxZ+uFPHI1R8wcYKvqMwMn8iU=; b=Bd0vc0fPTtEucc+4Wvra2poYVjOfBSObEvOQ0BtDjiqloL2FqqLsFQG/5M7qKeSBZ8 g4yR4qAh3f5QFIKuDky0mi+KaaNN0uN2N02/TUAnYfws0uOygdrXDDAmKxFaefTqca+I X1XP+QqZR2mswPB0DjeJppor4nB19F8bO1k+oqIgIHIrVfjSRkGNB2udSD5DdXX9DDv9 QfCKRTOznD8ZsSxUvSkaWcObQMUccNJZsYbnRXBvBI/P+YbYYdtsytfjFsr1Jh0LMrpE bYk6MOiitGiKul3jz0iUMtUeDpYmHtYug1NDXqQduFbV2lPgJ5a8D9PHW4R+vzD8JLJV n7kg== 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 g6-20020a17090a708600b0022932d0b810si8867098pjk.44.2023.01.16.03.55.07; Mon, 16 Jan 2023 03:55:13 -0800 (PST) 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 S229469AbjAPLKT (ORCPT + 51 others); Mon, 16 Jan 2023 06:10:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbjAPLJz (ORCPT ); Mon, 16 Jan 2023 06:09:55 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2004D6A6B for ; Mon, 16 Jan 2023 03:09:24 -0800 (PST) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NwTlL2DT2zJrx8; Mon, 16 Jan 2023 19:07:58 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 16 Jan 2023 19:09:20 +0800 Message-ID: <6f1c8530-621c-c018-780f-60beb9054a7b@huawei.com> Date: Mon, 16 Jan 2023 19:09:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH -next 1/7] mm: huge_memory: make __do_huge_pmd_anonymous_page() to take a folio Content-Language: en-US To: Matthew Wilcox CC: , , References: <20230112083006.163393-1-wangkefeng.wang@huawei.com> <20230112083006.163393-2-wangkefeng.wang@huawei.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) 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 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/1/13 22:25, Matthew Wilcox wrote: > On Thu, Jan 12, 2023 at 04:30:00PM +0800, Kefeng Wang wrote: >> Let's __do_huge_pmd_anonymous_page() take a folio and convert related >> functions to use folios. > > No, this is actively wrong! Andrew, please drop this patch. > > If we want to support folio sizes larger than PMD size (and I think we > do), we need to be able to specify precisely which page in the folio > is to be stored at this PTE. The *interface* must remain struct page. > We can convert from page to folio within the function, but we *MUST NOT* > go the other way. Got it, > >> static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, >> - struct page *page, gfp_t gfp) >> + struct folio *folio, gfp_t gfp) >> { >> struct vm_area_struct *vma = vmf->vma; >> + struct page *page = &folio->page; > > ... ie this is bad and wrong. > >> @@ -834,7 +835,7 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf) >> count_vm_event(THP_FAULT_FALLBACK); >> return VM_FAULT_FALLBACK; >> } >> - return __do_huge_pmd_anonymous_page(vmf, &folio->page, gfp); >> + return __do_huge_pmd_anonymous_page(vmf, folio, gfp); >> } >> >> static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, > > A reasonable person might ask "But Matthew, you allocated a folio here, > then you're converting back to a struct page to call > __do_huge_pmd_anonymous_page() so isn't this a sensible patch?" and this is why I change the parameter from page to folio(no need to go back and forth between page and folio), > > And I would say "still no". This is a question of interfaces, and > even though __do_huge_pmd_anonymous_page() is static and has precisely > one caller today that always allocates a folio of precisely PMD size, > I suspect it will need to be more visible in the future and the > conversion of the interface from page to folio misleads people. ok, will keep page for __do_huge_pmd_anonymous_page(). >