Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4450750rwe; Mon, 17 Apr 2023 12:55:04 -0700 (PDT) X-Google-Smtp-Source: AKy350Y/yII+TZn9wGs4j14Y+4nomZyduqq2N4IZzQt5hq1slMMyLW/oWb8FH2r+/JSrbtH04lxC X-Received: by 2002:a17:90b:4b05:b0:247:4fc2:81c3 with SMTP id lx5-20020a17090b4b0500b002474fc281c3mr11056038pjb.11.1681761304167; Mon, 17 Apr 2023 12:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681761304; cv=none; d=google.com; s=arc-20160816; b=kunhRGpP3ESdOmooZud0tm5P6Rr3jx76oEPvsXBN1YiYnDHf5TrHbiiDSKbUHMyZNS rCZUwCeomBKjAy/2NJWqn0ncyV2Bl3NIveIgFIG7AIcHVs4QEGfXvryFeTvI5/pRieFU 2AodZgmQIvKtf10tBQT/uzWus/SLSryJBkFXb2TyBKD5qoLnObsPcix0lP1nelcZQkoy EZZ1Py2BeuAKbDmgzvm01akSAY6Nd7KzE9eSHJ9fNFlWmewSMxJMFPg+f7yo7kgD5PZ1 4cfXMQoEBay6IeUleyjfBKgIML4a06lDdz+GXquK+bvyUvsGrdPiW0yCpkR2OnhRWGpM cMhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZkpPzDKNye1p0Bi+afxT2w5cRXkVMuat6OESCAZjOlc=; b=uHY0Zb1BOK50A4Er3j78WF+lGg8fTarWkH5OdZZKFg4SHqQlw/WGelwDiK+b4RrqZ0 KeVZLVseAgsl35dSUhr1DU/NVCf4Y6z7dRphkbobIwXDGdhkNOGZK0J6W0iL+8CpKIml gUocfnIdBrTxnY4B4vFUyDuDZmC9NaDvwcNtfMh3q0JwmjHa0EHeHm6QSIFAjf73k1W+ 9olOajjXABzBpWTJxzz+zpqvH+VoBLBqEZG+uuMoq3L1n9z63XFzhfA09aekRFSThCWZ 1dSMD64bD6+j+3Ic6uD+MQGr2lG0uCMWIFarpRlp7B9HRYmel3PgDAeRGyXbvaqd7xlx uVFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=eveHTvGU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a170902708900b001a6cb738b8csi4359166plk.550.2023.04.17.12.54.52; Mon, 17 Apr 2023 12:55:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=eveHTvGU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbjDQTsH (ORCPT + 99 others); Mon, 17 Apr 2023 15:48:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230168AbjDQTqD (ORCPT ); Mon, 17 Apr 2023 15:46:03 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EECCED2; Mon, 17 Apr 2023 12:46:00 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id r15so4825331wmo.1; Mon, 17 Apr 2023 12:46:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681760759; x=1684352759; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZkpPzDKNye1p0Bi+afxT2w5cRXkVMuat6OESCAZjOlc=; b=eveHTvGUwIurwIcZKUmMfKipRZuwNBExVEK2kdyUYD0mnRERq6S3CwOETEFUtNJQQq Pk2wet28Bgynh2pkDhehnVB5XyZV+DnbnPCAyUVzlk8I19H05Ql0ddI/t6QR3SxVfIU0 zMr5yTp0l0m0AgWqmorrSokbryOwFZ/Fq9htulGq4Qn7fv97hO5keJ8tbBf7OYrdE9k4 /PBIifCiGixNUFRM1Gf0WHm76UVfb4lp1X1rLzkPHsboYi2+Un59c1ALyX3kylx/9qLv zhOzHSKCrCHv7bNKUOiOyUQ+KFpbE+k8xA//HfyiaRWJD8sXvKS9oYa+hYwtUxchU+rS Oo2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681760759; x=1684352759; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZkpPzDKNye1p0Bi+afxT2w5cRXkVMuat6OESCAZjOlc=; b=YmeY97ITTvQI6LzegkOtd5xpBhl5YJ4e8oqpf8bZS/iPyC8VzFwcRBqqgrOf2RBV8A pEa3FJ5vn775QfjA/yTD4n+87yTJNhzhmogPGw9mgrxa7g3QxKO9OCZX1JDEun8Y0dRH yfctB5lxo5p5bPR75pCgAFZ4ZmoW5DEtuMzGTqH0/3V3C6W8pHz8i7o5ze2noQFOnhph /ZxDUWZVZ/Iu7ZdufoSu2oAy6azn06dRt/wWsLqnpiLjOSj84CuLi7nHkCkR9PSrC43X Fy7xNHnuYy0uPrs9SvA8xdxwOGpMOC7zkA42J1pmX7Ah2XXCKeUSEUkN1wGqVYKx16LF 4AzQ== X-Gm-Message-State: AAQBX9cwPyCCGGD9Ga5gGeAa70BfpXE44lvzJ2VCZ2AIGvbLlbnNUiMb HyNrjL+jRsQkiIl5NyxHytukkKfTFRuipA== X-Received: by 2002:a05:600c:22cf:b0:3ef:5940:5f45 with SMTP id 15-20020a05600c22cf00b003ef59405f45mr10682246wmg.23.1681760759266; Mon, 17 Apr 2023 12:45:59 -0700 (PDT) Received: from localhost (host86-156-84-164.range86-156.btcentralplus.com. [86.156.84.164]) by smtp.gmail.com with ESMTPSA id n16-20020a05600c4f9000b003f1712b1402sm5598569wmq.30.2023.04.17.12.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 12:45:58 -0700 (PDT) Date: Mon, 17 Apr 2023 20:45:57 +0100 From: Lorenzo Stoakes To: Jason Gunthorpe Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Matthew Wilcox , David Hildenbrand , Jens Axboe , Pavel Begunkov , io-uring@vger.kernel.org Subject: Re: [PATCH 5/7] io_uring: rsrc: use FOLL_SAME_FILE on pin_user_pages() Message-ID: References: <17357dec04b32593b71e4fdf3c30a346020acf98.1681508038.git.lstoakes@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 17, 2023 at 04:24:04PM -0300, Jason Gunthorpe wrote: > On Mon, Apr 17, 2023 at 08:00:48PM +0100, Lorenzo Stoakes wrote: > > > So I don't think this route is plausible unless you were thinking of > > somehow offloading to a thread? > > ah, fair enough > > > In any case, if we institute the FOLL_ALLOW_BROKEN_FILE_MAPPINGS flag we > > can just drop FOLL_ANON altogether right, as this will be implied and > > hugetlb should work here too? > > Well.. no, as I said read-only access to the pages works fine, so GUP > should not block that. It is only write that has issues > > > Separately, I find the semantics of access_remote_vm() kind of weird, and > > with a possible mmap_lock-free future it does make me wonder whether > > something better could be done there. > > Yes, it is very weird, kthread_use_mm is much nicer. > > > (Section where I sound like I might be going mad) Perhaps having some means > > of context switching into the kernel portion of the remote process as if > > were a system call or soft interrupt handler and having that actually do > > the uaccess operation could be useful here? > > This is the kthread_use_mm() approach, that is basically what it > does. You are suggesting to extend it to kthreads that already have a > process attached... Yeah, I wonder how plausible this is as we could in theory simply eliminate these remote cases altogether which could be relatively efficient if we could find a way to batch up operations. > > access_remote_vm is basically copy_to/from_user built using kmap and > GUP. > > even a simple step of localizing FOLL_ANON to __access_remote_vm, > since it must have the VMA nyhow, would be an improvement. This is used from places where this flag might not be set though, e.g. acess_process_vm() and ptrace. However, access_remote_vm() is only used by the proc stuff, so I will spin up a patch to move this function and treat it as a helper which sets FOLL_ANON. > > Jason