Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6698636rwr; Tue, 2 May 2023 04:26:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ56t/uIL2/b8apUIsHOuIiXFGSskmT3gkXA4Dzf8CisqghPIiu9W9Pv6y8byiYTc7OAf6QH X-Received: by 2002:a05:6a21:33a8:b0:d9:b024:4824 with SMTP id yy40-20020a056a2133a800b000d9b0244824mr23181546pzb.26.1683026776357; Tue, 02 May 2023 04:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683026776; cv=none; d=google.com; s=arc-20160816; b=x98QmbQDRYR2ZlCWtTydsUukMaQpnlXFw4MszbRUxAYqLuKRdRfdllZLr5shUqtLCn vMWOjPQn956uBEYxTk2WSCPus/76pF3wKNfwa3CblPAnhVOfsoh0IPDFBWvMQIxpxDGx WJdwtZppLBFi8dwbqDCpx6tDM4ALhu2erj7Db5fguZ34e5PkWbQmu+6GZaq5zWHHAx1T 5W9/Amrl3Q/KS28T/oxkNXoRGTLxZ22sbsq6mAILSVpMBeAr+41fX2iD2/zXH5WGcWHk KP2jDpxbpUhW+YgStBHdxW68cvda9nnhFTMJMsvO1ech8EhO7W19jWsIWmwH941lCJaI N4iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=auMKjFCZlAomyDKk7xnRROZ2Twge8AIH71DokXSPSjQ=; b=F2CH9GZFDnqrBYHmdlSgTkLOhGzHOx2IyPidkCVrr+CIgHZmsMgC2qFVfKmGM9B/bh JJj5RlPlz3TBWHHR5GP0nalJQEkwhDZAkGFMniD/4Lpl70Utkx4xErUgV7gLAaqsj035 ryt3a8zImuvz+H15VkZOIITvi4PKCuXJhAbaVkkTpNjOuljyF46XNHLckH5PTkdNN+Zy dD/2EQ0Dxni46YKmrF96+NzLwvlWYXoYt5ehwxIP+TxO5lVZH/aetBLgaj7C37X3CooK GDSSWHKtjGJVZiiWVKVD7A8bUTMBZ/JPKQE6UlSuJnzZLeAqqY0UEWfdYO1stIeEZANy cHNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=yDVZEbii; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=vlJ+ISc1; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020a6552cb000000b0051942a23eefsi30116194pgp.533.2023.05.02.04.26.02; Tue, 02 May 2023 04:26:16 -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=@suse.cz header.s=susede2_rsa header.b=yDVZEbii; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=vlJ+ISc1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233933AbjEBLX7 (ORCPT + 99 others); Tue, 2 May 2023 07:23:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233548AbjEBLX6 (ORCPT ); Tue, 2 May 2023 07:23:58 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 259801FDB; Tue, 2 May 2023 04:23:57 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CC26221D09; Tue, 2 May 2023 11:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1683026635; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=auMKjFCZlAomyDKk7xnRROZ2Twge8AIH71DokXSPSjQ=; b=yDVZEbiiKxDBys2VplkjOJE5soUzLmDaeNBafVUAWaWwTSf/XXaJ+Zd5/un54dtk0vtleb z75+VYNYttuBHYfV8xrjFbBG6D8v1hltNrPmlFUiT8sjlBi+CY/j9+QjjtHawuDJ4jZus9 YjTg6JKDcs6YZHWR/VA7BAOF40ws0hg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1683026635; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=auMKjFCZlAomyDKk7xnRROZ2Twge8AIH71DokXSPSjQ=; b=vlJ+ISc1zUTFBDEuIMzGfidUwuB/hxcA/r7oslsic0I9dKZoBi2WfdSZ8Ly/xfYA8bkfJw ALbmGkc8a0ixEOBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AD0F4134FB; Tue, 2 May 2023 11:23:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id xdLSKcvyUGT/FQAAMHmgww (envelope-from ); Tue, 02 May 2023 11:23:55 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 24A0EA0735; Tue, 2 May 2023 13:23:55 +0200 (CEST) Date: Tue, 2 May 2023 13:23:55 +0200 From: Jan Kara To: Peter Zijlstra Cc: Lorenzo Stoakes , 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 , 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 , David Hildenbrand , Dave Chinner , Theodore Ts'o , Peter Xu Subject: Re: [PATCH v6 3/3] mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings Message-ID: <20230502112355.x5lgcy75lh4mjo66@quack3> References: <20230502111334.GP1597476@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230502111334.GP1597476@hirez.programming.kicks-ass.net> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue 02-05-23 13:13:34, Peter Zijlstra wrote: > On Tue, May 02, 2023 at 12:11:49AM +0100, Lorenzo Stoakes wrote: > > + > > + /* > > + * Neither anonymous nor shmem-backed folios require > > + * dirty tracking. > > + */ > > + ret = folio_test_anon(folio) || > > + (mapping && shmem_mapping(mapping)); > > + } else { > > + /* If the mapping is unstable, fallback to the slow path. */ > > + ret = false; > > + } > > + > > + unlock_rcu(); > > + > > + return ret; > > then becomes: > > > if (folio_test_anon(folio)) > return true; > > /* > * Having IRQs disabled (as per GUP-fast) also inhibits RCU > * grace periods from making progress, IOW. they imply > * rcu_read_lock(). > */ > lockdep_assert_irqs_disabled(); > > /* > * Inodes and thus address_space are RCU freed and thus safe to > * access at this point. > */ > mapping = folio_mapping(folio); > if (mapping && shmem_mapping(mapping)) > return true; > > return false; Yeah, that's even better. Honza -- Jan Kara SUSE Labs, CR