From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752567AbdHNIAT (ORCPT ); Mon, 14 Aug 2017 04:00:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:38173 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752262AbdHNIAS (ORCPT ); Mon, 14 Aug 2017 04:00:18 -0400 Date: Mon, 14 Aug 2017 09:00:15 +0100 From: Mel Gorman To: Ben Hutchings Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Nadav Amit , Andy Lutomirski , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman Subject: Re: [PATCH 4.4 18/58] mm, mprotect: flush TLB if potentially racing with a parallel reclaim leaving stale TLB entries Message-ID: <20170814080015.6hrus2mca4g3qxza@suse.de> References: <20170809194146.501519882@linuxfoundation.org> <20170809194147.234463750@linuxfoundation.org> <1502473549.2047.36.camel@codethink.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1502473549.2047.36.camel@codethink.co.uk> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 11, 2017 at 06:45:49PM +0100, Ben Hutchings wrote: > On Wed, 2017-08-09 at 12:41 -0700, Greg Kroah-Hartman wrote: > > 4.4-stable review patch. If anyone has any objections, please let me know. > > > > ------------------ > > > > From: Mel Gorman > > > > commit 3ea277194daaeaa84ce75180ec7c7a2075027a68 upstream. > [...] > > +/* > > + * Reclaim unmaps pages under the PTL but do not flush the TLB prior to > > + * releasing the PTL if TLB flushes are batched. It's possible for a parallel > > + * operation such as mprotect or munmap to race between reclaim unmapping > > + * the page and flushing the page. If this race occurs, it potentially allows > > + * access to data via a stale TLB entry. Tracking all mm's that have TLB > > + * batching in flight would be expensive during reclaim so instead track > > + * whether TLB batching occurred in the past and if so then do a flush here > > + * if required. This will cost one additional flush per reclaim cycle paid > > + * by the first operation at risk such as mprotect and mumap. > > + * > > + * This must be called under the PTL so that an access to tlb_flush_batched > > + * that is potentially a "reclaim vs mprotect/munmap/etc" race will synchronise > > + * via the PTL. > > What about USE_SPLIT_PTE_PTLOCKS? I don't see how you can use "the PTL" > to synchronise access to a per-mm flag. > In this context, the primary concern is a race with clearing and checking PTEs at the location protected by a single PTL lock. While the flag in question is a per-mm flag, the ordering only matters when a race can potentially occur. -- Mel Gorman SUSE Labs