Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp11800ybz; Thu, 30 Apr 2020 15:29:23 -0700 (PDT) X-Google-Smtp-Source: APiQypIwKUd1Ko8po39bQXG6SVix5b+WYQiOi35QbfyRieMAR1fwONnxJn89nX6OBe5QtTzmy+RW X-Received: by 2002:a50:e002:: with SMTP id e2mr1151684edl.179.1588285763733; Thu, 30 Apr 2020 15:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588285763; cv=none; d=google.com; s=arc-20160816; b=ZUerkcpvCbTYQlg3e0AsgTYoHswXoOHZyyXyy93v+M1+clwtpU3eAId3Y1QP5l56iW h/4usBRXRvFBBFSKgmluqsAptKGizj8wjgTfliz9Y5HyxRm4xn8DZIookcXpyiKq7qIC l9EiK/e4pEHHlSwLO9Unt28MXQR3boV+qsQdHgOuaI4Reg6l9zQuoUSuaKpEp+zlm59X QSZlh5A6nGCX6URETidyjuk71lZLoyK6Iw1xVVKwNEF5X31sBiBCgyJvPsXJ8yBLnKGT EFKODHSx5ROpkdcc5OtkbB9JrbZt652upH7WCjw3HL9jcl8BiuToZYpPZcZrkJLftWdh Tkhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=PfIc0Ej9cQtaja7/GNMf6pJmEyJmx2HiNl1JcjlZMjI=; b=CI6AttNOLAOO+32NgGuc6ejXTLBJ8mFYnGGMAh2EXei4+JfkKPiPYKK1h/l9Jp4Wcg 48eRRzEr9/Xp8sX7B+1TLOQEwOB0eW6R3C84IgzJmrtL/pjiO17TETtFw5WcfvWkw0MN PW8Nb4SVJeXEYfDubT6o7JuJ5DMucMIcDA/uTOPyMCcmgEACceMPbhZQZCULpCv/XBcg KooNcKuJivg9yOACyX2ZMxHuRtQTM/AusUdmLmH8vgYsdyOdTs/r0kOAxtpT0me/pkzN V5p9gVmzALE20hNwBY96MJhdz8ArpJCglQA+dNtthdd/fRn2sZdpcDlJJhOeyT1WR8Nh miSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=TNJMwVu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l64si695781ede.47.2020.04.30.15.28.38; Thu, 30 Apr 2020 15:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=TNJMwVu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727864AbgD3W02 (ORCPT + 99 others); Thu, 30 Apr 2020 18:26:28 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:1432 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbgD3W01 (ORCPT ); Thu, 30 Apr 2020 18:26:27 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 30 Apr 2020 15:25:20 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 30 Apr 2020 15:26:27 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 30 Apr 2020 15:26:27 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 30 Apr 2020 22:26:26 +0000 Received: from [10.2.50.180] (10.124.1.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 30 Apr 2020 22:26:26 +0000 Subject: Re: [PATCH v1 1/1] fs/splice: add missing callback for inaccessible pages To: Christian Borntraeger , Dave Hansen , Claudio Imbrenda , , , CC: , , , , , , , , References: <20200428225043.3091359-1-imbrenda@linux.ibm.com> <2a1abf38-d321-e3c7-c3b1-53b6db6da310@intel.com> <4b32c162-6ea4-ba91-b6d5-8961b7dff6e8@de.ibm.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: <0b7c0575-5d31-e34a-13bf-f2e67c5aa3d4@nvidia.com> Date: Thu, 30 Apr 2020 15:26:25 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To DRHQMAIL107.nvidia.com (10.27.9.16) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1588285520; bh=PfIc0Ej9cQtaja7/GNMf6pJmEyJmx2HiNl1JcjlZMjI=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=TNJMwVu65tIQy0f8Eu+UM3gRKR0uy+hIEPwjoqG97gQY5yl45DX4WrNL82IpcqY/H UPj2px7nL/QYT3AqfyOKZ5SZ796Ylk+yKN9Tx1ujJgTNtEJvycUjJl4AR//Ja0NJpi yVN40wmDcT6+eZa7uWEEbCyjV0O7/Jdlz/7f+/o5nNsDUwvTxdeTWNC1SOFZKNGsXG TlbQwpoyR3gYnpbbjCDbO4p4cIrUmwPRh/lTkXqARO+cTp+uQOr5DGBorFtnK9sQtE znNkhTl7fy0k6QKtqMc8iwVpNKP/farng/97d6N2+eM5J+87lcN29eh7DVUCsb0Apj tWxFiFyU11sug== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-04-30 12:54, Christian Borntraeger wrote: > On 30.04.20 21:02, Christian Borntraeger wrote: >> On 30.04.20 20:12, Christian Borntraeger wrote: >>> On 29.04.20 18:07, Dave Hansen wrote: >>>> On 4/28/20 3:50 PM, Claudio Imbrenda wrote: >>>>> If a page is inaccesible and it is used for things like sendfile, then >>>>> the content of the page is not always touched, and can be passed >>>>> directly to a driver, causing issues. >>>>> >>>>> This patch fixes the issue by adding a call to arch_make_page_accessible >>>>> in page_cache_pipe_buf_confirm; this fixes the issue. >>>> >>>> I spent about 5 minutes putting together a patch: >>>> >>>> https://sr71.net/~dave/intel/accessible.patch >>> >>> You only set the page flag for compound pages. that of course leaves a big pile >>> of pages marked a not accessible, thus explaining the sendto trace and all kind >>> of other random traces. >>> >>> >>> What do you see when you also do the SetPageAccessible(page); >>> in the else page of prep_new_page (order == 0). >>> (I do get > 10000 of these non compound page allocs just during boot). >>> >> >> And yes, I think you are right that we should call the callback also for !FOLL_PIN. > Disclaimer: I haven't dug into the details of the latest points above, so answers below will be narrowly focused. > > Thinking again about this I am no longer sure. Adding John Hubbard. > > Documentation/core-api/pin_user_pages.rst says: > -------snip---------- > Another way of thinking about these flags is as a progression of restrictions: > FOLL_GET is for struct page manipulation, without affecting the data that the > struct page refers to. FOLL_PIN is a *replacement* for FOLL_GET, and is for > short term pins on pages whose data *will* get accessed. As such, FOLL_PIN is > a "more severe" form of pinning. And finally, FOLL_LONGTERM is an even more > restrictive case that has FOLL_PIN as a prerequisite: this is for pages that > will be pinned longterm, and whose data will be accessed. > -------snip---------- > > So John,is it ok to give a page to an I/O device where the code has used gup > with FOLL_GET (or gup fast without pup) or would you consider this a bug? > Well, it's a bug (or a bug-in-waiting): even though gup/FOLL_GET works just as well (and as badly) as ever, pup/FOLL_PIN is required in order to safely and correctly allow a non-CPU device to operate on a page's data. Core mm and fs code is going to key off of page_maybe_dma_pinned() in order to make critical decisions about writeback and umount, and FOLL_PIN opts into that; FOLL_GET does not. Basically, you'd be creating another set of call sites that someone would have to convert to pup/FOLL_PIN. btw, on the FOLL_LONGTERM documentation above: that's more of an aspiration than a description of current behavior, in some ways. The current FOLL_LONGTERM is a little more quirky than is implied there. Also on a related note, I've been slow in posting patches to implement the remaining call site conversions, and am trying to get back to that asap. There have been some distractions. :) Once every call site is correctly using gup or pup, it will be easier for everyone. thanks, -- John Hubbard NVIDIA