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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 9B55EC388F2 for ; Fri, 6 Nov 2020 10:28:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0067B20720 for ; Fri, 6 Nov 2020 10:28:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="bzj83Mf9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbgKFK2M (ORCPT ); Fri, 6 Nov 2020 05:28:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbgKFK2L (ORCPT ); Fri, 6 Nov 2020 05:28:11 -0500 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A985C0613D4 for ; Fri, 6 Nov 2020 02:28:11 -0800 (PST) Received: by mail-oi1-x243.google.com with SMTP id t143so840799oif.10 for ; Fri, 06 Nov 2020 02:28:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GZSvjJXJ5NeS3xeVpOYrkTBUqUJmeylcGC99/vSxMgE=; b=bzj83Mf9zM2hSbE8EWsBjDPrQihAyugYzXs6/XtzMk42mlteKogf38yikrIVtP0YIp 1PpqGJ83G8CMqUOSy0c+3J2x07vzzrc1y+f0AiA/gsD366OU8Q4TqDzYqRuPe+cWSz/V V9A5M3N3kUQY2mHkFVy5IQrEsMOk51+osCoGc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GZSvjJXJ5NeS3xeVpOYrkTBUqUJmeylcGC99/vSxMgE=; b=R2ooh+As8lZtlWVvecVPAloxRv2NO5oc2FUD8oJuEmko2nDgy9H4yCH5PAIR8pQFJZ 3g6Sjlxkv8JdZVQiWG3trG3gln/wUhTNdMTx7aWBeQVT4PHtAVtvWj81mSmGZw5Pu/uq Yo0ymvI0V1iPbSHNwU4Vc9LzsD0Z29hfBEjFgyvKpqnlLVIvAfzcDkFZwbF8qSTdPInv EHfLefs33nAX2nkzKzEvP233nomh3vjLVFS8hqpL/Cp4yIx1fXpqhUFmZEsY9C3F+73E v5T/QgTgJL4W7M/96rquPFHvV1iluzaemu68x+mvaqCf/GO8sDUU5rIU0SRcqL4Yy+U7 Qssg== X-Gm-Message-State: AOAM532A+opeCbFeao01rGUARuEmUU1wF831CkABy7EMBXetqMRs38eX gWJOxpH8EWnBDZEMTtpm1yktIgOTH5mpz46+znN52Q== X-Google-Smtp-Source: ABdhPJxaH0jX6R8wLLVMSL6X5ZRgt3aYM2nGlRnlOOpo51kJ5ZLuq1XuS09rdAP7rLsL8i/ky1hkd4FCo7S1HBbLmlY= X-Received: by 2002:aca:b141:: with SMTP id a62mr626467oif.101.1604658490602; Fri, 06 Nov 2020 02:28:10 -0800 (PST) MIME-Version: 1.0 References: <20201104140023.GQ36674@ziepe.ca> <20201104162125.GA13007@infradead.org> <20201104163758.GA17425@infradead.org> <20201104164119.GA18218@infradead.org> <20201104181708.GU36674@ziepe.ca> <20201105092524.GQ401619@phenom.ffwll.local> <20201105124950.GZ36674@ziepe.ca> <7ae3486d-095e-cf4e-6b0f-339d99709996@nvidia.com> In-Reply-To: From: Daniel Vetter Date: Fri, 6 Nov 2020 11:27:59 +0100 Message-ID: Subject: Re: [PATCH v5 05/15] mm/frame-vector: Use FOLL_LONGTERM To: John Hubbard , Thomas Hellstrom Cc: Jason Gunthorpe , Christoph Hellwig , "J??r??me Glisse" , linux-samsung-soc , Jan Kara , Pawel Osciak , KVM list , Mauro Carvalho Chehab , LKML , DRI Development , Tomasz Figa , Linux MM , Kyungmin Park , Daniel Vetter , Andrew Morton , Marek Szyprowski , Dan Williams , Linux ARM , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 6, 2020 at 11:01 AM Daniel Vetter wrote: > > On Fri, Nov 6, 2020 at 5:08 AM John Hubbard wrote: > > > > On 11/5/20 4:49 AM, Jason Gunthorpe wrote: > > > On Thu, Nov 05, 2020 at 10:25:24AM +0100, Daniel Vetter wrote: > > >>> /* > > >>> * If we can't determine whether or not a pte is special, then fail immediately > > >>> * for ptes. Note, we can still pin HugeTLB and THP as these are guaranteed not > > >>> * to be special. > > >>> * > > >>> * For a futex to be placed on a THP tail page, get_futex_key requires a > > >>> * get_user_pages_fast_only implementation that can pin pages. Thus it's still > > >>> * useful to have gup_huge_pmd even if we can't operate on ptes. > > >>> */ > > >> > > >> We support hugepage faults in gpu drivers since recently, and I'm not > > >> seeing a pud_mkhugespecial anywhere. So not sure this works, but probably > > >> just me missing something again. > > > > > > It means ioremap can't create an IO page PUD, it has to be broken up. > > > > > > Does ioremap even create anything larger than PTEs? > > gpu drivers also tend to use vmf_insert_pfn* directly, so we can do > on-demand paging and move buffers around. From what I glanced for > lowest level we to the pte_mkspecial correctly (I think I convinced > myself that vm_insert_pfn does that), but for pud/pmd levels it seems > just yolo. So I dug around a bit more and ttm sets PFN_DEV | PFN_MAP to get past the various pft_t_devmap checks (see e.g. vmf_insert_pfn_pmd_prot()). x86-64 has ARCH_HAS_PTE_DEVMAP, and gup.c seems to handle these specially, but frankly I got totally lost in what this does. The comment above the pfn_t_devmap check makes me wonder whether doing this is correct or not. Also adding Thomas Hellstrom, who implemented the huge map support in ttm. -Daniel > remap_pfn_range seems to indeed split down to pte level always. > > > From my reading, yes. See ioremap_try_huge_pmd(). > > The ioremap here shouldn't matter, since this is for kernel-internal > mappings. So that's all fine I think. > -Daniel > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch 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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 13B1DC2D0A3 for ; Fri, 6 Nov 2020 10:28:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DF0522222B for ; Fri, 6 Nov 2020 10:28:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="bzj83Mf9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF0522222B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E0C356B005C; Fri, 6 Nov 2020 05:28:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DED286B005D; Fri, 6 Nov 2020 05:28:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C82396B0068; Fri, 6 Nov 2020 05:28:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 9C3256B005C for ; Fri, 6 Nov 2020 05:28:12 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3753B181AEF0B for ; Fri, 6 Nov 2020 10:28:12 +0000 (UTC) X-FDA: 77453618424.03.snake17_1808f47272d1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 0C4DE28A4E9 for ; Fri, 6 Nov 2020 10:28:12 +0000 (UTC) X-HE-Tag: snake17_1808f47272d1 X-Filterd-Recvd-Size: 6083 Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Nov 2020 10:28:11 +0000 (UTC) Received: by mail-oi1-f196.google.com with SMTP id t143so840805oif.10 for ; Fri, 06 Nov 2020 02:28:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GZSvjJXJ5NeS3xeVpOYrkTBUqUJmeylcGC99/vSxMgE=; b=bzj83Mf9zM2hSbE8EWsBjDPrQihAyugYzXs6/XtzMk42mlteKogf38yikrIVtP0YIp 1PpqGJ83G8CMqUOSy0c+3J2x07vzzrc1y+f0AiA/gsD366OU8Q4TqDzYqRuPe+cWSz/V V9A5M3N3kUQY2mHkFVy5IQrEsMOk51+osCoGc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GZSvjJXJ5NeS3xeVpOYrkTBUqUJmeylcGC99/vSxMgE=; b=hTo6s4ykZd4MnB7uPXdt1GJqO8SBD/ThNJLpDkOSzk/kMSn/r9RRQiVxYubHqpiX3B jzeovzrWcolXDFTltQZNrN9l5JaHGlKPA7qbHbRlCefYMOVpJtOdBuq4xN2upWSdcfhL MMIiJ2BKYJp5CLEDKcSyxCIuunrKZSO1A7Fv6uwxNWXJwymbYlLdmyAXBTUCzccYJXlk csAeVEuu5iHmGmwl7F1jdyVbGYwQMHvpIndKABHoDf1yzW8H6bsaQ1HWCtIIystg1zcb qCdM0T3gsYdalVak1j/DH1xsygprtXK39fbv4drRjSQi5+nydCTGXqrPnNMTQExJtTTX XfeQ== X-Gm-Message-State: AOAM533JrCkIax6sDjvcu+Gf0Ciz844DBfg0zK1zfxx4yWWHHURBCPTn drtTtTOgvbKoxvty8bPMHhUOHvpgngotkEysQ1Yzug== X-Google-Smtp-Source: ABdhPJxaH0jX6R8wLLVMSL6X5ZRgt3aYM2nGlRnlOOpo51kJ5ZLuq1XuS09rdAP7rLsL8i/ky1hkd4FCo7S1HBbLmlY= X-Received: by 2002:aca:b141:: with SMTP id a62mr626467oif.101.1604658490602; Fri, 06 Nov 2020 02:28:10 -0800 (PST) MIME-Version: 1.0 References: <20201104140023.GQ36674@ziepe.ca> <20201104162125.GA13007@infradead.org> <20201104163758.GA17425@infradead.org> <20201104164119.GA18218@infradead.org> <20201104181708.GU36674@ziepe.ca> <20201105092524.GQ401619@phenom.ffwll.local> <20201105124950.GZ36674@ziepe.ca> <7ae3486d-095e-cf4e-6b0f-339d99709996@nvidia.com> In-Reply-To: From: Daniel Vetter Date: Fri, 6 Nov 2020 11:27:59 +0100 Message-ID: Subject: Re: [PATCH v5 05/15] mm/frame-vector: Use FOLL_LONGTERM To: John Hubbard , Thomas Hellstrom Cc: Jason Gunthorpe , Christoph Hellwig , "J??r??me Glisse" , linux-samsung-soc , Jan Kara , Pawel Osciak , KVM list , Mauro Carvalho Chehab , LKML , DRI Development , Tomasz Figa , Linux MM , Kyungmin Park , Daniel Vetter , Andrew Morton , Marek Szyprowski , Dan Williams , Linux ARM , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="UTF-8" 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 Fri, Nov 6, 2020 at 11:01 AM Daniel Vetter wrote: > > On Fri, Nov 6, 2020 at 5:08 AM John Hubbard wrote: > > > > On 11/5/20 4:49 AM, Jason Gunthorpe wrote: > > > On Thu, Nov 05, 2020 at 10:25:24AM +0100, Daniel Vetter wrote: > > >>> /* > > >>> * If we can't determine whether or not a pte is special, then fail immediately > > >>> * for ptes. Note, we can still pin HugeTLB and THP as these are guaranteed not > > >>> * to be special. > > >>> * > > >>> * For a futex to be placed on a THP tail page, get_futex_key requires a > > >>> * get_user_pages_fast_only implementation that can pin pages. Thus it's still > > >>> * useful to have gup_huge_pmd even if we can't operate on ptes. > > >>> */ > > >> > > >> We support hugepage faults in gpu drivers since recently, and I'm not > > >> seeing a pud_mkhugespecial anywhere. So not sure this works, but probably > > >> just me missing something again. > > > > > > It means ioremap can't create an IO page PUD, it has to be broken up. > > > > > > Does ioremap even create anything larger than PTEs? > > gpu drivers also tend to use vmf_insert_pfn* directly, so we can do > on-demand paging and move buffers around. From what I glanced for > lowest level we to the pte_mkspecial correctly (I think I convinced > myself that vm_insert_pfn does that), but for pud/pmd levels it seems > just yolo. So I dug around a bit more and ttm sets PFN_DEV | PFN_MAP to get past the various pft_t_devmap checks (see e.g. vmf_insert_pfn_pmd_prot()). x86-64 has ARCH_HAS_PTE_DEVMAP, and gup.c seems to handle these specially, but frankly I got totally lost in what this does. The comment above the pfn_t_devmap check makes me wonder whether doing this is correct or not. Also adding Thomas Hellstrom, who implemented the huge map support in ttm. -Daniel > remap_pfn_range seems to indeed split down to pte level always. > > > From my reading, yes. See ioremap_try_huge_pmd(). > > The ioremap here shouldn't matter, since this is for kernel-internal > mappings. So that's all fine I think. > -Daniel > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch 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=-3.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 3F0E4C2D0A3 for ; Fri, 6 Nov 2020 11:05:28 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80ADC221FA for ; Fri, 6 Nov 2020 11:05:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="m7fdCJzy"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="bzj83Mf9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80ADC221FA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+jx51PYznW11YG28+iEsrhVZg3ElqZCKewzu8w7Fwlg=; b=m7fdCJzyxjQsSE1a+m0LOcC2L V6RfAWPJlczDaM9W60t3WpVjwELY4JK0DM7rVEZua+S71JyJihG3hpox49RwkC/fZHWLK4Nb/wRvn JY0m728vIzcqui9cmBu8pXrQYDAabAwJ/7c+ENE4sFV+igxJa04AD5s6fc2EIMmxkomfqvHp8JFMa fwhGLN84Sz1biW9hYkELnffJj+lCr6L2+YpY69qDbp/TWGMYiyPpU1QuXCwddHLjVZtO4fqmXgdPL wf3vsvg2yhQ1p089BFP3s3YeKNAYWry4OK6v1Uptcljwdxfj4AcajWTw8eBnUR/tOj5i6oUZGPRTY J1XKcS02A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kayyu-0001xf-TK; Fri, 06 Nov 2020 10:28:32 +0000 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kayyb-0001rg-Io for linux-arm-kernel@lists.infradead.org; Fri, 06 Nov 2020 10:28:15 +0000 Received: by mail-oi1-x243.google.com with SMTP id u127so855646oib.6 for ; Fri, 06 Nov 2020 02:28:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GZSvjJXJ5NeS3xeVpOYrkTBUqUJmeylcGC99/vSxMgE=; b=bzj83Mf9zM2hSbE8EWsBjDPrQihAyugYzXs6/XtzMk42mlteKogf38yikrIVtP0YIp 1PpqGJ83G8CMqUOSy0c+3J2x07vzzrc1y+f0AiA/gsD366OU8Q4TqDzYqRuPe+cWSz/V V9A5M3N3kUQY2mHkFVy5IQrEsMOk51+osCoGc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GZSvjJXJ5NeS3xeVpOYrkTBUqUJmeylcGC99/vSxMgE=; b=H6qzY7W6dsVAOQiMCs5OrgJR8pEscoVwtaOC4C+DPbjKvHsOe21fBlHSBSyf0vMNkJ QxYZvdoJH7jQs8T7Tj6BRZuhyMurM0/8ax7wheoP/zSI45Bck/pNqu2NvuAcodL7Ta0S rks6w964YrI65c/L86W1WQpUmSsfeSuzfWQq7xnowC8Av69RQ8ld6vwvvtS8QCrfBUjc ULkBtxjbblKVBRp1Mvice9fvJ8tQI4wdYa8DB8iqqvCNrWs9SjSSj/+ri7bSZqkvvKMS KOQvLPvnuu59uTPqINlOPzIE5kdyhV9ZCBZqsS4eLPvahKY3KcyBkJxTZNJ6A8YbWra9 2zIg== X-Gm-Message-State: AOAM532wRdvMniSBU74+nBVV55pRMz9vHogkaif+upNIwxj16AF5uejo wKyi25LhNd+jR/wU1K4jHKfTNItv90bT95dwSyblOw== X-Google-Smtp-Source: ABdhPJxaH0jX6R8wLLVMSL6X5ZRgt3aYM2nGlRnlOOpo51kJ5ZLuq1XuS09rdAP7rLsL8i/ky1hkd4FCo7S1HBbLmlY= X-Received: by 2002:aca:b141:: with SMTP id a62mr626467oif.101.1604658490602; Fri, 06 Nov 2020 02:28:10 -0800 (PST) MIME-Version: 1.0 References: <20201104140023.GQ36674@ziepe.ca> <20201104162125.GA13007@infradead.org> <20201104163758.GA17425@infradead.org> <20201104164119.GA18218@infradead.org> <20201104181708.GU36674@ziepe.ca> <20201105092524.GQ401619@phenom.ffwll.local> <20201105124950.GZ36674@ziepe.ca> <7ae3486d-095e-cf4e-6b0f-339d99709996@nvidia.com> In-Reply-To: From: Daniel Vetter Date: Fri, 6 Nov 2020 11:27:59 +0100 Message-ID: Subject: Re: [PATCH v5 05/15] mm/frame-vector: Use FOLL_LONGTERM To: John Hubbard , Thomas Hellstrom X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201106_052813_883573_B9FF1953 X-CRM114-Status: GOOD ( 25.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc , Jan Kara , KVM list , Pawel Osciak , Linux MM , LKML , DRI Development , Tomasz Figa , Christoph Hellwig , Jason Gunthorpe , J??r??me Glisse , "open list:DMA BUFFER SHARING FRAMEWORK" , Daniel Vetter , Kyungmin Park , Andrew Morton , Mauro Carvalho Chehab , Dan Williams , Linux ARM , Marek Szyprowski Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Nov 6, 2020 at 11:01 AM Daniel Vetter wrote: > > On Fri, Nov 6, 2020 at 5:08 AM John Hubbard wrote: > > > > On 11/5/20 4:49 AM, Jason Gunthorpe wrote: > > > On Thu, Nov 05, 2020 at 10:25:24AM +0100, Daniel Vetter wrote: > > >>> /* > > >>> * If we can't determine whether or not a pte is special, then fail immediately > > >>> * for ptes. Note, we can still pin HugeTLB and THP as these are guaranteed not > > >>> * to be special. > > >>> * > > >>> * For a futex to be placed on a THP tail page, get_futex_key requires a > > >>> * get_user_pages_fast_only implementation that can pin pages. Thus it's still > > >>> * useful to have gup_huge_pmd even if we can't operate on ptes. > > >>> */ > > >> > > >> We support hugepage faults in gpu drivers since recently, and I'm not > > >> seeing a pud_mkhugespecial anywhere. So not sure this works, but probably > > >> just me missing something again. > > > > > > It means ioremap can't create an IO page PUD, it has to be broken up. > > > > > > Does ioremap even create anything larger than PTEs? > > gpu drivers also tend to use vmf_insert_pfn* directly, so we can do > on-demand paging and move buffers around. From what I glanced for > lowest level we to the pte_mkspecial correctly (I think I convinced > myself that vm_insert_pfn does that), but for pud/pmd levels it seems > just yolo. So I dug around a bit more and ttm sets PFN_DEV | PFN_MAP to get past the various pft_t_devmap checks (see e.g. vmf_insert_pfn_pmd_prot()). x86-64 has ARCH_HAS_PTE_DEVMAP, and gup.c seems to handle these specially, but frankly I got totally lost in what this does. The comment above the pfn_t_devmap check makes me wonder whether doing this is correct or not. Also adding Thomas Hellstrom, who implemented the huge map support in ttm. -Daniel > remap_pfn_range seems to indeed split down to pte level always. > > > From my reading, yes. See ioremap_try_huge_pmd(). > > The ioremap here shouldn't matter, since this is for kernel-internal > mappings. So that's all fine I think. > -Daniel > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 E45A6C55178 for ; Fri, 6 Nov 2020 10:28:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17CB822242 for ; Fri, 6 Nov 2020 10:28:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="bzj83Mf9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17CB822242 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B895C6EE3E; Fri, 6 Nov 2020 10:28:12 +0000 (UTC) Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 541DB6EE3E for ; Fri, 6 Nov 2020 10:28:11 +0000 (UTC) Received: by mail-oi1-x242.google.com with SMTP id q206so830426oif.13 for ; Fri, 06 Nov 2020 02:28:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GZSvjJXJ5NeS3xeVpOYrkTBUqUJmeylcGC99/vSxMgE=; b=bzj83Mf9zM2hSbE8EWsBjDPrQihAyugYzXs6/XtzMk42mlteKogf38yikrIVtP0YIp 1PpqGJ83G8CMqUOSy0c+3J2x07vzzrc1y+f0AiA/gsD366OU8Q4TqDzYqRuPe+cWSz/V V9A5M3N3kUQY2mHkFVy5IQrEsMOk51+osCoGc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GZSvjJXJ5NeS3xeVpOYrkTBUqUJmeylcGC99/vSxMgE=; b=Szruvc72anUKZD6sjmEjKOHgL1FEu1FgHo2aJG/xyvHm6cvw67GlMDHqY7BuHbckZv +K9CpvF0iZVSV/mQCXZnCyjABHtBiKDXOD6YL9M047tDpZH7WlCGrdVHo5ZbOrErJId2 nExVj5LwMww3lYMYqctX/GO2NRrySUp3d4KiTRlRS03+cTXCX1oUBKHs4i4Ksjl8d7Of QD7tgZZiLIJ3eSuuQsAVPrikuzM1IbZ8RXO2DN/Fx11MRG1r0kGYTaFN0YWs3BY+MsbY O65mZ3SqGzezJG9d48hRLElTpMzdLNSiGvOhkEio+tFNDQsjj4BSSPTvGeiIgtT/xlzX S+bA== X-Gm-Message-State: AOAM533fcvCoZRX4nhl1L4u4kkx6J3pPKORPihwPzVHd8UXwjctjMvnn dhXzF1gmjBpZx6MIJeqE4t2nDRXep8OJklbxgKTXqQ== X-Google-Smtp-Source: ABdhPJxaH0jX6R8wLLVMSL6X5ZRgt3aYM2nGlRnlOOpo51kJ5ZLuq1XuS09rdAP7rLsL8i/ky1hkd4FCo7S1HBbLmlY= X-Received: by 2002:aca:b141:: with SMTP id a62mr626467oif.101.1604658490602; Fri, 06 Nov 2020 02:28:10 -0800 (PST) MIME-Version: 1.0 References: <20201104140023.GQ36674@ziepe.ca> <20201104162125.GA13007@infradead.org> <20201104163758.GA17425@infradead.org> <20201104164119.GA18218@infradead.org> <20201104181708.GU36674@ziepe.ca> <20201105092524.GQ401619@phenom.ffwll.local> <20201105124950.GZ36674@ziepe.ca> <7ae3486d-095e-cf4e-6b0f-339d99709996@nvidia.com> In-Reply-To: From: Daniel Vetter Date: Fri, 6 Nov 2020 11:27:59 +0100 Message-ID: Subject: Re: [PATCH v5 05/15] mm/frame-vector: Use FOLL_LONGTERM To: John Hubbard , Thomas Hellstrom X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc , Jan Kara , KVM list , Pawel Osciak , Linux MM , LKML , DRI Development , Tomasz Figa , Christoph Hellwig , Jason Gunthorpe , J??r??me Glisse , "open list:DMA BUFFER SHARING FRAMEWORK" , Daniel Vetter , Kyungmin Park , Andrew Morton , Mauro Carvalho Chehab , Dan Williams , Linux ARM , Marek Szyprowski Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Fri, Nov 6, 2020 at 11:01 AM Daniel Vetter wrote: > > On Fri, Nov 6, 2020 at 5:08 AM John Hubbard wrote: > > > > On 11/5/20 4:49 AM, Jason Gunthorpe wrote: > > > On Thu, Nov 05, 2020 at 10:25:24AM +0100, Daniel Vetter wrote: > > >>> /* > > >>> * If we can't determine whether or not a pte is special, then fail immediately > > >>> * for ptes. Note, we can still pin HugeTLB and THP as these are guaranteed not > > >>> * to be special. > > >>> * > > >>> * For a futex to be placed on a THP tail page, get_futex_key requires a > > >>> * get_user_pages_fast_only implementation that can pin pages. Thus it's still > > >>> * useful to have gup_huge_pmd even if we can't operate on ptes. > > >>> */ > > >> > > >> We support hugepage faults in gpu drivers since recently, and I'm not > > >> seeing a pud_mkhugespecial anywhere. So not sure this works, but probably > > >> just me missing something again. > > > > > > It means ioremap can't create an IO page PUD, it has to be broken up. > > > > > > Does ioremap even create anything larger than PTEs? > > gpu drivers also tend to use vmf_insert_pfn* directly, so we can do > on-demand paging and move buffers around. From what I glanced for > lowest level we to the pte_mkspecial correctly (I think I convinced > myself that vm_insert_pfn does that), but for pud/pmd levels it seems > just yolo. So I dug around a bit more and ttm sets PFN_DEV | PFN_MAP to get past the various pft_t_devmap checks (see e.g. vmf_insert_pfn_pmd_prot()). x86-64 has ARCH_HAS_PTE_DEVMAP, and gup.c seems to handle these specially, but frankly I got totally lost in what this does. The comment above the pfn_t_devmap check makes me wonder whether doing this is correct or not. Also adding Thomas Hellstrom, who implemented the huge map support in ttm. -Daniel > remap_pfn_range seems to indeed split down to pte level always. > > > From my reading, yes. See ioremap_try_huge_pmd(). > > The ioremap here shouldn't matter, since this is for kernel-internal > mappings. So that's all fine I think. > -Daniel > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel