From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47B59315D3B for ; Wed, 10 Jun 2026 16:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781110318; cv=none; b=D2H+Hp1LLsF3zlifnrvIASOb3G+BuPSO6gooZ44M4hR87Pl+qXRDiGsSCBKaKkIcdYeZVOmTe61SLHMBKUV33wFC5NZgwRtSIlVLprbjmjnZ+NEClE01t8vLlviD0N+bY55BiwENZZfUvjGkQNL192R67efmTT6BDJPmqrXy5sM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781110318; c=relaxed/simple; bh=ct5PPGwjc/EQ8VGw12wx7v1TodId4eA1iFVryGvgOcU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JRihnFD0+Xbvo3XYDvA2UTHSCXon1BRvR1rrN9CZ4H5/Ywlv1dePpkaBKGOa5XI8oS/8gVkVv7nzNeBpvxrt9M9r2ACsIJ/Uc1+tcRIuIAVzmwodbVU6NzWZFlFeEkcYPCx7iiNjdWpUr9Sj/QXIKnDBpVJhtjAjRvjtSBBS7U0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=RXIshKPc; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="RXIshKPc" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-5175cb5946dso46427301cf.0 for ; Wed, 10 Jun 2026 09:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1781110314; x=1781715114; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=qO7PcTURECVwaL537JQLmKXQDPG+aZWd6lpbt9X9Cxg=; b=RXIshKPcEWafUchZv/WxvyP9eMuUF92XWeERyN6eVbjgJSKT3ROIHv6JLM4AomE3Kr aV38BQnT5CqdEQFA+SnC/gtn4rS+yw2zh28GAa6Koc1D3U7pAY8lkoBeHHS2FryoojYp 33RQ359FmY4sq7kAKbkO6AATxvMqaD5Yir7V/8T3X+XFdV5q59J9BvnJEakQw+X4mhCy QKOcHYbaF8raUxVLqnNlr49HPUJksSh6g9P1MRwh1n3opaP0YhD5zhw4w/TSNnBIVZHq eW2VAOnpmznNL9xMkvJEwOH2Ugcn2w4jB8aVsID/O6cr2cjgW383wASC1GHJ6oBwi63r CAiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781110314; x=1781715114; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qO7PcTURECVwaL537JQLmKXQDPG+aZWd6lpbt9X9Cxg=; b=gyPYu+Mx1jSQ75HVfUuf45oh65/AHNNNTEf0bbZ5ueOhAxtGI8ojLzgcWXwvOiEq9I Y/u+v5RYIUO0L6anPZdrDdiebUPxL8lRAsNL+Q059A4ONaOPIQ9ETmuHQ1w8fXkmC1MX xMD88PvbLCgceA2Q9qctYVAGU4U9ttpqdmYpoT45tpz65AtKT8sd/7zT2xerlVGO3pZG yKyjsfQk00gOFti7jmZOdc3fynAfPnFUuHWeDNjF1y6oHrNkokA6TXM/4sQ0RVQ7VgDI do+wKJeB38b1inmc/H8nOtuCBuIJ5PrHfeU6RpBeRthV3o0d/iEx16HwLnetJlB+IJAV chlQ== X-Forwarded-Encrypted: i=1; AFNElJ/6IMngEEiQK2ooj8f9SNaKnKTNninvxCxXTsiqUgVoIW2iLsDp+KzQUEfzUU0b0Flmxw45mpAB/W99c+8=@vger.kernel.org X-Gm-Message-State: AOJu0YwdxwKvvl4avvlpraLihQRBErhBpWVmUxSHpdOP5DFCDLFjyJkB BZh+24nEvAYu24n4GQzOL0t4N7li9u/TIUdSFGp1+w4L9Rx1vUWBDWXbXkWDPwEG0iQ= X-Gm-Gg: Acq92OH6QS30MCgIgXH4m2qLIHO7fm8cx10NEiU6r9Z9tm2bozYmOWIJNEpnWZrViWF 103KXWz2ONv9l+0zRhzB7Q5XSAxr/CwBTeEBxnXjWGTYJ+ccMiuwJo5ztGYW0IgLntqxsWGJps8 M6+ozH2ikKFJCRRzGlsSvJFB23FYGXaQqtATn/DBzW+B/0r0HCF37agtQOc7V9227/iTT2Ox/BN 1dXf4iBedhOh1cv0neEAmtmZcLcA4hU6tney4pA5WafJvituMACZP9SJAeSm48zHMo7tosMjYnR RkeygEzwCXFt5xVoJU8g2jDjp7CcH/qqjiMBe3TKDObGQJnQ4S98ypmoaozN745GXqcqS6HOx81 dgxjML4wyp50extHfktTrFL+O/9kusvfTplWzixN2+CIsNRPq3zuQH2oNPQGuA2Mbto/Ofz1WyR Ps+e0BygwPi51FjAmqrjIZgd+zAKRtGFSH X-Received: by 2002:ac8:5f84:0:b0:517:b58e:a1e4 with SMTP id d75a77b69052e-517b58ea315mr236682201cf.41.1781110313972; Wed, 10 Jun 2026 09:51:53 -0700 (PDT) Received: from localhost ([2603:7001:f100:500:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775e2e16dsm222674371cf.31.2026.06.10.09.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 09:51:53 -0700 (PDT) Date: Wed, 10 Jun 2026 12:51:52 -0400 From: Johannes Weiner To: Usama Arif Cc: Andrew Morton , riel@surriel.com, david@kernel.org, baohua@kernel.org, baoquan.he@linux.dev, chrisl@kernel.org, kasong@tencent.com, linux-mm@kvack.org, shakeel.butt@linux.dev, nphamcs@gmail.com, shikemeng@huaweicloud.com, youngjun.park@lge.com, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH] mm/swap_state: remove unnecessary lru_add_drain() from readahead Message-ID: References: <20260608143242.2869392-1-usama.arif@linux.dev> 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: <20260608143242.2869392-1-usama.arif@linux.dev> On Mon, Jun 08, 2026 at 07:32:42AM -0700, Usama Arif wrote: > swap_cluster_readahead() and swap_vma_readahead() end the readahead > loop with an explicit lru_add_drain() call. That drain is a leftover > from 2.6.12 era code and serves no functional purpose for the callers: > > - do_swap_page() ignores LRU residency for the readahead folios; > it only needs the target folio it called swapin_readahead() for, > and if the write-fault path needs the target folio on the LRU to count > references accurately, it runs its own lru_add_drain() at the > wp_can_reuse_anon_folio() and do_swap_page() sites. > > - shmem_swapin_cluster() immediately locks the returned folio, waits > for writeback, then operates on it - LRU residency of either the target > or the readahead folios is irrelevant. > > - try_to_unuse() likewise locks the folio and calls unuse_pte() without > depending on LRU presence. > > Folios newly added to the swap cache by the readahead loop sit in > the per-CPU LRU folio_batch and will be drained naturally as the > batch fills (FOLIO_BATCH_SIZE),by the next reclaim/compaction > lru_add_drain_all() and so on. The unconditional drain only > synchronously flushes a partial batch and forces contention on > lruvec_lock. > > On a 176-CPU production host running a memory-pressured workload, this > path was observed to call folio_batch_move_lru() from > swap_cluster_readahead() ~28K/min, a very large source of LRU lock > traffic. > > This is a direct continuation of the cleanup started in commit > 1aa43598c03b ("mm: remove unnecessary calls to lru_add_drain") which > removed the equivalent drain from free_pages_and_swap_cache() with > the same rationale. A detailed reasoning for this is present in [1]. > > Remove both drains. > > [1] https://lore.kernel.org/all/dca2824e8e88e826c6b260a831d79089b5b9c79d.camel@surriel.com/T/#u > > Signed-off-by: Usama Arif Acked-by: Johannes Weiner