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 C3EA9C3ABBE for ; Thu, 8 May 2025 15:37:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E259E6B0096; Thu, 8 May 2025 11:37:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD2FC6B0098; Thu, 8 May 2025 11:37:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4BEA6B0099; Thu, 8 May 2025 11:37:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A7E686B0096 for ; Thu, 8 May 2025 11:37:15 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AB2081CD3A9 for ; Thu, 8 May 2025 15:37:15 +0000 (UTC) X-FDA: 83420144430.27.64DA5C5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 354A6180016 for ; Thu, 8 May 2025 15:37:13 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="D/8QzFP0"; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746718633; a=rsa-sha256; cv=none; b=T2nNQc8aKFyJMt5OzjbT1l6DC0NWPjeU8NQ6IJeQZyaRnGiiCg36gUC2ArAfhVPdaelsQc 2HL+7ERiiQhVb5PfhZn209vJxUOoOcod8jfJ2lkx0YycNAuyAeeNB981cAb/spiIPZxooK 7vFzkVJA7nKX95SkDK7exgHMvMqUpS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1746718633; 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=WqIleyRWbBE6fAeA2+kL12j5GghozmhjBuwTBWLQVFQ=; b=O0Qr58LtpVUQdQrC8FAEYm/w26+erscvKKpko5oZY+AMcxTMdLClCwmjIy7+ctfH2oOIX6 O4VfRpRT9f8V94apmOygFOC1su12pdu8leXB+HixW1FG0RiNFaNw4vQrxnQ7sZPnUEXXMR yez/iCDdtzNW1ptIxcDjQ+DMjItOwgY= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="D/8QzFP0"; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1746718632; h=from:from: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:autocrypt:autocrypt; bh=WqIleyRWbBE6fAeA2+kL12j5GghozmhjBuwTBWLQVFQ=; b=D/8QzFP0l6v01EKEj8k70oFAsNCUuvpoOwWtJVz2M5JBeZTwkaIHFIU6qjhVhBJrYS54iL FiN1rKk57EkAYLihZvxK6I1QpO53t+fJMtE6JXAjgDMbhUJBXY+vjp79f6SzeZS4e5iroj zbwtqnveA9bA0rn0QzYRiwtrC9eRHBA= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-74-foWRqCIgNpu-LoXAxqHr0A-1; Thu, 08 May 2025 11:37:09 -0400 X-MC-Unique: foWRqCIgNpu-LoXAxqHr0A-1 X-Mimecast-MFC-AGG-ID: foWRqCIgNpu-LoXAxqHr0A_1746718626 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-43efa869b19so7346085e9.2 for ; Thu, 08 May 2025 08:37:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746718626; x=1747323426; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=WqIleyRWbBE6fAeA2+kL12j5GghozmhjBuwTBWLQVFQ=; b=XxT+rXGTyhIJecULXBNhpD3XWdcpLqsDq+gBbliemJjH9wbgWrxS8EQiyWdxwYQBMZ EklI8XMWvy8rCP98SBZ4gGQmcfGVUf4NWBV/c2Ky+znU/9x5QV24Lff8Z/8qR2wPjq3L 7rt29+WfVkN4ahbA+QR/ZEaWZl6TpjAddZItVfsy5D4QNkquwFszZN/zE5VtpSwYStsh v5gGlgiGTcofDGJ3pGV+qhGtGwYxDE67nGXrhjE5hXrAGMfegpNPBzJ+XbYPByD5VN1c L+mnFLD30EPXGtdV17prS6GadxEa3jXhg2ratFwyehfTnMANWUO3zN8TJFqeGreWijGZ pX7A== X-Forwarded-Encrypted: i=1; AJvYcCXTJo5Nb9A09mGmZFprPMeQMxgDrJ+UCsgxqnjsXFN+Gdp9D3zIuNUXUJkTg66YANohJDnE7/2IrQ==@kvack.org X-Gm-Message-State: AOJu0Yyt9FBlNvuEHa7YZjwparSPPFppHgPnKKUwzSey2nq+Cy47m9kO yrT6HFAq75TmhQ2365Jb9kuxXdOudqo/kUsEgFl2mzsdQYkb8FemWY1cir+eFD23PcK7qXUbNJ2 1nYQ0EKJNUsFGhkKk0Hl4TWseItx6OD7id/oGRfeoERVDWLjk X-Gm-Gg: ASbGnctlj7SAoMe9W4gENIOG6F9Uwh/jCHkTNdESOvDgaTbz87ZjyT7WWUQCe6lGUji /kevz/wZvfZM85qnia+LjsCjZmXkPWEmfwhgEUF+SvGmsWWc3TqiBKnMQOfPoGvXoCAutZbJJw9 zE39hA1FPqVmoSC96sA/TY2J/NkumHnI7Lo8//Fv18J+rBYkSiLi6YZVofY+uujyVUiz7VzK+Px NeYzT3wwWaCMcgMXYESMYHTuUuRbVbCDgacOehJIj2o0NqHF33gfVRiTnobMfFQtkYkvneNu7VW sLk0kNmnUdY/xnooNVOKCwdu1et+P88EaYqTrXhp9OjiOa2R1U7x+SxxplEY/bosQEe6EiqkuWE MmznyLdWKe1UAh/g9xoQm4roChfgCQTU8sRh6VQ0= X-Received: by 2002:a05:600c:1e1c:b0:43d:300f:fa4a with SMTP id 5b1f17b1804b1-441d44c4f9cmr77168685e9.12.1746718626064; Thu, 08 May 2025 08:37:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8+Z0hrydt/sNvRj0RjbhS2hsfzsEiHQI1YRNtaN1N6XVBPHA0SaOTi3RMMG6pXTHWtjJ1RA== X-Received: by 2002:a05:600c:1e1c:b0:43d:300f:fa4a with SMTP id 5b1f17b1804b1-441d44c4f9cmr77168355e9.12.1746718625656; Thu, 08 May 2025 08:37:05 -0700 (PDT) Received: from ?IPV6:2003:d8:2f3e:5900:27aa:5f4a:b65c:3d3c? (p200300d82f3e590027aa5f4ab65c3d3c.dip0.t-ipconnect.de. [2003:d8:2f3e:5900:27aa:5f4a:b65c:3d3c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-442cd32b0c8sm41504345e9.3.2025.05.08.08.37.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 May 2025 08:37:05 -0700 (PDT) Message-ID: Date: Thu, 8 May 2025 17:37:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] Fix zero copy I/O on __get_user_pages allocated pages To: Pantelis Antoniou Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Artem Krupotkin , Charles Briere , Wade Farnsworth , Peter Xu References: <20250507154105.763088-1-p.antoniou@partner.samsung.com> <20250507154105.763088-2-p.antoniou@partner.samsung.com> <99ed92b7-c1b2-4e12-a7ee-776a7f890b47@redhat.com> <20250508182356.45dbfd40@sarc.samsung.com> From: David Hildenbrand Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9 PXFNNgV5jXMQRwU0O/ztJIQqsE5LsUomE//bLwzj9IVsaQpKDqW6TAPjcdBDPLHvriq7kGjt WhVhdl0qEYB8lkBEU7V2Yb+SYhmhpDrti9Fq1EsmhiHSkxJcGREoMK/63r9WLZYI3+4W2rAc UucZa4OT27U5ZISjNg3Ev0rxU5UH2/pT4wJCfxwocmqaRr6UYmrtZmND89X0KigoFD/XSeVv jwBRNjPAubK9/k5NoRrYqztM9W6sJqrH8+UWZ1Idd/DdmogJh0gNC0+N42Za9yBRURfIdKSb B3JfpUqcWwE7vUaYrHG1nw54pLUoPG6sAA7Mehl3nd4pZUALHwARAQABzSREYX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GluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20250508182356.45dbfd40@sarc.samsung.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: N6wNSlWB33MwjNvvaWmnE_-sw7GiHGWZva0EldD9z2w_1746718626 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 354A6180016 X-Stat-Signature: 5n83zexpwt8f9n9sbxuj7xkeanxf4xz1 X-Rspam-User: X-HE-Tag: 1746718633-655441 X-HE-Meta: U2FsdGVkX1+G3mdSZj5IX9Pg/PpRJyRKfDxbdnrHdOb1IW2qSMUHqLnVNidjrZxGGYue2rsT56ZLPUeU/avDZwUmdDauZQGiXGPtgJknrPPVlvvwe7aR7ih+eeGYwyp1F7FxA9kbVvkRA2oo/j5hedDaonEaqWa2IVLwKi3DQeT0OsNcWoXX06r/3Giey/KRSCRJZDXAfB1wwCwYegsJclUwg5YK5EEC2mc4d/NbpU+oB+ah3ZS/ejKEVS+Kq2csxrM/EyfdTo8sG1Fi0OMNBjl1EEyguvTW5vP51mlgMqd4u8bTzhq0uTf8HDpNTiZaI0G/uBgZQr0j6N5EnGi588VuRRD7k/5/+Ncs3idBlqVDx9pykGrhwYXYYvlA7SE/o2T4GK6DvG+JznV7UGpEq+b3lVX5D4uo1px8yX55SXr9FYusXc3oETmg7hGNjSeZkdjh7hdn3NM6Kw9ijC+PhHDgYrVxXkYyIX2qzEzWN/bq6ahZnzQIBMmO9491jZCfT/kyQxr4Qh/VZHP5nZ15wEwC7A1gZ4PJo7K3t2xlOyb+LLpUK5TDZp+q6rCThyCnmf1ljVam7gD7bRLzfCd+zNjHrJLSDCKYipRMs8Itrp6axxXTbbFA+MCrQDaaDTS345ZJKtz/Q0VLslPIJAgt2MJazvqGGxa3EnmwAm8C6olVgqwHjt/EZ6kmAvq511wijwsYS0deBz16j1UgX6p/MK5fKi0QAqeoEzvCsYeSxykRiUxAQkSaLwi700w1dK2G6sEnlWAPtTB+HgOB70IhDiXe3q0f40BWQIOaBNfM1vbjiYRObJjlsTkK5zQMdqpk86KYj1z544YE7tqevQcRTqOLh8JPgmce+HwXyqrN0wchBRZlD878Z51DujI5vfUHSCox+MxShBdwEkIl4IFCnjE77xLOVZgZ0wlUmSgmuEfVa84TNp9auEACRHHYjbhp2MSOXUAGGNlyQ9CLUuO uuR0gtOO bzY/o++eZDmv9wiRrvoOqh1GKq4nTG3w96Aq+vir7EiqN9t0762pR1XUy6ASIWXVG3S2pClF/OaTSvmmUTNT8vmk5X1m7lzq+xN7rTFHaOhqmj2r2Fe0RZi1urUnsBFpmYPTVuehdECRzwG2Le/CTtHKWtvwspXYXsSqi5xUIshhJHcARpCpBlLIyz0LQD87JJGGVQNkB6AuxVuKF4hH+WMWimrzlGX32dJ4iY+XFTAHWTy3mqbdWYVwUVceozbYIoNi5gpT4PssYy39XqaP828xejuJfvy8RCfn4xQymYPqhnveiy7dXwl3mJWFoZmLrFC29FPhBhgW105PztxMiuO/VQAXgShcBWFjvx1BHPyapdLy97ytS3p+WFTbAr14l4N53I60mQkM3/0aETKSxH40SM5Mk+zQwO03buOOsC3lZVEWj8ST6mWK6Mb3dnj4XJcjEyhkbNCblh0qpJgYMZ2cIJddHhnwRSMR0nHiaAJtj39yF0hMIuItkck85I2VxFDp1qdWmsxQUfIU= 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: List-Subscribe: List-Unsubscribe: On 08.05.25 17:23, Pantelis Antoniou wrote: > On Thu, 8 May 2025 17:03:46 +0200 > David Hildenbrand wrote: > > Hi there, > >> On 07. 05. 25 17: 41, Pantelis Antoniou wrote: Hi, > Recent updates >> to net filesystems enabled zero copy operations, > which require >> getting a user space page pinned. > > This does not work for pages >> that were allocated via __get_user_pages >> On 07.05.25 17:41, Pantelis Antoniou wrote: >> >> Hi, >> >>> Recent updates to net filesystems enabled zero copy operations, >>> which require getting a user space page pinned. >>> >>> This does not work for pages that were allocated via >>> __get_user_pages and then mapped to user-space via remap_pfn_rage. >> >> Right. Because the struct page of a VM_PFNMAP *must not be touched*. >> It has to be treated like it doesn't exist. >> > > Well, that's not exactly the case. For pages mapped to user space via > remap_pfn_range() the VM_PFNMAP bit is set even though the pages do > have a struct page. Yes. And VM_PFNMAP is the big flag that these pages shall not be touched. Even if it exists. Even if you say please. :) See the comment above vm_normal_page(): "Special" mappings do not wish to be associated with a "struct page" (either it doesn't exist, or it exists but they don't want to touch it) VM_MIXEDMAP could maybe be used for that purpose: possibly GUP also has to be updated to make use of that. (I was hoping we can get rid of VM_MIXEDMAP at some point) > > The details of how it happens are at the cover page of this patch but > let me paste the relevant bits here. > > "In our emulation environment we have noticed failing writes when > performing I/O from a userspace mapped DRM GEM buffer object. > The platform does not use VRAM, all graphics memory is regular DRAM > memory, allocated via __get_free_pages > > The same write was successful from a heap allocated bounce buffer. > > The sequence of events is as follows. > > 1. A BO (Buffer Object) is created, and it's backing memory is allocated via > __get_user_pages() __get_user_pages() only allocates memory via page faults. Are you sure you meant __get_user_pages() here? > > 2. Userspace mmaps a BO (Buffer Object) via a mmap call on the opened > file handle of a DRM driver. The mapping is done via the > drm_gem_mmap_obj() call. > > 3. Userspace issues a write to a file copying the contents of the BO. > > 3a. If the file is located on regular filesystem (like ext4), the write > completes successfully. > > 3b. If the file is located on a network filesystem, like 9p the write fails. > > The write fails because v9fs_file_write_iter() will call > netfs_unbuffered_write_iter(), netfs_unbuffered_write_iter_locked() which will > call netfs_extract_user_iter() > > netfs_extract_user_iter() will in turn call iov_iter_extract_pages() which for > a user backed iterator will call iov_iter_extract_user_pages which will call > pin_user_pages_fast() which finally will call __gup_longterm_locked(). > > __gup_longterm_locked() will call __get_user_pages_locked() which will fail > because the VMA is marked with the VM_IO and VM_PFNMAP flags." So, drm_gem_mmap_obj() ends up using remap_pfn_rage()? I can spot that drm_gem_mmap_obj() has a path where it explicitly sets vm_flags_set(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP); Which is a clear sign to core-MM (incl. GUP) to never mess with the mapped pages. > >>> >>> remap_pfn_range_internal() will turn on VM_IO | VM_PFNMAP vma bits. >>> VM_PFNMAP in particular mark the pages as not having struct_page >>> associated with them, which is not the case for __get_user_pages() >>> >>> This in turn makes any attempt to lock a page fail, and breaking >>> I/O from that address range. >>> >>> This patch address it by special casing pages in those VMAs and not >>> calling vm_normal_page() for them. >>> >>> Signed-off-by: Pantelis Antoniou >>> --- >>> mm/gup.c | 22 ++++++++++++++++++---- >>> 1 file changed, 18 insertions(+), 4 deletions(-) >>> >>> diff --git a/mm/gup.c b/mm/gup.c >>> index 84461d384ae2..e185c18c0c81 100644 >>> --- a/mm/gup.c >>> +++ b/mm/gup.c >>> @@ -833,6 +833,20 @@ static inline bool can_follow_write_pte(pte_t >>> pte, struct page *page, return !userfaultfd_pte_wp(vma, pte); >>> } >>> >>> +static struct page *gup_normal_page(struct vm_area_struct *vma, >>> + unsigned long address, pte_t pte) >>> +{ >>> + unsigned long pfn; >>> + >>> + if (vma->vm_flags & (VM_MIXEDMAP | VM_PFNMAP)) { >>> + pfn = pte_pfn(pte); >>> + if (!pfn_valid(pfn) || is_zero_pfn(pfn) || pfn > >>> highest_memmap_pfn) >>> + return NULL; >>> + return pfn_to_page(pfn); >>> + } >>> + return vm_normal_page(vma, address, pte); >> >> I enjoy seeing vm_normal_page() checks in GUP code. >> >> I don't enjoy seeing what you added before that :) >> >> If vm_normal_page() tells you "this is not a normal", then we should >> not touch it. There is one exception: the shared zeropage. >> >> >> So, unfortunately, this is wrong. >> > > Well, lets talk about a proper fix then for the previously mentioned > user-space regression. You really have to find out the responsible commit. GUP has been behaving like that forever I'm afraid. And even the VM_PFNMAP was in drm_gem_mmap_obj() already at least in 2012 if I am not wrong. -- Cheers, David / dhildenb