Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp961266lqj; Mon, 3 Jun 2024 06:23:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUj/OfBi/fdN+2ZseV4n2k00DkNufSZY/vNJebBZKVU+UPAMJo5rcwO0fE8gC2YQtC2E6rFe5x+tYOctHwKzyOsAl66xuk4K0sk6vtK8A== X-Google-Smtp-Source: AGHT+IEcutZF8X8YJLmv3G4/lEw5mP2+8XrRRU0kfkerok4V1L14FHWsnANbIuGQtlU9i1eqv5da X-Received: by 2002:a05:6e02:1524:b0:374:a477:5349 with SMTP id e9e14a558f8ab-374a47754b9mr10738635ab.13.1717421036814; Mon, 03 Jun 2024 06:23:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717421036; cv=pass; d=google.com; s=arc-20160816; b=zXng+HIZiNgqC7yfGd9A8sRfJj21db+kseRuJM6ljbwp7kW42F9v6T4I9baAYcYCOj LnvnNYKOqQM+cvWpc2tQLTwUTta4JlKDMtNUWyC7WO5Gis1zT1DCLLUSD2yh7JGVm6C+ uKlOksKWLbp7B5afobME2gH47/3Y/Y/lCd/vbGWEUsTCUgTMf4GFeup/d6ffBbFqzAeg VJWP/VyI44wpWE6/zcRMsaWgcazJTzQBZQ3ctA2JZ+8ufEaZnpYVZ2EjWemtUm6tJqEI xO/3tYajnrYzQ+DFzM1HcyM6jInTWkYl2q1btRdToBKf+CIsqJD5edcyyTyW41nEZ5MU Obew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=FsI4e2iwtiHdNnHZLApYOakz4g06pZw0cZuNFUyop4M=; fh=DNsuoCpOt4g06PoDig1gfLnNSqiOb3/ZPQWdm5N8aOg=; b=aQnXJXKZqAqnmgZCbP9rwGZIfL4ehio22dAzIGF4GfLHgkhPuINcya2J3YrB2Bhf1C H5TRP3VWZLnKwp9nLV4u9MOpKyeFgXIsWk//FIm6JVT0OY3L81zOyPN3RLT0rHHanaNM R8s1DkgIQiIqaA+tEWtHBon8k7OQOyp+PSBcVCvbhxzP9D7BFBr/I2hHX+PpnCOsS94V bpXexC4Ng8wOAqIWSV6ZkTHBddSFx50nrjI58GS0phCvJwdLAyzDoQh69JqcLVUsU1W6 6HGVQVcmnJA7S55c7ss0lC8icmVCU/Y1Wycp9jZYCq7U9ULltZkAsHREB7rnWl+sKhr/ 1SRQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WsDqaah7; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-199203-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35a0e6a6bsi6428478a12.422.2024.06.03.06.23.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 06:23:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199203-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WsDqaah7; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-199203-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199203-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6660D28127E for ; Mon, 3 Jun 2024 13:23:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5CD512D74E; Mon, 3 Jun 2024 13:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WsDqaah7" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF2DB59B4A for ; Mon, 3 Jun 2024 13:23:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717421030; cv=none; b=TfCGKCmlIBhXvo5q3bFVzzAaJvDE1mFWNhlN7MT9noz1hnEJWGRgLVUFDonRnHEBGGuHjY3RU901dqOZAlo1/NtofRAfij+HQFvO360rryZYaxeWGqz758kFhGRoOzQqN8OuUssIT5hi6d6FaG8uWRBoTFzQmkM3ET0ePwLI2SQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717421030; c=relaxed/simple; bh=0JmL6NQbUJ4ROho0N3kJCuCT4C0By7SeorqgtqCPtrc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=n6nzr2i17iUERzVX0/y8BHOpPGyBo2nji8PEpx+gDKS1xg65a/9Iq01J123C3zwL4uLVKglzc16lnXb6QdCgD6E1kYIWJqxxS3vc+yxnll5tDI40wHGRZ9J6c1HfrI0G/EbFe/+tagNKNyoRxc5otQ2TaFlxN05amxOP4ERKgWU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WsDqaah7; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1717421029; x=1748957029; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=0JmL6NQbUJ4ROho0N3kJCuCT4C0By7SeorqgtqCPtrc=; b=WsDqaah7zGj8bLKKmpUkJNUR+oY7L05e6FG/JiHpt76jxNOkYZYDhCtH Di9tsaGWWV0isZwPznkBU9lV4X2F/uKRnyoasOS9/JESXltPhCv9LjWOz k50sJ3HEVibMQRKFe/X6mQco5qlKdQz70y/g9LVCLbp6kZMRgZTsLCo2E z3C0XPRXmNtCI+L5CogneXyqYE1o8vslO1/ELcYc4enjEu6rW5Bnj0bOm ke9KypCzMSSEAqm37/BRhibsDxsi3lwv8isHnApGPlwFcRhZj5DsuReyk wpxQFTSPb4lYYCNNXTKGcud5TUFk8lL4V+ozk8+oRo+pK8qgl1Eu61bmG Q==; X-CSE-ConnectionGUID: CtXLqmGHS0+lOmUMdQZugA== X-CSE-MsgGUID: RGcrOKKcQHCrbYYEVUfHyQ== X-IronPort-AV: E=McAfee;i="6600,9927,11092"; a="25026032" X-IronPort-AV: E=Sophos;i="6.08,211,1712646000"; d="scan'208";a="25026032" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 06:23:48 -0700 X-CSE-ConnectionGUID: ihKcwV74SuS+DjxijYNvhQ== X-CSE-MsgGUID: p796QR5YQtGjH9FVPFI6tQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,211,1712646000"; d="scan'208";a="36956460" Received: from ibganev-desk.amr.corp.intel.com (HELO [10.125.108.143]) ([10.125.108.143]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2024 06:23:47 -0700 Message-ID: Date: Mon, 3 Jun 2024 06:23:46 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v11 09/12] mm: implement LUF(Lazy Unmap Flush) defering tlb flush when folios get unmapped To: Byungchul Park , David Hildenbrand Cc: Byungchul Park , linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com, akpm@linux-foundation.org, ying.huang@intel.com, vernhao@tencent.com, mgorman@techsingularity.net, hughd@google.com, willy@infradead.org, peterz@infradead.org, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, rjgolo@gmail.com References: <20240531092001.30428-1-byungchul@sk.com> <20240531092001.30428-10-byungchul@sk.com> <26dc4594-430b-483c-a26c-7e68bade74b0@redhat.com> <20240603093505.GA12549@system.software.com> From: Dave Hansen Content-Language: en-US Autocrypt: addr=dave.hansen@intel.com; keydata= xsFNBE6HMP0BEADIMA3XYkQfF3dwHlj58Yjsc4E5y5G67cfbt8dvaUq2fx1lR0K9h1bOI6fC oAiUXvGAOxPDsB/P6UEOISPpLl5IuYsSwAeZGkdQ5g6m1xq7AlDJQZddhr/1DC/nMVa/2BoY 2UnKuZuSBu7lgOE193+7Uks3416N2h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spZDFyfDjunimEhVHqlUt7ggR1Hsl/tkvTSze8pI1P6dGp2XW6AnH1iayn yRcoyT0ZJ+Zmm4xAH1zqKjWplzqdb/dO28qk0bPso8+1oPO8oDhLm1+tY+cOvufXkBTm+whm +AyNTjaCRt6aSMnA/QHVGSJ8grrTJCoACVNhnXg/R0g90g8iV8Q+IBZyDkG0tBThaDdw1B2l asInUTeb9EiVfL/Zjdg5VWiF9LL7iS+9hTeVdR09vThQ/DhVbCNxVk+DtyBHsjOKifrVsYep WpRGBIAu3bK8eXtyvrw1igWTNs2wazJ71+0z2jMzbclKAyRHKU9JdN6Hkkgr2nPb561yjcB8 sIq1pFXKyO+nKy6SZYxOvHxCcjk2fkw6UmPU6/j/nQlj2lfOAgNVKuDLothIxzi8pndB8Jju KktE5HJqUUMXePkAYIxEQ0mMc8Po7tuXdejgPMwgP7x65xtfEqI0RuzbUioFltsp1jUaRwQZ MTsCeQDdjpgHsj+P2ZDeEKCbma4m6Ez/YWs4+zDm1X8uZDkZcfQlD9NldbKDJEXLIjYWo1PH hYepSffIWPyvBMBTW2W5FRjJ4vLRrJSUoEfJuPQ3vW9Y73foyo/qFoURHO48AinGPZ7PC7TF vUaNOTjKedrqHkaOcqB185ahG2had0xnFsDPlx5y In-Reply-To: <20240603093505.GA12549@system.software.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 6/3/24 02:35, Byungchul Park wrote: ...> In luf's point of view, the points where the deferred flush should be > performed are simply: > > 1. when changing the vma maps, that might be luf'ed. > 2. when updating data of the pages, that might be luf'ed. It's simple, but the devil is in the details as always. > All we need to do is to indentify the points: > > 1. when changing the vma maps, that might be luf'ed. > > a) mmap and munmap e.i. fault handler or unmap_region(). > b) permission to writable e.i. mprotect or fault handler. > c) what I'm missing. I'd say it even more generally: anything that installs a PTE which is inconsistent with the original PTE. That, of course, includes writes. But it also includes crazy things that we do like uprobes. Take a look at __replace_page(). I think the page_vma_mapped_walk() checks plus the ptl keep LUF at bay there. But it needs some really thorough review. But the bigger concern is that, if there was a problem, I can't think of a systematic way to find it. > 2. when updating data of the pages, that might be luf'ed. > > a) updating files through vfs e.g. file_end_write(). > b) updating files through writable maps e.i. 1-a) or 1-b). > c) what I'm missing. Filesystems or block devices that change content without a "write" from the local system. Network filesystems and block devices come to mind. I honestly don't know what all the rules are around these, but they could certainly be troublesome. There appear to be some interactions for NFS between file locking and page cache flushing. But, stepping back ... I'd honestly be a lot more comfortable if there was even a debugging LUF mode that enforced a rule that said: 1. A LUF'd PTE can't be rewritten until after a luf_flush() occurs 2. A LUF'd page's position in the page cache can't be replaced until after a luf_flush() or *some* other independent set of rules that can tell us when something goes wrong. That uprobes code, for instance, seems like it will work. But I can also imagine writing it ten other ways where it would break when combined with LUF.