Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1550490pxb; Fri, 6 Nov 2020 12:39:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQP6M1pfbgTaKFg2CfEqsPKbisD2v+mLG3mieayIrDGXo3z7YImqmbPNzpjAz1P2B7rSDV X-Received: by 2002:a17:906:3fd3:: with SMTP id k19mr4098194ejj.434.1604695168261; Fri, 06 Nov 2020 12:39:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604695168; cv=none; d=google.com; s=arc-20160816; b=N41MQhOaougScgEqjyM4cJRrbVAEoNgiwizfsA7mEDAgY8itWvMldcJO0HQP57f/EI EBZDYjZzIncU/XrHMwpnxMmHJwawwwqmEdXAf86Y8fv//newCsBcJYSvle6sucpwAgBx /bi9PdmuOG52vlQNU5sa/JDpes1bJb0/pbiWbicWLFE/Yn1W+3zQPPIDRpyVimyeCNPq Zay6cUPKkRlKa6E8mdwp6C9LP5HDkylq+K3z8W2UjUvziwzFb5VfC1e/XGFEKoFDfCjT qHN4oyYKXxWNdbWxzFGmlj4gjJ2JS1dVsf2c8KynTM3KIHLO4QwcB1mLc/Dg8C5euPLL R4kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=3kQ//mMEobyQywMprE0fVaDOJaCYEqZr2rGa9riAH38=; b=W54pkDNyc0uCgy9t0ojg32FLE3j+W+ing0dixYRfKlZrUs8U8+Nho937MA2tevnkml fEnFSIoyjoEJUySiSw3qQPyXkw2V2unmf12d9hADcXywqg/mdDn9dCsbrD2gAZANLPaW c6YwqAN/ZfLt0dlOrvlQnwBAGM9NnQ+YY+P3xnGriHInwMkRToCNBYOyCe11Kp1dLxR+ cxWULcaveLbBlqSsNH1qhtQ+WX1iFsbqVIFpA4OqGyfiinD2qo5GbvimzWVTgfX0UtDx zx/rOj6JSalKEpQkKUea9EtMsCoMzAo4i6DW/alzULZD1JlNvMHkWcnuUzLZi1e+r7au bXxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=ZfdPSy+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 92si1898910edg.183.2020.11.06.12.39.03; Fri, 06 Nov 2020 12:39:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=ZfdPSy+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728446AbgKFUew (ORCPT + 99 others); Fri, 6 Nov 2020 15:34:52 -0500 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:9066 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727129AbgKFUew (ORCPT ); Fri, 6 Nov 2020 15:34:52 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Fri, 06 Nov 2020 12:34:50 -0800 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 6 Nov 2020 20:34:49 +0000 Subject: Re: [PATCH v3 1/6] mm/thp: add prep_transhuge_device_private_page() To: Matthew Wilcox CC: , , , , "Jerome Glisse" , John Hubbard , "Alistair Popple" , Christoph Hellwig , Jason Gunthorpe , Bharata B Rao , Zi Yan , "Kirill A . Shutemov" , Yang Shi , Ben Skeggs , Shuah Khan , Andrew Morton References: <20201106005147.20113-1-rcampbell@nvidia.com> <20201106005147.20113-2-rcampbell@nvidia.com> <20201106121407.GQ17076@casper.infradead.org> From: Ralph Campbell X-Nvconfidentiality: public Message-ID: Date: Fri, 6 Nov 2020 12:34:49 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20201106121407.GQ17076@casper.infradead.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1604694890; bh=3kQ//mMEobyQywMprE0fVaDOJaCYEqZr2rGa9riAH38=; h=Subject:To:CC:References:From:X-Nvconfidentiality:Message-ID:Date: User-Agent:MIME-Version:In-Reply-To:Content-Type:Content-Language: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy; b=ZfdPSy+wi5oJm1vMDFZi1SmNpeYM/8prR76BnNgoMkSMSy4w7h5WgBEzZsEPEcS7N DRqem5D7qEyAsyuyRSY1i0ypwydJcgYVspVqXuDd3UeWrYgNZ+wbrcfPkA1ygnQn0T CgmMWbi80T2WSfm1AmNpNcKF6QcMvRpiihkgA3C35EL15KcKT671+VzYGb8zgXxAOJ SLVF/22aNTf29FHM+5IKkAi7SOxnYjbRIIXFE+b9Kjh+qhWw4+VWDRnR6Wd7DV0QQw fSpOl7pA3HC2EoGrk4/m0ZED4KnZacd2J5rab7HOFIpKm/ZWATixv9WLIel2nUmv/A EnHQPaKIzWVMQ== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/6/20 4:14 AM, Matthew Wilcox wrote: > On Thu, Nov 05, 2020 at 04:51:42PM -0800, Ralph Campbell wrote: >> Add a helper function to allow device drivers to create device private >> transparent huge pages. This is intended to help support device private >> THP migrations. > > I think you'd be better off with these calling conventions: > > -void prep_transhuge_page(struct page *page) > +struct page *thp_prep(struct page *page) > { > + if (!page || compound_order(page) == 0) > + return page; > /* > - * we use page->mapping and page->indexlru in second tail page > + * we use page->mapping and page->index in second tail page > * as list_head: assuming THP order >= 2 > */ > + BUG_ON(compound_order(page) == 1); > > INIT_LIST_HEAD(page_deferred_list(page)); > set_compound_page_dtor(page, TRANSHUGE_PAGE_DTOR); > + > + return page; > } > > It simplifies the users. I'm not sure what the simplification is. If you mean the name change from prep_transhuge_page() to thp_prep(), that seems fine to me. The following could also be renamed to thp_prep_device_private_page() or similar. >> +void prep_transhuge_device_private_page(struct page *page) >> +{ >> + prep_compound_page(page, HPAGE_PMD_ORDER); >> + prep_transhuge_page(page); >> + /* Only the head page has a reference to the pgmap. */ >> + percpu_ref_put_many(page->pgmap->ref, HPAGE_PMD_NR - 1); >> +} >> +EXPORT_SYMBOL_GPL(prep_transhuge_device_private_page); > > Something else that may interest you from my patch series is support > for page sizes other than PMD_SIZE. I don't know what page sizes > hardware supports. There's no support for page sizes other than PMD > for anonymous memory, so this might not be too useful for you yet. I did see those changes. It might help some device drivers to do DMA in larger than PAGE_SIZE blocks but less than PMD_SIZE. It might help reduce page table sizes since 2MB, 64K, and 4K are commonly supported GPU page sizes. The MIGRATE_PFN_COMPOUND flag is intended to indicate that the page size is determined by page_size() so I was thinking ahead to other than PMD sized pages. However, when migrating a pte_none() or pmd_none() page, there is no source page to determine the size. Maybe I need to encode the page order in the migrate PFN entry like hmm_range_fault(). Anyway, I agree that thinking about page sizes other than PMD is good.