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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF3D1C6FD18 for ; Tue, 18 Apr 2023 17:26:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC9488E0002; Tue, 18 Apr 2023 13:26:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D7A528E0001; Tue, 18 Apr 2023 13:26:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4ADF8E0002; Tue, 18 Apr 2023 13:26:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B2C658E0001 for ; Tue, 18 Apr 2023 13:26:17 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 66E9A14029F for ; Tue, 18 Apr 2023 17:26:17 +0000 (UTC) X-FDA: 80695190394.27.7F39475 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by imf17.hostedemail.com (Postfix) with ESMTP id 78A6940018 for ; Tue, 18 Apr 2023 17:26:15 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=slO5u1I3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.218.50 as permitted sender) smtp.mailfrom=asml.silence@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681838775; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aaiw7V8k8wH9z4JrB/y3wNpwn08pUbQDV+4iNNk5WrU=; b=uybGsHx3uJ2ueKX38y1A9OKDZD2SnICbx0okhHdjuZkE41SzNlyxdOKOtEHN+KjoyXMrPc Gp6dgs6Laxxaujk7BmN45ILPcY6X9KnN3lFTekbIeYJC93oyQx4E3uG/Yd9M+miHbpuGTp g1wv4fevFsRFXQ78je93Gdgh+NBDNUI= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=slO5u1I3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of asml.silence@gmail.com designates 209.85.218.50 as permitted sender) smtp.mailfrom=asml.silence@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681838775; a=rsa-sha256; cv=none; b=WU2xNtxc0gacn1u44v5he65kqx1nb6wi6bnibjjxaaAVkrhkprf+DAaUSh3INERIatfRla k9UhQbBgBMz23rttZRvq65KZwCmnd/kqWf1UnFY7K2hnpNXS1BKEzGDtSVEDGkmAUPz+iN WeaWeGhD5SO+oFovRM2Ns8LuxHSiqIc= Received: by mail-ej1-f50.google.com with SMTP id a5so18631730ejb.6 for ; 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=IfdGeBDlU5v1hgtECrx0dOldE1H8XAKBa+UD7dOBqs2jfGwj+0cY+271EWopTAuC5s u1ZhHo7E1XKnAV1U4YOoTnhfI7ZV+/z9kEEAPxPvi3eV4+LHj6K50aWCj8gIsFBmZPMX 7zzpKr8rOngwnRTWlV0Z/iaaYvdL/bZYHaThjAeCaE06+GzweIy1I7Szx6fRDSrqDrdp HLhQMMINRwS79s52kIenadxjxbR8+FxXYSYaB3l1qxqW9HzOs/j42Z+lUkn2OnfaFzrE XEHWAp/VpOml6mgCt3AWqUz1wlgDk5zBHCXFqEMBWxdaFc9sLjQe/HKiABq3YFJP3zOi jskA== X-Gm-Message-State: AAQBX9dA9dXF4dic2hBO99H8gBMkonwr0FiJ5233c1QAj80G3xEcbkGt n1HD+Ic81M7aZKO9a3VDDRY= X-Google-Smtp-Source: AKy350ZUpa9TcFQ41rMxn9IQ2/E64zbqR+REpUN9wbwr+bM2ZrAMz2N9JQIk5BFk7IQBm04QEsifSQ== 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-Rspamd-Queue-Id: 78A6940018 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: hk6xghk9fmm3yuro6awkh5eukgskm8cn X-HE-Tag: 1681838775-831254 X-HE-Meta: U2FsdGVkX19ZnXMheF6porjsqsRCCdVmwPDszPrX6dBPrxEwR5pen8AtCVbdtPNyqPD4eD7vZo6YiBXRz/jPTHx8DFTKW+x38yJ33w0BgIAAIshcneOuAbUb/CEa6lWTkmxltC+3ZB1EBEcIG9IlTl48JPIh3TtuPKj0TC/RuP8iz9uC7Bhqc6kJCuiXOtjb2MT1/8vPzh+MYk2OTQ7U3VRiJt+VxbmcxTPILp9kTWVbI4Y0LknF3MEiQRzagW0NWO1Fo9K9GrO1J/qOnFeji+brPdYzaUPd3WbFXfSM7ajLygsvSTGg21SyUJnN1wqwwOJ+fNfzI/iOd19Og0VAxPYDmFaVtJKfMRoPQL3xUJGTqFjh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E8TUXV2Z+Iy/l5SFjptFgvt4Is6aICKo5Z1r/ameU/WetxqP9IxwxGosQKSh0fQCYOZxUmjblVfsQj0M2fRD5ig== 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 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