Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6989736rwr; Tue, 2 May 2023 08:06:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ59t3w0sNSoSTs/lAK57x1IAkMqeySnfP/3dYww5GDubHJF6MelbobQHJ/no5gpLtKhEp02 X-Received: by 2002:a05:6a00:2344:b0:637:3234:4e22 with SMTP id j4-20020a056a00234400b0063732344e22mr24022555pfj.23.1683039990445; Tue, 02 May 2023 08:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683039990; cv=none; d=google.com; s=arc-20160816; b=JNw+gQU/as6gtCb5qciAtLAxaAc2j1MRT8+rVrYrly1dB6I9/eIyjwZtVO5O04gYID eCeff57hWdmklBg4NG3ZawIdoBeHINS7I9qXBRdN99Ng4t0cwBWAbrfasvc7NdO0yy1s mX2dA60BR0LgA/yVKhdB0LjygoZc3xyWAQjXoygUehMUYPSTPWa2brsyRKuglb2sZ0W2 pvCXj1IdZ0HUzYaAp+3GKLXxB9+D4Dm7SALiqNTQj4olt0A93UtR7Bz78DdeEDoFORJz EDlwI9qa8MZbLzYvpAVOk7ogSmDIjJM7PcJqoD8k7cq/j8tqO7sX32W6Vpii8r+qNzYK Q30A== 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 :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=15zhWnNnUv6N+Qv+v/91mVtnb9crmK+0j2EjkR4cdzk=; b=tOwA6WB7BvDRuiTG+cu2lkE3ap11vqw+pSbiqL9lQpHmbGITNMia8rmsYRBbLDGXLN +v3Dwml2YQcVuI8h2pKHWp9CD9tuz8zJe9jlBjcvi2/RBKGCTc3TYnr/FraFYwBoNV1H udiqh6SIY/9tR/HQJ5RLd87lqior2YVyG5D3g2yDWxiAUJ0aLUMP2y2zfqCSeDsu0bZf fQIYDVg7pRf76J+Uy49gUCvCyQCT1ab7P1fpsqHEm73mpn9xWx4ndmbHaQ9xqgYYJm5L Jty+VVVHDowqrgmha49ygRasgRufj5DU363qD/XEReMvMTcaMPyNxfTEMafaA0iHCJs2 LWEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EOZPCe4z; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a056a00008600b0063b82c0941fsi30625822pfj.36.2023.05.02.08.06.11; Tue, 02 May 2023 08:06:30 -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=@redhat.com header.s=mimecast20190719 header.b=EOZPCe4z; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234535AbjEBO6G (ORCPT + 99 others); Tue, 2 May 2023 10:58:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234420AbjEBO6B (ORCPT ); Tue, 2 May 2023 10:58:01 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9A6F211B 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=1683039435; 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=EOZPCe4z+PR2OtZGJPDDjuF9tYzT/6gT4q5AWorn6EwUKMQPZnCqOju8Uv0tGviUUSdg4B Zj2cI5vPY4/g4ERikv+E66vfyI8d/dOktj3exIVY6knHvtePqA7buMqa5rEjdDPrnxWM7w AJzPP0bk0JX0w73bEdYqDgt5vq14VVg= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-Hzx1m1IIPKyGQ0b9a7guQQ-1; Tue, 02 May 2023 10:57:14 -0400 X-MC-Unique: Hzx1m1IIPKyGQ0b9a7guQQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3062e5d0cd3so806231f8f.3 for ; Tue, 02 May 2023 07:57:12 -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=Ypg4GdQ0gvuTNNB59dO0lJlHjerzFlPnYWtskqoR3mC5g5YVdXXT5xExF9vzosJtrb MdXKPaQ7fO1ct7qH0jQZR6u7NLnaiigzS62Mwjwr/48R5NP+NUgdKJ94heATHX4Ie8d8 kXfEEz+PNQFwxf1+b+8CLFYZdgHFlYdPzrhP5dbuOEdj9nQUjHG7kdShjVissgQLJumP QtYVN6WJ6IQkd/PZ+QR4g2AjbabZO3+0iLfZ3ksAPVnWn20ngos24pyqs8pvLLoL1DOe 5+H2ZS6OQjN3IuTWhNSBB8htoHA3espDbnvAtuZawiuXthNsDCvoQu9J4JPCo/56ViYR Ky1A== X-Gm-Message-State: AC+VfDw7qbwhYoHNSBGas+FZGRhrwoZu/LZYEPoYUEgaELgGkr6ACxs/ pX2RTyGCoefyz8jrONCclj/1OYEgFF2flFHdKYS81aallSEq4EJrlKL0yHQgDM8tkJh+mueU+s5 iS6WhFoQ6UhL3U7+j8bMmh64C X-Received: by 2002:adf:e582:0:b0:306:3382:721d with SMTP id l2-20020adfe582000000b003063382721dmr3299985wrm.38.1683039431952; Tue, 02 May 2023 07:57:11 -0700 (PDT) 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 X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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