From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (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 0FA63301465 for ; Fri, 12 Jun 2026 01:39:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781228384; cv=none; b=P2Xx6GQURwlIVv3MkKCZo/5E7tpPoGXHhJWmBAuwW/dd6xRVYkAaFDFaX40Qr+B6DYNabZyF7ukEUzfqYD8p7Nq4AWGVcva4nXDeW0mmUhKpAEbAEwShWbBiF09vKE0n+5ohF7DCg6td/CV/zljmWqL9TxiDQzU1HjAiaOo5gy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781228384; c=relaxed/simple; bh=rSji8BuuMEzAum7X2J1QIY+jsJv7O2S6hGMiE8b5b9E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HT1JMyCfu5/bz0Wus+gOcydjE7j73Uq57te0ZeB1GZYchOdyJgqmMLfiXRd4FkmAskfmfevodBckrMzk2WAPp2FcFOJhYoqhMlCtG4KOmilvPP9PDRksAGmf7YxNDgOyiLK0+ia3dstxgRYeFG7F+X2DA5ITTYzeH2axzgaBNOE= 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=LGLOoTjg; arc=none smtp.client-ip=91.218.175.186 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="LGLOoTjg" Date: Fri, 12 Jun 2026 09:39:29 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1781228379; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZTQ/6WMmxREpnpZL5rsRg6GyXuulFTK7USgPNOqZmyI=; b=LGLOoTjgKQ3gCNfchJxPcPiqLb1X/HIdIefLejyjDiekw1r/tabu5dFcuTkv25LIHGUNTH nFDRHFIlq0xbj1Sh9oycQgviIY+ZJ4HvMN7ddKZmeOlzTce3ehqzKCyc9J1xuadYNn888k pEmDDabL27H2BoXG/dTbM9Yxk6evCo4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Baoquan He To: "Barry Song (Xiaomi)" Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, david@kernel.org, ljs@kernel.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, chrisl@kernel.org, kasong@tencent.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, youngjun.park@lge.com, jp.kobryn@linux.dev, usama.arif@linux.dev, shakeel.butt@linux.dev Subject: Re: [RFC PATCH 3/3] mm: entirely remove lru_add_drain in do_swap_page Message-ID: References: <20260611105124.98668-1-baohua@kernel.org> <20260611105124.98668-4-baohua@kernel.org> 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: <20260611105124.98668-4-baohua@kernel.org> X-Migadu-Flow: FLOW_OUT On 06/11/26 at 06:51pm, Barry Song (Xiaomi) wrote: > We are doing a lot of redundant lru_add_drain() calls in > do_swap_page(), especially for synchronous I/O devices. For > example, the test program below currently ends up draining > lru_cache 100% of the time: > > int main(int argc, char *argv[]) > { > int i; > #define SIZE 100*1024*1024 > while(1) { > volatile int *p = mmap(0, SIZE, PROT_READ | PROT_WRITE, > MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); > > for (int i = 0; i < SIZE/sizeof(int); i++) > p[i] = i%64; > madvise((void *)p, SIZE, MADV_PAGEOUT); > for (int i = 0; i < SIZE/sizeof(int); i++) > p[i] = i%64; > munmap(p, SIZE); > } > return 0; > } > > Folio reuse now relies primarily on the exclusive hint, making > lru_cache draining to drop the refcount in lru_cache largely > irrelevant. > > Signed-off-by: Barry Song (Xiaomi) > --- > mm/memory.c | 10 ---------- > 1 file changed, 10 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index ce8ef27e7a54..b5a78670bcc8 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -4903,16 +4903,6 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > } else if (folio != swapcache) > page = folio_page(folio, 0); > > - /* > - * If we want to map a page that's in the swapcache writable, we > - * have to detect via the refcount if we're really the exclusive > - * owner. Try removing the extra reference from the local LRU > - * caches if required. > - */ > - if ((vmf->flags & FAULT_FLAG_WRITE) && > - !folio_test_ksm(folio) && !folio_test_lru(folio)) > - lru_add_drain(); > - > folio_throttle_swaprate(folio, GFP_KERNEL); Reviewed-by: Baoquan He > > /* > -- > 2.39.3 (Apple Git-146) >