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=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 A810BC433DB for ; Thu, 25 Mar 2021 13:31:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2485D61A17 for ; Thu, 25 Mar 2021 13:31:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2485D61A17 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 AB5656B006C; Thu, 25 Mar 2021 09:31:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A22A6B0070; Thu, 25 Mar 2021 09:31:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F5026B0071; Thu, 25 Mar 2021 09:31:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 642396B006C for ; Thu, 25 Mar 2021 09:31:33 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 136791181E for ; Thu, 25 Mar 2021 13:31:33 +0000 (UTC) X-FDA: 77958483666.39.BA50896 Received: from ste-pvt-msa2.bahnhof.se (ste-pvt-msa2.bahnhof.se [213.80.101.71]) by imf13.hostedemail.com (Postfix) with ESMTP id EFA74E037DAD for ; Thu, 25 Mar 2021 13:31:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 9C0E83FEFF; Thu, 25 Mar 2021 14:31:28 +0100 (CET) Authentication-Results: ste-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=Mdg8AKwx; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se Authentication-Results: ste-ftg-msa2.bahnhof.se (amavisd-new); dkim=pass (1024-bit key) header.d=shipmail.org Received: from ste-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (ste-ftg-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9qCSgkHCCOe7; Thu, 25 Mar 2021 14:31:26 +0100 (CET) Received: by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 2D72E3FFA0; Thu, 25 Mar 2021 14:31:23 +0100 (CET) Received: from [10.249.254.165] (unknown [192.198.151.44]) by mail1.shipmail.org (Postfix) with ESMTPSA id 1F61C3600A8; Thu, 25 Mar 2021 14:31:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1616679083; bh=XL8BQAJQEgz/HLXrzxugZdd/kAGy1RzLvj1mQCzDRCE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Mdg8AKwxGQ6V9ZBKUXVtboLF2eXHKU4JPoHnip24gLaK3C4SzHyvsdQrTgwIx3H12 //oJQ3EAvuZ6AsyBKb8g7S5z/CB5gVqkdUJoVB9PX/F4eR+WeBp/o12nWyHtUX1mLu ZFIriU2fBftCSzwXnUdi8riG3/KApf6l9HFkBiBk= Subject: Re: [RFC PATCH 1/2] mm,drm/ttm: Block fast GUP to TTM huge pages To: =?UTF-8?Q?Christian_K=c3=b6nig?= , Jason Gunthorpe Cc: David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Andrew Morton References: <0b984f96-00fb-5410-bb16-02e12b2cc024@shipmail.org> <20210324163812.GJ2356281@nvidia.com> <08f19e80-d6cb-8858-0c5d-67d2e2723f72@amd.com> <730eb2ff-ba98-2393-6d42-61735e3c6b83@shipmail.org> <20210324231419.GR2356281@nvidia.com> <607ecbeb-e8a5-66e9-6fe2-9a8d22f12bc2@shipmail.org> <15da5784-96ca-25e5-1485-3ce387ee6695@shipmail.org> <20210325113023.GT2356281@nvidia.com> <20210325120103.GV2356281@nvidia.com> From: =?UTF-8?Q?Thomas_Hellstr=c3=b6m_=28Intel=29?= Message-ID: <9e924f37-c638-afc7-0354-7258836772b1@shipmail.org> Date: Thu, 25 Mar 2021 14:31:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: EFA74E037DAD X-Stat-Signature: rgak6swh3xiocmyfo3s3gyme4jh7dixk Received-SPF: none (shipmail.org>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from=""; helo=ste-pvt-msa2.bahnhof.se; client-ip=213.80.101.71 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616679089-935213 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: Hi, On 3/25/21 2:02 PM, Christian K=C3=B6nig wrote: > > > Am 25.03.21 um 13:36 schrieb Thomas Hellstr=C3=B6m (Intel): >> >> On 3/25/21 1:09 PM, Christian K=C3=B6nig wrote: >>> Am 25.03.21 um 13:01 schrieb Jason Gunthorpe: >>>> On Thu, Mar 25, 2021 at 12:53:15PM +0100, Thomas Hellstr=C3=B6m (Int= el)=20 >>>> wrote: >>>> >>>>> Nope. The point here was that in this case, to make sure mmap uses=20 >>>>> the >>>>> correct VA to give us a reasonable chance of alignement, the=20 >>>>> driver might >>>>> need to be aware of and do trickery with the huge page-table-entry=20 >>>>> sizes >>>>> anyway, although I think in most cases a standard helper for this=20 >>>>> can be >>>>> supplied. >>>> Of course the driver needs some way to influence the VA mmap uses, >>>> gernally it should align to the natural page size of the device >>> >>> Well a mmap() needs to be aligned to the page size of the CPU, but=20 >>> not necessarily to the one of the device. >>> >>> So I'm pretty sure the device driver should not be involved in any=20 >>> way the choosing of the VA for the CPU mapping. >>> >>> Christian. >>> >> We've had this discussion before and at that time I managed to=20 >> convince you by pointing to the shmem helper for this,=20 >> shmem_get_umapped_area(). > > No, you didn't convinced me. I was just surprised that this is=20 > something under driver control. > >> >> Basically there are two ways to do this. Either use a standard helper=20 >> similar to shmem's, and then the driver needs to align physical=20 >> (device) huge page boundaries to address space offset huge page=20 >> boundaries. If you don't do that you can just as well use a custom=20 >> function that adjusts for you not doing that=20 >> (drm_get_unmapped_area()). Both require driver knowledge of the size=20 >> of huge pages. > > And once more, at least for GPU drivers that looks like the totally=20 > wrong approach to me. > > Aligning the VMA so that huge page allocations become possible is the=20 > job of the MM subsystem and not that of the drivers. > Previous discussion here https://www.spinics.net/lists/linux-mm/msg205291.html >> >> Without a function to adjust, mmap will use it's default (16 byte?)=20 >> alignment and chance of alignment becomes very small. > > Well it's 4KiB at least. Yes :/ ... > > Regards, > Christian. > Thanks, Thomas