From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 A39723793BA for ; Mon, 27 Apr 2026 07:16:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777274196; cv=none; b=hBDMh2NAX3w6mnlK4CeZRLsq+cHTye5OJSVd/r+DQ7dll/UPo4KB7UVps4T54W6Fio9G6K8o/wcVE6Fpjt5pArtwssGirJ78ojKMgL+U0HwdHccQcaLugr/x6p/fihWjBCHn9NNiRAnBmvqo07DQt8xZSIUOVGINozpbtLp2Ih8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777274196; c=relaxed/simple; bh=CgYNoeo4Ma2x/AydAJ9rtFeZOoiEC4OwaUsFMIwsgtQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XYx45ws5Yp61C52z6cjzxml0hMYOIrBfKGv7yhii6IQ1iwalcmjJopoug2RdVzrEVkMd1RoGYQwDzDR1IrQUN7KVBU+eZqqk1C21dtnThkcICkIsUETP+sbemQ/SRfzKQNbBeQUYhondYbYG5qERL4WUk9q0bJAI/958HdPQ0Xk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=hDb7m1ZX; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="hDb7m1ZX" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-488af9fdaa7so58180175e9.1 for ; Mon, 27 Apr 2026 00:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1777274193; x=1777878993; 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=7AvPAXsuvtgC8xHgqZ0h0f5zzV7f6VHw1kg2bqEt4fs=; b=hDb7m1ZXCEU7U40wHfcJ1qdVA21mrF5/dJKreyA7cQ0iAGN7hD3NgY84Syn38W8BY+ cZgr58ALRgoQFHy3GgfGzOsFRqPyORZdgetCj8qLsXqJPxg3r5wuOL5OU2Ra/fCq/rYD eaN2Dj6C0VVzr3bBcApe14m+bhsdSRftHx0wNSTWnTckELEbRrTiSFbD87NSSTT4Qe2c SS/qRC+JqetZvMIRTHIcdHVqn+GWd4X7SxxqlVWbG3AeoXJsxZ4Z31qZJwZ2VpyfFyzO Njv8XVRbJSq7DQzZ1l3gsYlf9yokIQZ3FlFSwuj6xgGmKZqPMwOPNSlfFZ5QdhN8F26Q PGtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777274193; x=1777878993; 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=7AvPAXsuvtgC8xHgqZ0h0f5zzV7f6VHw1kg2bqEt4fs=; b=dVEEG9Gf4Fz3B1pJuNuaod2f59Lpexr+gMj9/3iqdBppKR1eOS/XmOloir5B9efK36 m4Di+/BlzWGS68R7MhMN5xDT5kUl/ZnQcxwsTh6RJ71kRJUPpK0Fy4TcFMmI80Pm63J1 PIZHPvNRhfUcmwMfmxpnKsYbY+lk9toxHwLA3Fb8kZC4jzPMMkDzMnniTjoHLbH+i1xf 1saEeprDbVi5Y3Q2wDGmsf3750m2+YvdBvxW3RolQ00fzeATEW6EzDYu1AOBeKkCCr8E LiBfOoR/R302r9BLPPWizw6VUgJ33equDGdQlvRfbB8o472G4J+UZMF/xKL1SKpSqSYS FNmQ== X-Forwarded-Encrypted: i=1; AFNElJ+kGXHRD+4VrjO0lRh9WyvWLHmstYhQcRKcu/1M8rUfuBsVPXerPn7rshiE/eogp8yoZt1yoywC9l0Zqyc=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/K2Zl5eWdm0cHjITGpKjz1jBDuBb2rTiA+88u+WmlViMjht/i TpKmc+Rc0p4p1dLA4ml3/00O58JYdRPBAxjpz8TFchiGpaSMsM9Rflm7wNRUd7Rh5KY= X-Gm-Gg: AeBDieuf9y6q+FhvHyRDwP3rs3pC0pxYgn3rNeTFZJjH85/Vfm5wJDPMRNKIpO/Aibj SpleHYsvv0uOduyF6ZdGQ1mFMomEgYHTyDym8dVsgqcxbHIqBtx+F4tc8nWoNPVCVtASxr1XrLf iz+4zlWBEqY8l7+Al2fbeq/EC5fTZbaVxTtXxMYruh/JFLl2qZeKu9dXiM7mBg/gvRbb2Idv2ms fHhg9wFwl3wwNynWg/BAiSokiJ55IOrkkksVfQC9jkit93upYFLDnTrzvLhHmzmM0TeSm0Wgtxn iNa6412bsOFakNmjy85Ob4MhP261++lERYsrJuIWC8nia7FfKi8u6DoWV+86m5qFIR3pL4yj1yw aqxjsWjuQkVriEZ+xVjn3Pqeg0h8VZhkRJsjabAIszf126Fuse+8yhw45MiThZvfpYJ/lxIPie3 XqgaQAjgCjoBj4ZlsO1ZtQbFIzELIYFCHfxFWKFE9Bm4THzRo= X-Received: by 2002:a05:600c:858c:b0:48a:55d8:7882 with SMTP id 5b1f17b1804b1-48a55d87a58mr307347815e9.9.1777274192917; Mon, 27 Apr 2026 00:16:32 -0700 (PDT) Received: from localhost (109-81-17-171.rct.o2.cz. [109.81.17.171]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc177dafsm936339475e9.4.2026.04.27.00.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 00:16:32 -0700 (PDT) Date: Mon, 27 Apr 2026 09:16:31 +0200 From: Michal Hocko To: Minchan Kim Cc: "David Hildenbrand (Arm)" , akpm@linux-foundation.org, hca@linux.ibm.com, linux-s390@vger.kernel.org, brauner@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, surenb@google.com, timmurray@google.com Subject: Re: [PATCH v1 2/3] mm: process_mrelease: skip LRU movement for exclusive file folios Message-ID: References: <20260421230239.172582-1-minchan@kernel.org> <20260421230239.172582-3-minchan@kernel.org> <7c7da8ae-cd39-4edf-b94f-c79ab85df456@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: On Fri 24-04-26 12:15:18, Minchan Kim wrote: > On Fri, Apr 24, 2026 at 09:57:16AM +0200, David Hildenbrand (Arm) wrote: > > On 4/24/26 09:51, Michal Hocko wrote: > > > On Tue 21-04-26 16:02:38, Minchan Kim wrote: > > >> For the process_mrelease reclaim, skip LRU handling for exclusive > > >> file-backed folios since they will be freed soon so pointless > > >> to move around in the LRU. > > >> > > >> This avoids costly LRU movement which accounts for a significant portion > > >> of the time during unmap_page_range. > > >> > > >> - 91.31% 0.00% mmap_exit_test [kernel.kallsyms] [.] exit_mm > > >> exit_mm > > >> __mmput > > >> exit_mmap > > >> unmap_vmas > > >> - unmap_page_range > > >> - 55.75% folio_mark_accessed > > >> + 48.79% __folio_batch_add_and_move > > >> 4.23% workingset_activation > > >> + 12.94% folio_remove_rmap_ptes > > >> + 9.86% page_table_check_clear > > >> + 3.34% tlb_flush_mmu > > >> 1.06% __page_table_check_pte_clear > > >> > > >> Signed-off-by: Minchan Kim > > > > > > As pointed out in the previous version of the patch. I really dislike > > > this to be mrelease or OOM specific. Behavior. You do not explain why > > > this needs to be this way, except for the performance reasons. My main > > > question is still unanswered (and NAK before this is sorted out). Why > > > this cannot be applied in general for _any_ exiting task. As you argue > > > the memory will just likely go away so why to bother? > > > > I think there was a lengthy discussion involving Johannes from a previous series. > > > > That should be linked here indeed. > > How about this? > > mm: process_mrelease: skip LRU movement for exclusive file folios > > During process_mrelease() or OOM reaping, unmapping file-backed folios > spends a significant portion of CPU time in folio_mark_accessed() to > maintain accurate LRU state (~55% of unmap time as shown in the profile > below). > > This patch skips LRU handling for exclusive file-backed folios during > such emergency memory reclaim. > > One might ask why this optimization shouldn't be applied to any exiting > task in general. The reason is that for a normal, orderly exit or just > pure kill, it is worth paying the CPU cost to preserve the active state > of clean file folios in case they are reused soon. Preserving cache hits > is beneficial for overall system performance. This is a statement rather than an explanation. Why is it worth paying the cost? What is different here? > However, process_mrelease() and OOM reaping are emergency operations > triggered under extreme memory pressure. In these scenarios, the highest > priority is to recover memory as quickly as possible to avoid further > kills or system jank. Spending half of the unmap time on LRU maintenance > for pages belonging to a victim process is a bad trade-off. If speeding up > the victim's reclaim by avoiding LRU movement and evicting cache negatively > affects the workflow (due to immediate restart), it implies a sub-optimal > kill target selection by the userspace policy (e.g., LMKD), rather than > a problem in this expedited APIs. Your change effectively boils down to break aging for exclusively mapped file pages when those pages should have been activated. All that because the activation has some (batched) overhead. You argue that the overhead is not a good trade-off for OOM path because those pages are exclusive to the process and therefore they will go away after the task exits. The same line of argument applies to task exiting normally too. Task exit it not the most hot path but certainly something noticeable, especially so for huge tasks. All that being said, you really need to focus why breaking the aging is a worth optimization. Keep in mind that while the page might be exlusively mapped it could still be actively consumed from the page cache and breaking the aging could lead to refaults. -- Michal Hocko SUSE Labs