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 BAEE9C433C1 for ; Thu, 25 Mar 2021 12:36:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2330461A1A for ; Thu, 25 Mar 2021 12:36:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2330461A1A 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 AA2C66B0036; Thu, 25 Mar 2021 08:36:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7A546B006C; Thu, 25 Mar 2021 08:36:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 968696B0070; Thu, 25 Mar 2021 08:36:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id 7B22A6B0036 for ; Thu, 25 Mar 2021 08:36:45 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 384148861B54 for ; Thu, 25 Mar 2021 12:36:45 +0000 (UTC) X-FDA: 77958345570.27.C643048 Received: from ste-pvt-msa1.bahnhof.se (ste-pvt-msa1.bahnhof.se [213.80.101.70]) by imf26.hostedemail.com (Postfix) with ESMTP id 6C04640002C4 for ; Thu, 25 Mar 2021 12:36:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTP id F1DC33F6BE; Thu, 25 Mar 2021 13:36:41 +0100 (CET) Authentication-Results: ste-pvt-msa1.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=gD78SScH; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se Received: from ste-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (ste-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3veBufnIduPG; Thu, 25 Mar 2021 13:36:40 +0100 (CET) Received: by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 7512A3F2E2; Thu, 25 Mar 2021 13:36:39 +0100 (CET) Received: from [10.249.254.165] (unknown [192.198.151.44]) by mail1.shipmail.org (Postfix) with ESMTPSA id 1EC303600A8; Thu, 25 Mar 2021 13:36:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1616675798; bh=nuPktcMhKejdFp1Z/65E+GhLl3FbivLnSEFyMbRaI34=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=gD78SScHSDRZD6sZd6WmUqUYAPn6X5Tt4UXq1JrQzfL49ycTmMGvRTXvfvvPj7mUU F+3wIzfxWZJzfC0zV1G88pkACeP50q6Zj1axpvO/rYFy0U6cOMzSd9hhqsmO3bZpjq B8A4geR/ERcWYbNnKqxN1dPfXAmjDKyct20ex0ao= 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: Date: Thu, 25 Mar 2021 13:36:35 +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-Stat-Signature: kgdjfuoagwccmr7ucz8ayw39rw4b5ww6 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 6C04640002C4 Received-SPF: none (shipmail.org>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=ste-pvt-msa1.bahnhof.se; client-ip=213.80.101.70 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616675802-912390 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 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 (Intel= )=20 >> wrote: >> >>> Nope. The point here was that in this case, to make sure mmap uses th= e >>> correct VA to give us a reasonable chance of alignement, the driver=20 >>> 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 not=20 > necessarily to the one of the device. > > So I'm pretty sure the device driver should not be involved in any way=20 > the choosing of the VA for the CPU mapping. > > Christian. > We've had this discussion before and at that time I managed to convince=20 you by pointing to the shmem helper for this, shmem_get_umapped_area(). 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 (device)=20 huge page boundaries to address space offset huge page boundaries. If=20 you don't do that you can just as well use a custom function that=20 adjusts for you not doing that (drm_get_unmapped_area()). Both require=20 driver knowledge of the size of huge pages. Without a function to adjust, mmap will use it's default (16 byte?)=20 alignment and chance of alignment becomes very small. /Thomas >> >> Jason