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 5CDFAC77B73 for ; Tue, 2 May 2023 15:20:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED0C86B0078; Tue, 2 May 2023 11:20:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E7F5B6B007E; Tue, 2 May 2023 11:20:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D47AD6B007B; Tue, 2 May 2023 11:20:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by kanga.kvack.org (Postfix) with ESMTP id B25CB6B0074 for ; Tue, 2 May 2023 11:20:03 -0400 (EDT) Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 342FEhe5029367; Tue, 2 May 2023 15:19:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=V/GvdVySfSsWA0N3QEeFl+4m6R54hVIWKrdbC5AyEtQ=; b=eRrNF8+aSndfvKzim1IA2567TNN4PpHVuphKquobKmSvlroUjM7048+5Y8jbLSNSWK46 cpL2EXnV/pHaCV7fOABe79Aa8ACUKi7CA6FMISKNF7vIcwmGlevnoD7lGkLwHryRoTqW AR/jvm2MFm2dFzHB8ft/Wbl5dVRwRSgDl+zq/7oPSJxNlsNmeVVsfBHLct8c/s2qeHck xQRDH3qs7gbcotfqdHY8uCZXzGKR+7W8BNRt6ab2R8ceuv9uDxXhyiAuRtBK0OGrcvLP ccYFfpC50AMS5iQw+uKtHhmsrAxCZqmqpFQ9q2eRx/NHagCOwtcZ4Mz3UiqOzdmDPrdP nQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qb50205du-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 May 2023 15:19:38 +0000 Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 342FGRkn006394; Tue, 2 May 2023 15:19:37 GMT Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qb50205cv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 May 2023 15:19:37 +0000 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 342DhqET006796; Tue, 2 May 2023 15:19:36 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([9.208.129.117]) by ppma04dal.us.ibm.com (PPS) with ESMTPS id 3q8tv83xjg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 May 2023 15:19:36 +0000 Received: from smtpav06.wdc07v.mail.ibm.com (smtpav06.wdc07v.mail.ibm.com [10.39.53.233]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 342FJW6529032994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 May 2023 15:19:32 GMT Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E7C558056; Tue, 2 May 2023 15:19:32 +0000 (GMT) Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 113ED58054; Tue, 2 May 2023 15:19:27 +0000 (GMT) Received: from [9.60.89.243] (unknown [9.60.89.243]) by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 2 May 2023 15:19:26 +0000 (GMT) Message-ID: Date: Tue, 2 May 2023 11:19:26 -0400 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: David Hildenbrand , 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> <203a8ed7-47fa-0830-c691-71d00517fecb@redhat.com> From: Matthew Rosato In-Reply-To: <203a8ed7-47fa-0830-c691-71d00517fecb@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vnnCp1okX_g5G3U1ACKbZ-SlmxtBdROZ X-Proofpoint-ORIG-GUID: vBc3zQ3EyUW2J7HM9dD9YpTFTVq8PZA8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-02_09,2023-04-27_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305020128 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 5/2/23 10:57 AM, David Hildenbrand wrote: > 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. > The memory backend file is on ext4 in my tests. A quick trace shows that pin_user_pages_fast(FOLL_WRITE | FOLL_LONGTERM) in kvm_s390_pci_aif_enable is still returning positive implying pages are being pinned.