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 X-Spam-Level: X-Spam-Status: No, score=-8.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2CF7C432C3 for ; Wed, 27 Nov 2019 12:25:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 948262068E for ; Wed, 27 Nov 2019 12:25:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="qYP4CXBt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 948262068E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 34F376B039A; Wed, 27 Nov 2019 07:25:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 289836B039B; Wed, 27 Nov 2019 07:25:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1778B6B039C; Wed, 27 Nov 2019 07:25:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0029.hostedemail.com [216.40.44.29]) by kanga.kvack.org (Postfix) with ESMTP id F35136B039A for ; Wed, 27 Nov 2019 07:25:01 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id B16E5181AEF15 for ; Wed, 27 Nov 2019 12:25:01 +0000 (UTC) X-FDA: 76201976802.18.front76_48b01abe96516 X-HE-Tag: front76_48b01abe96516 X-Filterd-Recvd-Size: 7029 Received: from pio-pvt-msa2.bahnhof.se (pio-pvt-msa2.bahnhof.se [79.136.2.41]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 Nov 2019 12:24:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 73B8E3F683; Wed, 27 Nov 2019 13:24:57 +0100 (CET) Authentication-Results: pio-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=qYP4CXBt; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EWrtG9W4vugB; Wed, 27 Nov 2019 13:24:55 +0100 (CET) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 691493F556; Wed, 27 Nov 2019 13:24:52 +0100 (CET) Received: from localhost.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 9FF2D360140; Wed, 27 Nov 2019 13:24:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1574857492; bh=G8kszZs1jtzCSQxM7XxfwjE4wxpMdv4dFcCTVfNkcPE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=qYP4CXBt+c2IMRKHRJkjJRGWfHNF/5SJN0EB9A4yORFOsXTA9iICXqdzjiZP/4lh/ bZLDtjvtQuKbvC8qXX/XUmor9wnCMjOTrQgB6desRFuKm8tZVwTZRjGAxmLUZbxZTI 66A3krVi3PNGQLEESuTGUy+BTQ6e45Ky/A+ZrFDU= Subject: Re: [RFC PATCH 4/7] drm/ttm: Support huge pagefaults To: =?UTF-8?Q?Christian_K=c3=b6nig?= , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-graphics-maintainer@vmware.com Cc: Thomas Hellstrom , Andrew Morton , Michal Hocko , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Ralph Campbell , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= References: <20191127083120.34611-1-thomas_os@shipmail.org> <20191127083120.34611-5-thomas_os@shipmail.org> From: =?UTF-8?Q?Thomas_Hellstr=c3=b6m_=28VMware=29?= Organization: VMware Inc. Message-ID: <83b83746-7d54-e56b-3753-0b29b01074a2@shipmail.org> Date: Wed, 27 Nov 2019 13:24:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 11/27/19 10:12 AM, Christian K=C3=B6nig wrote: > Am 27.11.19 um 09:31 schrieb Thomas Hellstr=C3=B6m (VMware): >> From: Thomas Hellstrom >> >> Support huge (PMD-size and PUD-size) page-table entries by providing a >> huge_fault() callback. >> We still support private mappings and write-notify by splitting the hu= ge >> page-table entries on write-access. >> >> Note that for huge page-faults to occur, either the kernel needs to be >> compiled with trans-huge-pages always enabled, or the kernel needs to = be >> compiled with trans-huge-pages enabled using madvise, and the user-spa= ce >> app needs to call madvise() to enable trans-huge pages on a per-mappin= g >> basis. >> >> Furthermore huge page-faults will not occur unless buffer objects and >> user-space addresses are aligned on huge page size boundaries. >> >> Cc: Andrew Morton >> Cc: Michal Hocko >> Cc: "Matthew Wilcox (Oracle)" >> Cc: "Kirill A. Shutemov" >> Cc: Ralph Campbell >> Cc: "J=C3=A9r=C3=B4me Glisse" >> Cc: "Christian K=C3=B6nig" >> Signed-off-by: Thomas Hellstrom >> --- >> =C2=A0 drivers/gpu/drm/ttm/ttm_bo_vm.c | 139 +++++++++++++++++++++++++= ++++++- >> =C2=A0 include/drm/ttm/ttm_bo_api.h=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 3 = +- >> =C2=A0 2 files changed, 138 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c=20 >> b/drivers/gpu/drm/ttm/ttm_bo_vm.c >> index 2098f8d4dfc5..8d6089880e39 100644 >> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c >> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c >> @@ -150,6 +150,84 @@ vm_fault_t ttm_bo_vm_reserve(struct=20 >> ttm_buffer_object *bo, >> =C2=A0 } >> =C2=A0 EXPORT_SYMBOL(ttm_bo_vm_reserve); >> =C2=A0 +#ifdef CONFIG_TRANSPARENT_HUGEPAGE >> +/** >> + * ttm_bo_vm_insert_huge - Insert a pfn for PUD or PMD faults >> + * @vmf: Fault data >> + * @bo: The buffer object >> + * @page_offset: Page offset from bo start >> + * @fault_page_size: The size of the fault in pages. >> + * @pgprot: The page protections. >> + * Does additional checking whether it's possible to insert a PUD or=20 >> PMD >> + * pfn and performs the insertion. >> + * >> + * Return: VM_FAULT_NOPAGE on successful insertion,=20 >> VM_FAULT_FALLBACK if >> + * a huge fault was not possible, and a VM_FAULT_ERROR code otherwise= . >> + */ >> +static vm_fault_t ttm_bo_vm_insert_huge(struct vm_fault *vmf, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct ttm_buffer_object *b= o, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pgoff_t page_offset, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pgoff_t fault_page_size, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pgprot_t pgprot) >> +{ >> +=C2=A0=C2=A0=C2=A0 pgoff_t i; >> +=C2=A0=C2=A0=C2=A0 vm_fault_t ret; >> +=C2=A0=C2=A0=C2=A0 unsigned long pfn; >> +=C2=A0=C2=A0=C2=A0 pfn_t pfnt; >> +=C2=A0=C2=A0=C2=A0 struct ttm_tt *ttm =3D bo->ttm; >> +=C2=A0=C2=A0=C2=A0 bool write =3D vmf->flags & FAULT_FLAG_WRITE; >> + >> + >> +=C2=A0=C2=A0=C2=A0 /* Fault should not cross bo boundary */ >> +=C2=A0=C2=A0=C2=A0 page_offset &=3D ~(fault_page_size - 1); >> +=C2=A0=C2=A0=C2=A0 if (page_offset + fault_page_size > bo->num_pages) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_fallback; >> + >> +=C2=A0=C2=A0=C2=A0 if (bo->mem.bus.is_iomem) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pfn =3D ttm_bo_io_mem_pfn(= bo, page_offset); >> +=C2=A0=C2=A0=C2=A0 else >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pfn =3D page_to_pfn(ttm->p= ages[page_offset]); >> + >> +=C2=A0=C2=A0=C2=A0 /* pfn must be fault_page_size aligned. */ >> +=C2=A0=C2=A0=C2=A0 if ((pfn & (fault_page_size - 1)) !=3D 0) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_fallback; >> + >> +=C2=A0=C2=A0=C2=A0 /* IO memory is OK now, TT memory must be contigou= s. */ > > That won't work correctly, IO mem might not be contiguous either. > > We either need to call ttm_bo_io_mem_pfn() multiple times and check=20 > that the addresses are linear or return the length additional to the pf= n. Yes, you're right. Will fix that up. Thanks, Thomas > > Regards, > Christian.=20