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.9 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 090B8C4363C for ; Sun, 4 Oct 2020 11:22:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA83B2080A for ; Sun, 4 Oct 2020 11:22:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="f5dd3Mrk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726046AbgJDLW3 (ORCPT ); Sun, 4 Oct 2020 07:22:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbgJDLUq (ORCPT ); Sun, 4 Oct 2020 07:20:46 -0400 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C60CEC0613CE for ; Sun, 4 Oct 2020 04:20:43 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id 60so5877063otw.3 for ; Sun, 04 Oct 2020 04:20:43 -0700 (PDT) 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=F1P39aVq/hZE1a/ZNFpkwqSichMZqIMoJHAVD0hctIo=; b=f5dd3MrkYcy8/aD7b+pp4n3Qd4ummEslPZLTRt6CmyxxeMAlfleGd5Dfp874p+qUpY j6kAiBeOvNPrJhgZA8ZwL8CfE9QHGJf7l9mEUa3q3twT+o7VwA7yWSbyIEkatqa7DjKZ 2o7kSRHm9MLEBW4gDBATa2dJOssUGc4hiGwFE= 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=F1P39aVq/hZE1a/ZNFpkwqSichMZqIMoJHAVD0hctIo=; b=ZOUCSxXvW8yh5DALaCz7euOIX7u7H8qJzMKyyRRyRvBU1a/TrzNesz/TLfkRf/6ugk +hP986NPuY0L4nw+Sn/nICBO1Bq9xrvJbENsWTt02QEKgfEVcyW3vXA+tOcLX6k0MNAn /zbAmIiaRESUTQ8R40YKkCHGV4BXwyJgPtb50rpfRhf3Ftki4Did04QL6QrnVxSOqU7M zSsrKOtHwxaABH3Mt8ojFaqtvdoMR5oqVSzq/2M9sPRg1IKZ7KQC9Ig/+8LJbtDpF7fS XeTKvNSD0jRM1dSv0QLi9xvj+6BdTFrQvsjISiNIHbaYmf/yvM5dO2sqEeaYvmkVZXi0 TrCA== X-Gm-Message-State: AOAM530hg3FFpYFgaLyPUZOkbTH1UITZ+dnPNpl8MHi5yP2AhkxhI+w1 OYU6FCLq0xADd0D7XPP2GSB+IK2FFgqCXAdB/tN0jA== X-Google-Smtp-Source: ABdhPJzk4utKZUHKkD2Pntaa4TtV+H5VfSo7BOy9dlnzPXQ7sPmOEnfTjNGZnPb4bUQ2llmVT9XDHSXvI1R3pQKQgMQ= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr777182otr.281.1601810442219; Sun, 04 Oct 2020 04:20:42 -0700 (PDT) MIME-Version: 1.0 References: <20201002175303.390363-1-daniel.vetter@ffwll.ch> <20201002175303.390363-2-daniel.vetter@ffwll.ch> <20201003232441.GO9916@ziepe.ca> In-Reply-To: <20201003232441.GO9916@ziepe.ca> From: Daniel Vetter Date: Sun, 4 Oct 2020 13:20:31 +0200 Message-ID: Subject: Re: [PATCH 2/2] mm/frame-vec: use FOLL_LONGTERM To: Jason Gunthorpe Cc: John Hubbard , DRI Development , LKML , Daniel Vetter , Andrew Morton , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jan Kara , Dan Williams , Linux MM , Linux ARM , linux-samsung-soc , "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 Sun, Oct 4, 2020 at 1:24 AM Jason Gunthorpe wrote: > On Sat, Oct 03, 2020 at 03:52:32PM -0700, John Hubbard wrote: > > On 10/3/20 2:45 AM, Daniel Vetter wrote: > > > On Sat, Oct 3, 2020 at 12:39 AM John Hubbard wrote: > > > > > > > > On 10/2/20 10:53 AM, Daniel Vetter wrote: > > > > > For $reasons I've stumbled over this code and I'm not sure the change > > > > > to the new gup functions in 55a650c35fea ("mm/gup: frame_vector: > > > > > convert get_user_pages() --> pin_user_pages()") was entirely correct. > > > > > > > > > > This here is used for long term buffers (not just quick I/O) like > > > > > RDMA, and John notes this in his patch. But I thought the rule for > > > > > these is that they need to add FOLL_LONGTERM, which John's patch > > > > > didn't do. > > > > > > > > Yep. The earlier gup --> pup conversion patches were intended to not > > > > have any noticeable behavior changes, and FOLL_LONGTERM, with it's > > > > special cases and such, added some risk that I wasn't ready to take > > > > on yet. Also, FOLL_LONGTERM rules are only *recently* getting firmed > > > > up. So there was some doubt at least in my mind, about which sites > > > > should have it. > > > > > > > > But now that we're here, I think it's really good that you've brought > > > > this up. It's definitely time to add FOLL_LONGTERM wherever it's missing. > > > > > > So should I keep this patch, or will it collide with a series you're working on? > > > > It doesn't collide with anything on my end yet, because I've been slow to > > pick up on the need for changing callsites to add FOLL_LONGTERM. :) > > > > And it looks like that's actually a problem, because: > > > > > > > > Also with the firmed up rules, correct that I can also drop the > > > vma_is_fsdax check when the FOLL_LONGTERM flag is set? > > > > That's the right direction to go *in general*, but I see that the > > pin_user_pages code is still a bit stuck in the past. And this patch > > won't actually work, with or without that vma_is_fsdax() check. > > Because: > > > > get_vaddr_frames(FOLL_LONGTERM) > > pin_user_pages_locked() > > if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM)) > > return -EINVAL; > > There is no particular reason this code needs to have the mm sem at > that point. > > It should call pin_user_pages_fast() and only if that fails get the mmap > lock and extract the VMA to do broken hackery. Yeah I think that works. I tried understanding gup.c code a bit more, and it looks like FOLL_LONGTERM only works for the pup_fast variant right now? All others seem to have this comment that it's somehow incompatible with FAULT_FLAG_ALLOW_RETRY and daxfs. But grepping around for that didn't show up anything, at least not nearby dax code. For my understanding of all this, what's the hiccup there? For plans, I only started this for a bit of my own learning, but I think I'll respin with the following changes: - convert exynos and habanalabs to pin_user_pages_fast directly, instead of going through this frame-vector detour - move the locking and convert get_vaddr_frames to pup_fast as Jason suggested - hack up some truly gross rfc to plug the follow_pfn hole Cheers, Daniel -- 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=-4.5 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 0BD7DC4363C for ; Sun, 4 Oct 2020 11:22:38 +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 B2DF1206A1 for ; Sun, 4 Oct 2020 11:22:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oBjlm0f8"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="f5dd3Mrk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2DF1206A1 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=9kT5E6bTKgv7Pz5ul0DUhNPBaY0Hu+gHCeSfz0j498U=; b=oBjlm0f8kJmUMimC0b6+yEUkP ESCqK4MukezysasNF3efr6yRhhcOzl72h9r8PURVXkmCJVg77LrdCZv4HPcwaxV4wdXCgxk415rJK 5kt/90+d/1s0Gdj6dAtM8Dsx7NPSNUqa/LRqcrbfs8xzQa7uqGqxwUqUKkzWUhpcM62TrpoAZU45P DVs12Fx6448TAuni1uTAYLDDMMteCqnKK48tTcKFvfqm4zZTTOZnXk18488MxWQkNvtGopsm9z94u 91HB178dD8sGU2oljbSbZ4x21XD+i2Wb8SlPeRGEiKQy0nLg4/6nS0+o5etv+GAdE+y9B2VxjWTpG RUg6w8Hag==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kP24Q-0003LZ-Bf; Sun, 04 Oct 2020 11:20:50 +0000 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kP24N-0003Kd-0m for linux-arm-kernel@lists.infradead.org; Sun, 04 Oct 2020 11:20:48 +0000 Received: by mail-ot1-x331.google.com with SMTP id u25so5864373otq.6 for ; Sun, 04 Oct 2020 04:20:43 -0700 (PDT) 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=F1P39aVq/hZE1a/ZNFpkwqSichMZqIMoJHAVD0hctIo=; b=f5dd3MrkYcy8/aD7b+pp4n3Qd4ummEslPZLTRt6CmyxxeMAlfleGd5Dfp874p+qUpY j6kAiBeOvNPrJhgZA8ZwL8CfE9QHGJf7l9mEUa3q3twT+o7VwA7yWSbyIEkatqa7DjKZ 2o7kSRHm9MLEBW4gDBATa2dJOssUGc4hiGwFE= 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=F1P39aVq/hZE1a/ZNFpkwqSichMZqIMoJHAVD0hctIo=; b=CFCjiypj7xmGtkE8I7EllfVX2nTJeNYVvQmHIP3owbgU+xU+li2+ikCp2OHct7EsdO zsx+VUVQ7OZNUrZF7HWeu8+eW23yDW2Csib6O0MZBtrEja0A6D2ddEvOiTqQKUFihaVX gat5BoRuod6cjjD+9w4Z7g9yRDEZPI0b1qHXmJ0Zc6RCptWzoaVa6sXLxl0v0Ollo7nS VEgumM0YtQ8vIez1rP6X+VCOnil/gpS+esK4sUmA0b96r36xBOYssnOBajv4ZjYTpYSq wcNJ816QSxB9df6OZn/8c3yWT6B5rytQYZhNSat4t2ht3IPgyZ3V2wF3pcgLgPgGlq83 M8+g== X-Gm-Message-State: AOAM533xlHhv7bF27Oj7ZU6OqqKXqT5Fio1sg8pBA0gFrUTcbU+zQv/n 8mc/I3BxMt4lNnKSPJV8Id+pvyGrGq5ZgXolBQur5A== X-Google-Smtp-Source: ABdhPJzk4utKZUHKkD2Pntaa4TtV+H5VfSo7BOy9dlnzPXQ7sPmOEnfTjNGZnPb4bUQ2llmVT9XDHSXvI1R3pQKQgMQ= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr777182otr.281.1601810442219; Sun, 04 Oct 2020 04:20:42 -0700 (PDT) MIME-Version: 1.0 References: <20201002175303.390363-1-daniel.vetter@ffwll.ch> <20201002175303.390363-2-daniel.vetter@ffwll.ch> <20201003232441.GO9916@ziepe.ca> In-Reply-To: <20201003232441.GO9916@ziepe.ca> From: Daniel Vetter Date: Sun, 4 Oct 2020 13:20:31 +0200 Message-ID: Subject: Re: [PATCH 2/2] mm/frame-vec: use FOLL_LONGTERM To: Jason Gunthorpe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201004_072047_196409_465DDCE2 X-CRM114-Status: GOOD ( 35.03 ) 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 , John Hubbard , LKML , DRI Development , Linux MM , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Daniel Vetter , Andrew Morton , Dan Williams , Linux ARM , "open list:DMA BUFFER SHARING FRAMEWORK" 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 Sun, Oct 4, 2020 at 1:24 AM Jason Gunthorpe wrote: > On Sat, Oct 03, 2020 at 03:52:32PM -0700, John Hubbard wrote: > > On 10/3/20 2:45 AM, Daniel Vetter wrote: > > > On Sat, Oct 3, 2020 at 12:39 AM John Hubbard wrote: > > > > > > > > On 10/2/20 10:53 AM, Daniel Vetter wrote: > > > > > For $reasons I've stumbled over this code and I'm not sure the change > > > > > to the new gup functions in 55a650c35fea ("mm/gup: frame_vector: > > > > > convert get_user_pages() --> pin_user_pages()") was entirely correct. > > > > > > > > > > This here is used for long term buffers (not just quick I/O) like > > > > > RDMA, and John notes this in his patch. But I thought the rule for > > > > > these is that they need to add FOLL_LONGTERM, which John's patch > > > > > didn't do. > > > > > > > > Yep. The earlier gup --> pup conversion patches were intended to not > > > > have any noticeable behavior changes, and FOLL_LONGTERM, with it's > > > > special cases and such, added some risk that I wasn't ready to take > > > > on yet. Also, FOLL_LONGTERM rules are only *recently* getting firmed > > > > up. So there was some doubt at least in my mind, about which sites > > > > should have it. > > > > > > > > But now that we're here, I think it's really good that you've brought > > > > this up. It's definitely time to add FOLL_LONGTERM wherever it's missing. > > > > > > So should I keep this patch, or will it collide with a series you're working on? > > > > It doesn't collide with anything on my end yet, because I've been slow to > > pick up on the need for changing callsites to add FOLL_LONGTERM. :) > > > > And it looks like that's actually a problem, because: > > > > > > > > Also with the firmed up rules, correct that I can also drop the > > > vma_is_fsdax check when the FOLL_LONGTERM flag is set? > > > > That's the right direction to go *in general*, but I see that the > > pin_user_pages code is still a bit stuck in the past. And this patch > > won't actually work, with or without that vma_is_fsdax() check. > > Because: > > > > get_vaddr_frames(FOLL_LONGTERM) > > pin_user_pages_locked() > > if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM)) > > return -EINVAL; > > There is no particular reason this code needs to have the mm sem at > that point. > > It should call pin_user_pages_fast() and only if that fails get the mmap > lock and extract the VMA to do broken hackery. Yeah I think that works. I tried understanding gup.c code a bit more, and it looks like FOLL_LONGTERM only works for the pup_fast variant right now? All others seem to have this comment that it's somehow incompatible with FAULT_FLAG_ALLOW_RETRY and daxfs. But grepping around for that didn't show up anything, at least not nearby dax code. For my understanding of all this, what's the hiccup there? For plans, I only started this for a bit of my own learning, but I think I'll respin with the following changes: - convert exynos and habanalabs to pin_user_pages_fast directly, instead of going through this frame-vector detour - move the locking and convert get_vaddr_frames to pup_fast as Jason suggested - hack up some truly gross rfc to plug the follow_pfn hole Cheers, Daniel -- 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.6 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 C541DC4363C for ; Sun, 4 Oct 2020 11:20:45 +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 86899206A1 for ; Sun, 4 Oct 2020 11:20:44 +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="f5dd3Mrk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86899206A1 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 CAD8389FD1; Sun, 4 Oct 2020 11:20:43 +0000 (UTC) Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by gabe.freedesktop.org (Postfix) with ESMTPS id E48A389FD1 for ; Sun, 4 Oct 2020 11:20:42 +0000 (UTC) Received: by mail-ot1-x330.google.com with SMTP id h17so5886997otr.1 for ; Sun, 04 Oct 2020 04:20:42 -0700 (PDT) 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=F1P39aVq/hZE1a/ZNFpkwqSichMZqIMoJHAVD0hctIo=; b=f5dd3MrkYcy8/aD7b+pp4n3Qd4ummEslPZLTRt6CmyxxeMAlfleGd5Dfp874p+qUpY j6kAiBeOvNPrJhgZA8ZwL8CfE9QHGJf7l9mEUa3q3twT+o7VwA7yWSbyIEkatqa7DjKZ 2o7kSRHm9MLEBW4gDBATa2dJOssUGc4hiGwFE= 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=F1P39aVq/hZE1a/ZNFpkwqSichMZqIMoJHAVD0hctIo=; b=PYnM/ufqRXSRg8lVwYJFmmRoNFJmmtAbuJczriy+9H+uc9tQyoAIt2DfoTlDw9NJWt b35dyNAdCKyPmV6twOpEtm2x1HAj7UD5N0WuDmVpBexAT6HIjHxfRmUP5h4K/ugyKJpL r19rFRSOSyPH0uYarOItH4udNN9KuvQzUvPx8I96kUY5ETWiC5PJmcANbTLQPOFgB1Bm ryXJxHIgiiochLJSeoSt8XQkpXDgwdd03c2GEN4ZuJC9t7eJdim5Mtkp+fsv3uRIp3Wk eBuApZie98Z2uiZTHoAB8iw2DoML+vZCxCJ2t0MJVneTnZvnLx+/MA4DxRg4hb49xTcG e3cg== X-Gm-Message-State: AOAM5316zmw8KSJ2UGS5VvbiiyKg4spjDdt6HAxOOCbAk4BPdDszi0rs u7+sXR8QXlBC2Hu4q0hxQ/h39rYTEh6FNY7QfKj3gA== X-Google-Smtp-Source: ABdhPJzk4utKZUHKkD2Pntaa4TtV+H5VfSo7BOy9dlnzPXQ7sPmOEnfTjNGZnPb4bUQ2llmVT9XDHSXvI1R3pQKQgMQ= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr777182otr.281.1601810442219; Sun, 04 Oct 2020 04:20:42 -0700 (PDT) MIME-Version: 1.0 References: <20201002175303.390363-1-daniel.vetter@ffwll.ch> <20201002175303.390363-2-daniel.vetter@ffwll.ch> <20201003232441.GO9916@ziepe.ca> In-Reply-To: <20201003232441.GO9916@ziepe.ca> From: Daniel Vetter Date: Sun, 4 Oct 2020 13:20:31 +0200 Message-ID: Subject: Re: [PATCH 2/2] mm/frame-vec: use FOLL_LONGTERM To: Jason Gunthorpe 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 , John Hubbard , LKML , DRI Development , Linux MM , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Daniel Vetter , Andrew Morton , Dan Williams , Linux ARM , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Sun, Oct 4, 2020 at 1:24 AM Jason Gunthorpe wrote: > On Sat, Oct 03, 2020 at 03:52:32PM -0700, John Hubbard wrote: > > On 10/3/20 2:45 AM, Daniel Vetter wrote: > > > On Sat, Oct 3, 2020 at 12:39 AM John Hubbard wrote: > > > > > > > > On 10/2/20 10:53 AM, Daniel Vetter wrote: > > > > > For $reasons I've stumbled over this code and I'm not sure the change > > > > > to the new gup functions in 55a650c35fea ("mm/gup: frame_vector: > > > > > convert get_user_pages() --> pin_user_pages()") was entirely correct. > > > > > > > > > > This here is used for long term buffers (not just quick I/O) like > > > > > RDMA, and John notes this in his patch. But I thought the rule for > > > > > these is that they need to add FOLL_LONGTERM, which John's patch > > > > > didn't do. > > > > > > > > Yep. The earlier gup --> pup conversion patches were intended to not > > > > have any noticeable behavior changes, and FOLL_LONGTERM, with it's > > > > special cases and such, added some risk that I wasn't ready to take > > > > on yet. Also, FOLL_LONGTERM rules are only *recently* getting firmed > > > > up. So there was some doubt at least in my mind, about which sites > > > > should have it. > > > > > > > > But now that we're here, I think it's really good that you've brought > > > > this up. It's definitely time to add FOLL_LONGTERM wherever it's missing. > > > > > > So should I keep this patch, or will it collide with a series you're working on? > > > > It doesn't collide with anything on my end yet, because I've been slow to > > pick up on the need for changing callsites to add FOLL_LONGTERM. :) > > > > And it looks like that's actually a problem, because: > > > > > > > > Also with the firmed up rules, correct that I can also drop the > > > vma_is_fsdax check when the FOLL_LONGTERM flag is set? > > > > That's the right direction to go *in general*, but I see that the > > pin_user_pages code is still a bit stuck in the past. And this patch > > won't actually work, with or without that vma_is_fsdax() check. > > Because: > > > > get_vaddr_frames(FOLL_LONGTERM) > > pin_user_pages_locked() > > if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM)) > > return -EINVAL; > > There is no particular reason this code needs to have the mm sem at > that point. > > It should call pin_user_pages_fast() and only if that fails get the mmap > lock and extract the VMA to do broken hackery. Yeah I think that works. I tried understanding gup.c code a bit more, and it looks like FOLL_LONGTERM only works for the pup_fast variant right now? All others seem to have this comment that it's somehow incompatible with FAULT_FLAG_ALLOW_RETRY and daxfs. But grepping around for that didn't show up anything, at least not nearby dax code. For my understanding of all this, what's the hiccup there? For plans, I only started this for a bit of my own learning, but I think I'll respin with the following changes: - convert exynos and habanalabs to pin_user_pages_fast directly, instead of going through this frame-vector detour - move the locking and convert get_vaddr_frames to pup_fast as Jason suggested - hack up some truly gross rfc to plug the follow_pfn hole Cheers, Daniel -- 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