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 E1F12C54EBE for ; Mon, 16 Jan 2023 12:34:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D0C56B0071; Mon, 16 Jan 2023 07:34:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3806E6B0072; Mon, 16 Jan 2023 07:34:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2484D6B0073; Mon, 16 Jan 2023 07:34:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 110746B0071 for ; Mon, 16 Jan 2023 07:34:11 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D7342A0751 for ; Mon, 16 Jan 2023 12:34:10 +0000 (UTC) X-FDA: 80360604660.26.82CA566 Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by imf27.hostedemail.com (Postfix) with ESMTP id CAD5A4000C for ; Mon, 16 Jan 2023 12:34:07 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm1 header.b=eaCUJLCb; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=itIuCA2a; spf=pass (imf27.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.19 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673872448; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VUDr8cpDb6H5GOfkB07vTgHvt+AyLkABhj5WKeHRWOI=; b=HNBoBe/VwwRYC2NjWARYTBtdsj7SmjwFmaX5kQeyZP1LB1Kf0IuRcyKMN7BT27SOi5NzKa mbAbKuf3IYqMNmFPc40dpuPDDXfKiE/UpS3jqfhOCT4/f+vfhbjdwU2yCNMoUtSud1K0L8 oBsrvl5BYnOD9GrX6xalfLo/EbXwXP8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm1 header.b=eaCUJLCb; dkim=pass header.d=messagingengine.com header.s=fm3 header.b=itIuCA2a; spf=pass (imf27.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.19 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673872448; a=rsa-sha256; cv=none; b=m7TOkNHbYrgGV0C7cAaRdd7NLpFfxOaud/FWb14NSaPxrOPx19wQO/iog4NL+NB4bzq4MH exkeyWkVgucVG03TPHuSV7XDdyU2mGmm8EbJDZCn7j5mU5bXgqpowlomQ2iId8Y7ryLj+B X/pjCbVDCVAd3bPPpDdy2vwI3uTw9bs= Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id BD37E32002D8; Mon, 16 Jan 2023 07:34:05 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 16 Jan 2023 07:34:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1673872445; x=1673958845; bh=VU Dr8cpDb6H5GOfkB07vTgHvt+AyLkABhj5WKeHRWOI=; b=eaCUJLCbqY7U95iVyK Cw7AQCMwjzTi+UuBbeNUvKgFvo58VbOdSEZ4W9AsMINRv3UBMW+e8JPKWxL7y1l6 G2mRaVYcIXM61R8WfT/PuXTAfzVnD3gJmo8xpARon9AYMSBfQi1BircwitNkZY55 wvbCF2tXj5Xn11taRW1gA6ad/3BCx0+wDYXgQGsS8sBB0pAHdJ47o00rqHIcStjO u7KLJwxPWzNCfwwSWMcVcKknra/XZOfANcSH49gOMbKtArgx2khO8JuGlPb45ENQ Hw1EBermNgQLv5MEGOIxGB1h4pd13zj+bhNcReESZwh9hLfZyZef4o1sxCwNMvh2 9c5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1673872445; x=1673958845; bh=VUDr8cpDb6H5GOfkB07vTgHvt+Ay LkABhj5WKeHRWOI=; b=itIuCA2aFBIqr2YAugpAWhNf9HE0dvFM/H7bRGvhPY/g 3Aqr77gcrbHqPzH77XT+XzHb3WJmFOisNu1rKn9IB6rzxidqpQiepGTh/qNvWjs4 1P3tTlFjLip5h8ms736X/ft3UDK0n/txN3YOoxZW9z6slK6qaV6mq18pvNUYVt+6 f6EbmENMASccI/Zxc4KlKBiuLnEMbpTkrRWGITWwh+Myr03BL2HdgPR/jI7NM3oG tP+g5ebr+TkPMuKBYnhsm647l7qC8K3sfgrmpDWQmxQWgzsiHRqS39udEPpvbnrR s5zNjmXcvSlp3PZC8eyeGzqAY/rY8Eu2F4AMpWbhmg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddtgedggeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdttddttddtvdenucfhrhhomhepfdfmihhr ihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovhdrnh grmhgvqeenucggtffrrghtthgvrhhnpefhieeghfdtfeehtdeftdehgfehuddtvdeuheet tddtheejueekjeegueeivdektdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 16 Jan 2023 07:34:04 -0500 (EST) Received: by box.shutemov.name (Postfix, from userid 1000) id 33F96109792; Mon, 16 Jan 2023 15:34:03 +0300 (+03) Date: Mon, 16 Jan 2023 15:34:03 +0300 From: "Kirill A. Shutemov" To: Jann Horn Cc: Andrew Morton , linux-mm@kvack.org, "Kirill A. Shutemov" , Zach O'Keefe , linux-kernel@vger.kernel.org, David Hildenbrand , Yang Shi Subject: Re: [PATCH] mm/khugepaged: Fix ->anon_vma race Message-ID: <20230116123403.fiyv22esqgh7bzp3@box.shutemov.name> References: <20230111133351.807024-1-jannh@google.com> <20230112085649.gvriasb2t5xwmxkm@box.shutemov.name> <20230115190654.mehtlyz2rxtg34sl@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: CAD5A4000C X-Rspam-User: X-Stat-Signature: 5zjrz9iypyo8oqditbmu93wgt5xszewk X-HE-Tag: 1673872447-934405 X-HE-Meta: U2FsdGVkX182GlsprvCi025/RiPsjzEyqRgkQCnMMsq98VBmOyT7hhA2nW/gRS55bmQY2GLxOj+f9Buca6qfmTTb98gd09lXfazgDUASSXnoNdz+dcXA5dk8ieaZd3UsyNlLczfpfUyxjkukfMegqcU2jQ/+srTlUR+kuMOcMdeUPkATGSXgoAr4Zb0jlWC0x5dOqnnAi7HAHTDwI2nR0fqTHtsmgQ9eBsUm4xwGLjlAVXNNuC6EDlx1/GoInwFGdnlIbhUUMTQGxyt3TvCEpV8MrEdAOc2mtm2bRnL7MK9xWvUkQ/ToHUz2FoRrTKsPOLYvEuY1v88S6fxnV8iUNbDaO1Z2Quy1LWf+AxJcRJpVGLgqo6pB/Y92KAdD0UlAYnkTpBvb7bjwwSj0WrZfNSraENduCagVqu0ucAUIjR8zyniatysUniaSfRDugK9puO5UF9YjKIkUmXzRGateLjlTeoe2nL8StBtyBG2a7BGYfjTT5ehmMyuNAl2oqEFJy05uHcuydyzI1QeG4Hq9mCR5kzi5aLTMPSTXCS9Sxx9msDs1Qrj/Cmj8fLYgZxKWUWrkCm7LSjoSyB7kLXJwXAH2O4p9PXgmqATZtVfTo9pmYAt/6V/mb9YgQfvQUXlIR2oEi7DCwwasm7X92zySSjwRP3wzHIvTlMtyMKI9vL38ShrpOajHTtiWGH1YQsuN1b1aoEow+Jl2Ve2oaPstgUyYm+NTOUh+6ExMyzMaI+Kt+rIPGgHrehIXvH9dutjwFLw2+oNLPluCj9wuXKBctqeFk27g1eyGp3ryo/Ew/jdhqG+vlDZr3AM6O6ncbcGVNchYP+LVP6QuYNc19ZLqp9ER3Gvvx0cs72faQBxb8DKNfdBHinM9Ch4ShIr8wLrH8ZcvAkmpOWb9aLEGN4FRtRU+BLqKKAmDoTDsifAdeqa1w8P2tlBg4vpULo3DhsYCtGolQVIfI0xBCqiVPzF 2jW/DOME fc8S8bZwRqRFXieNxU6cBqJvPZQ== 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 Mon, Jan 16, 2023 at 01:06:59PM +0100, Jann Horn wrote: > On Sun, Jan 15, 2023 at 8:07 PM Kirill A. Shutemov wrote: > > On Fri, Jan 13, 2023 at 08:28:59PM +0100, Jann Horn wrote: > > > No, that lockdep assert has to be there. Page table traversal is > > > allowed under any one of the mmap lock, the anon_vma lock (if the VMA > > > is associated with an anon_vma), and the mapping lock (if the VMA is > > > associated with a mapping); and so to be able to remove page tables, > > > we must hold all three of them. > > > > Okay, that's fair. I agree with the patch now. Maybe adjust the commit > > message a bit? > > Just to make sure we're on the same page: Are you suggesting that I > add this text? > "Page table traversal is allowed under any one of the mmap lock, the > anon_vma lock (if the VMA is associated with an anon_vma), and the > mapping lock (if the VMA is associated with a mapping); and so to be > able to remove page tables, we must hold all three of them." > Or something else? Looks good to me. > > Anyway: > > > > Acked-by: Kirill A. Shutemov > > Thanks! > > > BTW, I've noticied that you recently added tlb_remove_table_sync_one(). > > I'm not sure why it is needed. Why IPI in pmdp_collapse_flush() in not > > good enough to serialize against GUP fast? > > If that sent an IPI, it would be good enough; but > pmdp_collapse_flush() is not guaranteed to send an IPI. > It does a TLB flush, but on some architectures (including arm64 and > also virtualized x86), a remote TLB flush can be done without an IPI. > For example, arm64 has some fancy hardware support for remote TLB > invalidation without IPIs ("broadcast TLB invalidation"), and > virtualized x86 has (depending on the hypervisor) things like TLB > shootdown hypercalls (under Hyper-V, see hyperv_flush_tlb_multi) or > TLB shootdown signalling for preempted CPUs through shared memory > (under KVM, see kvm_flush_tlb_multi). I think such architectures must provide proper pmdp_collapse_flush() with the required serialization. Power and S390 already do that. -- Kiryl Shutsemau / Kirill A. Shutemov