From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 625AB1AA1FA for ; Thu, 19 Dec 2024 22:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734646471; cv=none; b=Edpopp80XVzPEf/9L3iTU9qZWyNn33FRPeAEFsWAUeT8nnLgW9RZO2/Rzkn2tWxGSf7FHvhwuf/b12ErKJSZUKAL8trijirVta7yNM2QlKjHfiLCOBQ1sR0KuzXpPukgh6WZDNL0VEPWbmpccqi08G4smKP/OYWk4GYJBSDgApc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734646471; c=relaxed/simple; bh=xwgDeyo6Gmhq4VdLdy4Yv53Y9pUljjtCDCUuusGKq6M=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=KJ7ACUdhsSgCobJIdaLsVTS8lwcCIw0O/BSRiLtSl0nfjM+rJw8bc/2O7QEyFCsZSEIzito4sMZBurjqWChWWZ/cIqPizGltkYixP7uHA8dO6dyRaOINQ8KIooNCmaqK8S0AIVS7DcduFrIILC4inR/+y7iRgSJXd1IB2CMwki4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=AeHqduSN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="AeHqduSN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B599C4CED0; Thu, 19 Dec 2024 22:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1734646470; bh=xwgDeyo6Gmhq4VdLdy4Yv53Y9pUljjtCDCUuusGKq6M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=AeHqduSNqKkltbMDWtCPBwwrZZQ94Ir5WtW6P5561dBTZ3EXAlO+uP3WWXMUGk+7X amPygLyTTeGVa8akPJJ/m6GCy2+7h+WygKd6mLAytNlNM7mMNW7iWRRNJI+XANqtLy LFTlsoHZJq/wNtR5zfNhR3f6fuXRZBcT6ifxloBQ= Date: Thu, 19 Dec 2024 14:14:29 -0800 From: Andrew Morton To: Rik van Riel Cc: Shakeel Butt , David Hildenbrand , Chris Li , Ryan Roberts , "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, kernel-team@meta.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: remove unnecessary calls to lru_add_drain Message-Id: <20241219141429.165830ca3f405d5fd08be353@linux-foundation.org> In-Reply-To: <20241219153253.3da9e8aa@fangorn> References: <20241219153253.3da9e8aa@fangorn> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Thu, 19 Dec 2024 15:32:53 -0500 Rik van Riel wrote: > There seem to be several categories of calls to lru_add_drain > and lru_add_drain_all. > > The first are code paths that recently allocated, swapped in, > or otherwise processed a batch of pages, and want them all on > the LRU. These drain pages that were recently allocated, > probably on the local CPU. > > A second category are code paths that are actively trying to > reclaim, migrate, or offline memory. These often use lru_add_drain_all, > to drain the caches on all CPUs. > > However, there also seem to be some other callers where we > aren't really doing either. They are calling lru_add_drain(), > despite operating on pages that may have been allocated > long ago, and quite possibly on different CPUs. > > Those calls are not likely to be effective at anything but > creating lock contention on the LRU locks. > > Remove the lru_add_drain calls in the latter category. These lru_add_drain() calls are the sorts of things we've added as bugfixes when things go weird in unexpected situations. So the need for them can be obscure. I'd be more comfortable if we'd gone through them all, hunted down the commits which added them, learned why these calls were added then explained why that reasoning is no longer valid. A lot of the ones you're removing precede a tlb_gather_mmu() operation. I wonder why we have (or had) that pattern?