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=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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 43D60C433C1 for ; Tue, 23 Mar 2021 17:07:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BB629619BF for ; Tue, 23 Mar 2021 17:07:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB629619BF 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 3A2B16B0249; Tue, 23 Mar 2021 13:07:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 379FE6B024B; Tue, 23 Mar 2021 13:07:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F56F6B024D; Tue, 23 Mar 2021 13:07:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 03B476B0249 for ; Tue, 23 Mar 2021 13:07:20 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C005E8E70 for ; Tue, 23 Mar 2021 17:07:20 +0000 (UTC) X-FDA: 77951769840.34.9B33988 Received: from ste-pvt-msa2.bahnhof.se (ste-pvt-msa2.bahnhof.se [213.80.101.71]) by imf24.hostedemail.com (Postfix) with ESMTP id DDF2CA000855 for ; Tue, 23 Mar 2021 17:07:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id EF5CD3FF00; Tue, 23 Mar 2021 18:06:57 +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=OIPzPWVW; 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 4vXE_RuP9_af; Tue, 23 Mar 2021 18:06:57 +0100 (CET) Received: by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 58FE63FEFF; Tue, 23 Mar 2021 18:06:56 +0100 (CET) Received: from [192.168.0.209] (unknown [192.198.151.43]) by mail1.shipmail.org (Postfix) with ESMTPSA id 7C82636062E; Tue, 23 Mar 2021 18:06:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1616519216; bh=9C1/LIiOMgsGwjfQyFQT7VzzQnBpGQRxEf4hDMfEMQI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=OIPzPWVW/hOP84Aexusd08oV1ihkh2Q54GfQNCXWiaAmRUTIhMp6sprBTnzrN7WOq U8mSrmSG9//Y9cwdRAkmFH0vAilzHWB9jL1OrKJ+oM59wTCCCbWCgbsnko/zZACsSM dgSvTW/IU3jgcflSVkFOj8Iq++820R6HVr1m/+ws= Subject: Re: [RFC PATCH 1/2] mm,drm/ttm: Block fast GUP to TTM huge pages To: Jason Gunthorpe Cc: dri-devel@lists.freedesktop.org, Christian Koenig , David Airlie , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210321184529.59006-1-thomas_os@shipmail.org> <20210321184529.59006-2-thomas_os@shipmail.org> <314fc020-d243-dbf0-acb3-ecfcc9c2443c@shipmail.org> <20210323163715.GJ2356281@nvidia.com> From: =?UTF-8?Q?Thomas_Hellstr=c3=b6m_=28Intel=29?= Message-ID: <5824b731-ca6a-92fd-e314-d986b6a7b101@shipmail.org> Date: Tue, 23 Mar 2021 18:06:53 +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: <20210323163715.GJ2356281@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: DDF2CA000855 X-Stat-Signature: 4un5geq6yyzzpjfu9q86hqfukckgzdss Received-SPF: none (shipmail.org>: No applicable sender policy available) receiver=imf24; 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: 1616519230-419095 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/23/21 5:37 PM, Jason Gunthorpe wrote: > On Tue, Mar 23, 2021 at 05:34:51PM +0100, Thomas Hellstr=C3=B6m (Intel)= wrote: > >>>> @@ -210,6 +211,20 @@ static vm_fault_t ttm_bo_vm_insert_huge(struct = vm_fault *vmf, >>>> if ((pfn & (fault_page_size - 1)) !=3D 0) >>>> goto out_fallback; >>>> + /* >>>> + * Huge entries must be special, that is marking them as devmap >>>> + * with no backing device map range. If there is a backing >>>> + * range, Don't insert a huge entry. >>>> + * If this check turns out to be too much of a performance hit, >>>> + * we can instead have drivers indicate whether they may have >>>> + * backing device map ranges and if not, skip this lookup. >>>> + */ >>> I think we can do this statically: >>> - if it's system memory we know there's no devmap for it, and we do t= he >>> trick to block gup_fast >> Yes, that should work. >>> - if it's iomem, we know gup_fast wont work anyway if don't set PFN_D= EV, >>> so might as well not do that >> I think gup_fast will unfortunately mistake a huge iomem page for an >> ordinary page and try to access a non-existant struct page for it, unl= ess we >> do the devmap trick. >> >> And the lookup would then be for the rare case where a driver would ha= ve >> already registered a dev_pagemap for an iomem area which may also be m= apped >> through TTM (like the patch from Felix a couple of weeks ago). If a dr= iver >> can promise not to do that, then we can safely remove the lookup. > Isn't the devmap PTE flag arch optional? Does this fall back to not > using huge pages on arches that don't support it? Good point. No, currently it's only conditioned on transhuge page support= . Need to condition it on also devmap support. > > Also, I feel like this code to install "pte_special" huge pages does > not belong in the drm subsystem.. I could add helpers in huge_memory.c: vmf_insert_pfn_pmd_prot_special() and vmf_insert_pfn_pud_prot_special() /Thomas > > Jason