From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [95.215.58.181]) (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 E68C91BEF6F for ; Thu, 23 Jan 2025 21:19:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737667185; cv=none; b=ZRZAoLrPvLVRmtJxeLec6Rql60XbNicB+GUan90/XGca/on/YasgEVp+NEQFkiBXzKrkGQUBYRW4DZQSsk1c9ElZ9LAp3dMQrpyZNs0rg7kpA4kV189ViCB5oFEEOoj/xdwNqmIY68HpRltAaW332/DAWOnYG81SlGPbw3QEm+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737667185; c=relaxed/simple; bh=4gqLO/KhcclRntG1aQsO9+6It59ZitRWBvujhur8+dE=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=a2eRs/8w6bh4/lNCeHxKI7IKT16nIhRpS/4pas+I0DFAWcrnlX2ycaKk2dpQRqrwnjzKQhmxXAh0HnzwQWR9wPMoaJZ53EUlyKF69f9B5vg2Ewf7MF3O4XubCHHhnfJpqwLCvh1B2Sh3hhk24HUom5JZWyzajWf3sTA8/qJRtbQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=kTmy5IUD; arc=none smtp.client-ip=95.215.58.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="kTmy5IUD" Date: Thu, 23 Jan 2025 21:19:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1737667172; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cJFn4Dz4I4J//YPKVR1XgGUu4+tKSeCH0Rs85g4ayhM=; b=kTmy5IUD/twAkpjRZt4DcVZpZoeVa80RYz/k2/G/8NT33cYzTn1Xf5Bq5OX6bzNJLjwdaL NhE2lOafDS5TbPiYkFmVy8VCDbHf4SJcbaXNqvvmJfNQ1geCOmtMOML0a1CNIFFoX8Up9u 56SzvtSTCiIVibvjQCxNcWlCuhQjfKQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: "Liam R. Howlett" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Jann Horn , Peter Zijlstra , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Hugh Dickins , linux-arch@vger.kernel.org Subject: Re: [PATCH v3] mmu_gather: move tlb flush for VM_PFNMAP/VM_MIXEDMAP vmas into free_pgtables() Message-ID: References: <20250123164358.2384447-1-roman.gushchin@linux.dev> <5bpibh7qkrcggyqsrathszfqrjckyaqspdons6cfkkyse4ub4b@2iu4sibbirxf> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5bpibh7qkrcggyqsrathszfqrjckyaqspdons6cfkkyse4ub4b@2iu4sibbirxf> X-Migadu-Flow: FLOW_OUT On Thu, Jan 23, 2025 at 02:42:56PM -0500, Liam R. Howlett wrote: > * Roman Gushchin [250123 11:44]: > > Commit b67fbebd4cf9 ("mmu_gather: Force tlb-flush VM_PFNMAP vmas") > > added a forced tlbflush to tlb_vma_end(), which is required to avoid a > > race between munmap() and unmap_mapping_range(). However it added some > > overhead to other paths where tlb_vma_end() is used, but vmas are not > > removed, e.g. madvise(MADV_DONTNEED). > > > > Fix this by moving the tlb flush out of tlb_end_vma() into > > free_pgtables(), somewhat similar to the stable version of the > > original commit: e.g. stable commit 895428ee124a ("mm: Force TLB flush > > for PFNMAP mappings before unlink_file_vma()"). > > > > Note, that if tlb->fullmm is set, no flush is required, as the whole > > mm is about to be destroyed. > > > > --- > > Hugh didn't mean to add a ---, he meant to move the version info between > the Cc list and the patch so that it's not in the git history. Ah, ok, somehow it wasn't a problem previously for me, usually Andrew was dropping the part while merging into the mm tree. Thanks for clarifying. > > You can find examples on the ML. > > > > > v3: > > - added initialization of vma_pfn in __tlb_reset_range() (by Hugh D.) > > > > v2: > > - moved vma_pfn flag handling into tlb.h (by Peter Z.) > > - added comments (by Peter Z.) > > - fixed the vma_pfn flag setting (by Hugh D.) > > > > > > Suggested-by: Jann Horn > > Signed-off-by: Roman Gushchin > > Link: some email discussion url lore.kernel.org.. It was based on some non-public discussion unfortunately, so no lore link. Thank you!