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 2C45AE77184 for ; Thu, 19 Dec 2024 22:14:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5EF136B007B; Thu, 19 Dec 2024 17:14:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 578636B0082; Thu, 19 Dec 2024 17:14:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 419666B0083; Thu, 19 Dec 2024 17:14:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2581E6B007B for ; Thu, 19 Dec 2024 17:14:34 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8F3F141FA6 for ; Thu, 19 Dec 2024 22:14:33 +0000 (UTC) X-FDA: 82913113332.14.BD35475 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf26.hostedemail.com (Postfix) with ESMTP id 6618814000F for ; Thu, 19 Dec 2024 22:14:06 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=AeHqduSN; spf=pass (imf26.hostedemail.com: domain of akpm@linux-foundation.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734646456; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sG+gJjjqcdn6vd4lVA6h18IGrUxr7WM2K4aFPbgaOSI=; b=bqGZSOu5Wkxjgdq6xNtqWYL4yi6wK0rjBOOasiNjAZv6dGgWQzWMDmrenDji/stIvH5nz1 BmDmjoPWZLap8JCrTRnUXNYCkV5YXi9IlopHB8qmtYTK6YhBPCPtNOH/dhW8DPsI8oowOd VJBTXnnxG7pHNpK30qU+GcVEhBSe8HE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734646456; a=rsa-sha256; cv=none; b=ipQO1d0/eRbCHParq1evj49naHl4DrmT8u8leAFTpT6EUAo3DyH3hQGTuOAzAbPrbvoFej y13EoF9wOqhVKwouASe9Qj/UpOsofWDYm/cnhw72ZFzuU7iYMsNuOHVJt8xWwp3VR4Zp+A KQJ8Kq031lpEMmBQpdpiQTNPr41WtIA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=AeHqduSN; spf=pass (imf26.hostedemail.com: domain of akpm@linux-foundation.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id A20BDA42A13; Thu, 19 Dec 2024 22:12:40 +0000 (UTC) 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) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6618814000F X-Stat-Signature: hr68rfgosrwotq4x9oyr78qiy4md9fiq X-Rspam-User: X-HE-Tag: 1734646446-673588 X-HE-Meta: U2FsdGVkX19irApuLAFIShPGoRuWFoZvdZD64MUFRWYjhk0iSrDPTTDe6BID2PeW2mgessn+RiMArfVNPJ9OZGVvLLlP+vVDKZeBaARpj3zIDgI+vZhQ1/j66G1ticJevh5a7KGEY3eEXfdMUcso6gQLTL4TmjzKdwVGkNkduTuNW295ljWIXdTXBX43X9357CJ0/v3JTrhf4PW7O9z4BDVsqFzdR4gdUesxqltk0UrRpJ08cD6BER2DCpDjWxUU+/CZHiyWiRaFK7JouGmPqSyU78VUI4eXAlV/j9wWQ3OYVNNxoVLI3nCKKS9EAYnPQ7MBXwqjqKqIusEHevLaA/XV+KOTSBltGdw8t+/O6E9n2MMA2f2w8iUBANJA4BRjE+JKdd/WM1JBPQ3aXXKrTpcHu7aZI79AtHDcDAhfs+f9e2WtJuNKNf1oMKRxUZGaq1LyM2ROSHssv1gL0YBbqotJlIhExF+JgcPFL6LNCIUu8+7kTjN0C5aVn3HWsaYLg0AVZm4Vmywzh/DsGBdck7cIZsYBvOSoHX5Eo92GXSV4nTY3mKODGpvDcKVXkVJD4SoUzZg+GRvxIrqSbcjNFUWQ/lLsOJoikq0alNNbDiw18O39KfvU5dfkQpXtAxsXxvvZp75nuxM1scpTU5Kku0f7u/hKLnE5x/ovkzn158ofsfYsPGJoC1udS/T9b7q1KKhk6wN+Kua5aEDjjAg3lh3sRAEqcwSOFu3CY70WKYZZerANEDVEo4Jkh/yEvj38K4tVfCHIOyqlbfnaBDbE+SOz7CNbEn2cSoIBW3iB/ropuBgyCA0zhxDrTMrd2vAD1fUW3kHBZpXjsM6nUwN209hzt7HvW8vtIsn5mckSznP/lGnf+cBuq52mi86+uoHZ944cOZMXwT2lXE9wZJpupxUPHIWJz9SDw+c+WCsUEhZL7lDkIEBzZEdVXAlBJtbgwbY/cjrNh5xNuOLU47E dP/8UlaT jh3bX142ct4lPbck7feEq3SmvYpzOERAduw2Q+kFt+qelXL1aOTjogdI1U0OsN26CEsxeYgNb0kY4QL9j2rUbhcyF9USoslwLJStDyVXNKf98cJVjKbzgszdAQqdCAhF3gQ05D+KcFP3C5Oz+cAdctz2VFXb5O7tKeqk9hXVa7B5Y3JHOcH5gQVafL8z5seelJHGgYhIRsLXjEcxfyEIMDuDqTijlPfQZSIL+2Qbd6nMHYOLAV7Vz/KbQZiHnhSY9ss9j/dAvwpME3smydEMHLd4KfWbpl7Z5TS0YKTg8GUggOAcRQoGxt6tQ8ErhvwAvyRzivgQP0tSn24jnkDao/9C9pAid3ApCKxc8 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: List-Subscribe: List-Unsubscribe: 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?