Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5723286rwe; Tue, 18 Apr 2023 10:30:16 -0700 (PDT) X-Google-Smtp-Source: AKy350YJBCjxt/CLXWwA2aim7Ew7CSYhPCKQGFPc6T9/DzKwLMSDODJuNpxVP2qhEO8zTUx5lyAS X-Received: by 2002:a05:6a00:a09:b0:63b:7fc0:a4af with SMTP id p9-20020a056a000a0900b0063b7fc0a4afmr439040pfh.26.1681839015979; Tue, 18 Apr 2023 10:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681839015; cv=none; d=google.com; s=arc-20160816; b=pznU82c16ftTHQzHjrl90inpPgzvvfrs8dKtUG5d0CqUNl7sCNCf4OJm71rIwxHSjx LdEh25ivSw3xLe/h6JKs+L89vJTJGDBI5SScQtO0DWybDU6GEjSY7+zLEqQUPv7w0rxN iPKzw0561K7C1vgye3Px1KmPG3jGivmbrMYWwhDcjfXPEGWNPW3SMe068D6s3RwMgGUa xy2qslcuxe1bYEeI1YZwKEUQHt6//Rrfe5QmlZORA5kYhf+Notvv53Z8sP5ACc9VtlsL mhIJW7cHzQ/XMbsl9Q5BakqrMRpf+o0Rm5UTBq+4fb4TlXDOnrrW7wLgQv4R5XIp+mM0 k3FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=aaiw7V8k8wH9z4JrB/y3wNpwn08pUbQDV+4iNNk5WrU=; b=epBgih1q+j5a5ePkFNO0HhQM9TkWmldCidKVrrWJGh/Hv1nSDr73tjg7n8pbdGdQAG omtXl9erg4o0X6ZhETRMxmR6NEaWSwI83mrmJv4cthxPHXSXeNezLF4NiTNqsWrMcUe1 Ne6Q0CEbqsIIjpns31ECPRFIz7r0MdxFEyxgoWUKq5uuG+dmtPVc23za4lFNn5LeQBNx gdtnQwScszGnOwPcsXjG6OUrsmV4px0606ysI+fD2Kza4ivj7NVbX0990L8AsVJj1nil z/ys1u0aGkryvJoc3XnwlKovDcdyp51K8xWHk52lIHNVUzpM9q8xmnlBd2xUb2RKi25K LJ5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=slO5u1I3; 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 a134-20020a621a8c000000b0063d375f8e28si2106611pfa.128.2023.04.18.10.30.01; Tue, 18 Apr 2023 10:30:15 -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=slO5u1I3; 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 S232491AbjDRR01 (ORCPT + 99 others); Tue, 18 Apr 2023 13:26:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232137AbjDRR0X (ORCPT ); Tue, 18 Apr 2023 13:26:23 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 922A8A26B; Tue, 18 Apr 2023 10:26:15 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id kt6so36997718ejb.0; Tue, 18 Apr 2023 10:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681838774; x=1684430774; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=aaiw7V8k8wH9z4JrB/y3wNpwn08pUbQDV+4iNNk5WrU=; b=slO5u1I33nFyQxFlfCgyBo+J74Re+1J1463nwzWYqPkwrbiXf9UfUSSgyj+q9o4y/u TczsfqbyYkGfjNy5NJzxcL2leWPyOR5ExvWJzRSJCLHVD7yG0ybCdTz/yvpDJWwixRTV 1DZ39d50cjclVvrcehqYr4bTd2UmhmBTj4UqRFlh1UmK0dyDCoDpHO+Ff2aD/vz4YquI YyBQv5afqPuxYwN/YZu9CD2keQnWpmwEAU5+uZ8gTuH5hQdr+iAWxNAOPVSzQD9N95hi rUVukbFdSdorBanuJ6PZZB7FKP1aPSnSf8oP3bxw59WLMFDvZzGoFbwSgvUMbpm+J1Qc tudA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681838774; x=1684430774; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aaiw7V8k8wH9z4JrB/y3wNpwn08pUbQDV+4iNNk5WrU=; b=HsOtqN+XLb+5h6Zg74x9+g2Z4wfOUGGGyPC4zxkeTRvnsyRynqp2p7HgSyGZ6kaqdA boxUIEtAYXqBOFGjxguVFKZy/mwpemOVUhkuNGlYrJPMjMIF1Oc7/jJSFAcMTz+5zVeP tT1fUdGJWIySYpYtzGuDO/QBGOJa/oXt+23xlnAey18u6SGD3/w/+zLZqbwS9GWCuPwZ 0hNIr8wOimYfrBASe6v7EZhFl++UeRrudACXlliFPoTnffwgPE0ZtW4En2e+wuYySQoF Ru7gWHlapdymhFKb0UZiy0X3ISVUn90FkYnMHZ94MJ8NYKU5g3bO8RVpsO9aR2kVtW6x vJYw== X-Gm-Message-State: AAQBX9dmzITAzZakUFFt/A51NeJ7+MI+h9LnmcmCyMNuC815jPUo4gbW YREPKps5Qsn9fxF4zPSlX0I= X-Received: by 2002:a17:906:35d4:b0:94e:c317:2ff0 with SMTP id p20-20020a17090635d400b0094ec3172ff0mr11550407ejb.33.1681838773901; Tue, 18 Apr 2023 10:26:13 -0700 (PDT) Received: from ?IPV6:2620:10d:c096:310::26ef? ([2620:10d:c092:600::2:5697]) by smtp.gmail.com with ESMTPSA id gs8-20020a1709072d0800b0094f694e4ecbsm3667417ejc.146.2023.04.18.10.26.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Apr 2023 10:26:13 -0700 (PDT) Message-ID: <61ded378-51a8-1dcb-b631-fda1903248a9@gmail.com> Date: Tue, 18 Apr 2023 18:25:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 5/7] io_uring: rsrc: use FOLL_SAME_FILE on pin_user_pages() Content-Language: en-US To: Jason Gunthorpe Cc: Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Matthew Wilcox , David Hildenbrand , Jens Axboe , io-uring@vger.kernel.org References: <17357dec04b32593b71e4fdf3c30a346020acf98.1681508038.git.lstoakes@gmail.com> From: Pavel Begunkov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, 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 4/18/23 17:36, Jason Gunthorpe wrote: > On Tue, Apr 18, 2023 at 05:25:08PM +0100, Pavel Begunkov wrote: >> On 4/17/23 13:56, Jason Gunthorpe wrote: >>> On Sat, Apr 15, 2023 at 12:27:45AM +0100, Lorenzo Stoakes wrote: >>>> Commit edd478269640 ("io_uring/rsrc: disallow multi-source reg buffers") >>>> prevents io_pin_pages() from pinning pages spanning multiple VMAs with >>>> permitted characteristics (anon/huge), requiring that all VMAs share the >>>> same vm_file. >>> >>> That commmit doesn't really explain why io_uring is doing such a weird >>> thing. >>> >>> What exactly is the problem with mixing struct pages from different >>> files and why of all the GUP users does only io_uring need to care >>> about this? >> >> Simply because it doesn't seem sane to mix and register buffers of >> different "nature" as one. > > That is not a good reason. Once things are converted to struct pages > they don't need to care about their "nature" Arguing purely about uapi, I do think it is. Even though it can be passed down and a page is a page, Frankenstein's Monster mixing anon pages, pages for io_uring queues, device shared memory, and what not else doesn't seem right for uapi. I see keeping buffers as a single entity in opposite to a set of random pages beneficial for the future. And again, as for how it's internally done, I don't have any preference whatsoever. >> problem. We've been asked just recently to allow registering bufs >> provided mapped by some specific driver, or there might be DMA mapped >> memory in the future. > > We already have GUP flags to deal with it, eg FOLL_PCI_P2PDMA > >> Rejecting based on vmas might be too conservative, I agree and am all >> for if someone can help to make it right. > > It is GUP's problem to deal with this, not the callers. Ok, that's even better for io_uring if the same can be achieved just by passing flags. > GUP is defined to return a list of normal CPU DRAM in struct page > format. The caller doesn't care where or what this memory is, it is > all interchangable - by API contract of GUP itself. > > If you use FOLL_PCI_P2PDMA then the definition expands to allow struct > pages that are MMIO. > > In future, if someone invents new memory or new struct pages with > special needs it is their job to ensure it is blocked from GUP - for > *everyone*. eg how the PCI_P2PDMA was blocked from normal GUP. > > io_uring is not special, there are many users of GUP, they all need to > work consistently. -- Pavel Begunkov