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 D87EBC77B7E for ; Tue, 2 May 2023 15:12:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 758EB6B0078; Tue, 2 May 2023 11:12:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 709896B007B; Tue, 2 May 2023 11:12:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 582C0900002; Tue, 2 May 2023 11:12:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by kanga.kvack.org (Postfix) with ESMTP id 37A066B0078 for ; Tue, 2 May 2023 11:12:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683040339; 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; bh=15zhWnNnUv6N+Qv+v/91mVtnb9crmK+0j2EjkR4cdzk=; b=DVCGcJpPM7j50svblyx6kSChtTjVGYXcbTKMiWeSm6XWy7FGZP8s+KRNdxHcgyAclaiIPJ GKIPIw4WQQ5fdwiNiYiQnWnOoMiyWsT5h15X7Ja6oGT82Zn/FAxl3uv90fQ74A9pv+Qzww EkXPjRKEOr4jDVyTjLBYWy7eBbPds54= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-65-zPMbB4-EOpmq8Be6eZjsAQ-1; Tue, 02 May 2023 10:57:13 -0400 X-MC-Unique: zPMbB4-EOpmq8Be6eZjsAQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-306281812d6so1061315f8f.2 for ; Tue, 02 May 2023 07:57:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683039432; x=1685631432; h=content-transfer-encoding:in-reply-to:organization: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=15zhWnNnUv6N+Qv+v/91mVtnb9crmK+0j2EjkR4cdzk=; b=JVbqu2VceIJ1b0OqIG4SwYSoZt2wdxpkBNwaAo8pI3n0qdpAL1EBHr/i/NFdty7+p9 oZf1oKXGPk8un+3mUdvUtSmrHjgqpqDHbJmEgsbaYx4p1Rw5jgIZM3sBhxHd+dbI9U4b z+2ab2QHiZbPzLWwU/QDZNRfzYHLGD+Vx0B/CDKKzeDZ98WlswBtwYeAfmcReM8Vz3Bq Hxq0gFHJOwlbQ/pHAgH/hNl9MO4meXU6C/mKYZYO9JpG3AlyB60yDKOfZehkK6bq3y8X gSh6GJptNm/jeoATamIwI3Jv9SVx0QR21x6aLVW9ge317jp7yvCBV+E7V1a/amuGj7av jydA== X-Gm-Message-State: AC+VfDy20upnA1BG0mZ7LE8mUM2XulL013WXqyTW1wc2R8PF51ivZYw7 B/zLCWYws8hYyQ/Zi1tn0UCsf22laIKRzue0Gd2v6dx7+c/+zUyHkDgiLkrc1F1jEwx6h86M1rz Z3z9PA92yDupGENKP5ls= X-Received: by 2002:adf:e582:0:b0:306:3382:721d with SMTP id l2-20020adfe582000000b003063382721dmr3299984wrm.38.1683039431952; Tue, 02 May 2023 07:57:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ475CGduIpgjlDxsGxpLL5lhRcGF08NepGsYJMzG5SoRIDtlUYjiVEpzVfjvt29SmQGLcE2OA== X-Received: by 2002:adf:e582:0:b0:306:3382:721d with SMTP id l2-20020adfe582000000b003063382721dmr3299967wrm.38.1683039431553; Tue, 02 May 2023 07:57:11 -0700 (PDT) Received: from ?IPV6:2003:cb:c700:2400:6b79:2aa:9602:7016? (p200300cbc70024006b7902aa96027016.dip0.t-ipconnect.de. [2003:cb:c700:2400:6b79:2aa:9602:7016]) by smtp.gmail.com with ESMTPSA id b10-20020a5d550a000000b0030639a86f9dsm1577608wrv.51.2023.05.02.07.57.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 May 2023 07:57:10 -0700 (PDT) Message-ID: <203a8ed7-47fa-0830-c691-71d00517fecb@redhat.com> Date: Tue, 2 May 2023 16:57:08 +0200 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 v6 3/3] mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings To: Matthew Rosato , Christian Borntraeger , Lorenzo Stoakes Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jason Gunthorpe , Jens Axboe , Matthew Wilcox , Dennis Dalessandro , Leon Romanovsky , Christian Benvenuti , Nelson Escobar , Bernard Metzler , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Bjorn Topel , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Brauner , Richard Cochran , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , linux-fsdevel@vger.kernel.org, linux-perf-users@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Oleg Nesterov , Jason Gunthorpe , John Hubbard , Jan Kara , "Kirill A . Shutemov" , Pavel Begunkov , Mika Penttila , Dave Chinner , Theodore Ts'o , Peter Xu References: <7d56b424-ba79-4b21-b02c-c89705533852@lucifer.local> <651bfe55-6e2a-0337-d755-c8d606f5317e@linux.ibm.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <651bfe55-6e2a-0337-d755-c8d606f5317e@linux.ibm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 02.05.23 15:35, Matthew Rosato wrote: > On 5/2/23 9:04 AM, Christian Borntraeger wrote: >> >> >> Am 02.05.23 um 14:54 schrieb Lorenzo Stoakes: >>> On Tue, May 02, 2023 at 02:46:28PM +0200, Christian Borntraeger wrote: >>>> Am 02.05.23 um 01:11 schrieb Lorenzo Stoakes: >>>>> Writing to file-backed dirty-tracked mappings via GUP is inherently broken >>>>> as we cannot rule out folios being cleaned and then a GUP user writing to >>>>> them again and possibly marking them dirty unexpectedly. >>>>> >>>>> This is especially egregious for long-term mappings (as indicated by the >>>>> use of the FOLL_LONGTERM flag), so we disallow this case in GUP-fast as >>>>> we have already done in the slow path. >>>> >>>> Hmm, does this interfer with KVM on s390 and PCI interpretion of interrupt delivery? >>>> It would no longer work with file backed memory, correct? >>>> >>>> See >>>> arch/s390/kvm/pci.c >>>> >>>> kvm_s390_pci_aif_enable >>>> which does have >>>> FOLL_WRITE | FOLL_LONGTERM >>>> to >>>> >>> >>> Does this memory map a dirty-tracked file? It's kind of hard to dig into where >>> the address originates from without going through a ton of code. In worst case >>> if the fast code doesn't find a whitelist it'll fall back to slow path which >>> explicitly checks for dirty-tracked filesystem. >> >> It does pin from whatever QEMU uses as backing for the guest. >>> >>> We can reintroduce a flag to permit exceptions if this is really broken, are you >>> able to test? I don't have an s390 sat around :) >> >> Matt (Rosato on cc) probably can. In the end, it would mean having >>   >>     >>   >> >> In libvirt I guess. > > I am running with this series applied using a QEMU guest with memory-backend-file (using the above libvirt snippet) for a few different PCI device types and AEN forwarding (e.g. what is setup in kvm_s390_pci_aif_enable) is still working. > That's ... unexpected. :) Either this series doesn't work as expected or you end up using a filesystem that is still compatible. But I guess most applicable filesystems (ext4, btrfs, xfs) all have a page_mkwrite callback and should, therefore, disallow long-term pinning with this series. -- Thanks, David / dhildenb