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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC9AFC7EE2A for ; Tue, 2 May 2023 14:58:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234539AbjEBO6H (ORCPT ); Tue, 2 May 2023 10:58:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234522AbjEBO6D (ORCPT ); Tue, 2 May 2023 10:58:03 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30204210E for ; Tue, 2 May 2023 07:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683039434; 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=Xc4jVMrFEIZlA4y98rP50vEVhdXsloq8JE9RIRAee3nigY0L0IRLzgHfCLGfdQbyxOlQca qBK42ZaSbO8t8YX2wcdEghZJrQEu2TYymI0tXue1pCcL115XvcI9VkknzCoqEJKLGpty/K lF+oiGpeN4tRJJoBcm1sRmRiX8MmeeE= 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-310-VZAZvpXiM6qf0yh0NssFsQ-1; Tue, 02 May 2023 10:57:13 -0400 X-MC-Unique: VZAZvpXiM6qf0yh0NssFsQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-306311a2b99so724687f8f.1 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=S6hNKSAOz8fNvx+PlrV6+8hNaN8pop5KrL20KAb7gAno+kHkXeqQFdM2q+aGAG5Fop FJfyc01B4JPksxiCQP+SK6GCo37sQ3mL0BmzsMYCMNAuaL+hniav33QQxhxeoh09z1G2 qorWQV2Tyyq0xRS9uockbfGjkn++xULZn0Uzm/3L9pwOMQ8S86zOxbx+oMiBhz9+cq0y X/aNkw//m/81T0Muh0PG8uY1jGBOHbhh/XKnyVjoudjJkWeFoCb1tRe+QVWj05ngWXFA IW2ZziBM3J+JaxmMIFsYLKnX1iRxzkPN8ZguFSxDvPcs1Onf5w11MupHUuwwiaekYrBF fkOQ== X-Gm-Message-State: AC+VfDxnbHHcCBSVVEG+Pwr83ZcaPfwVl2fSUx+yFKnQcchF/t56vx1T 1RtSI257nIsPn9HBrgjRM6KXIsQ/U0gg6sDTO/wk/QeHcBfM2vl1FQpTFX/z3Cw6GwiC8qHe21S sCKaG+AdgBMWwyFUatwu3LxkosNjiZw== X-Received: by 2002:adf:e582:0:b0:306:3382:721d with SMTP id l2-20020adfe582000000b003063382721dmr3300004wrm.38.1683039431954; 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 Content-Language: en-US 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> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org 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