From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (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 62B003101D4 for ; Mon, 18 May 2026 09:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779095315; cv=none; b=fPLvgWWy11euuQW3eZVGku+4B+pF6Dj90VPA4ML5GroEFKnqxc06yX5JhNSCclj+XYdm/vldX+DI2M3U0KtY5EXURp4ejdndTzw4geUbkWwirfDRmbeerXabuHT+A+ZkXSqCVDtZyzmIqTIz6O4pvDDi2EZ6wDvkMK7Cjvp+HgA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779095315; c=relaxed/simple; bh=QnvLOFKf7l2AziDejcnsItdVNcZ+xCgDN4DOh7vh8CE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=JqdyFfy0t466DYgmuLFWU1/x2UnVJTJUOiPH8AJ4X/6dD/0WWw7nuUQW5+UyuYzrezt0GkXhFRBfaREAT74Ngeuhk5j1Z+q4JNXvDFnJDrrKCZJBT9urr0Pm7ExnwJWFyIW2aTQiVNJ6YcDJxnJYQD9CvEvhHAPN2N7nOb4ehuQ= 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=mn/ebOCL; arc=none smtp.client-ip=95.215.58.189 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="mn/ebOCL" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779095311; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZoVBgObVlHLK3fouujqDYkCHlgaAhCdl77DK23kYJ50=; b=mn/ebOCL9V/jPWdfLunYjJIvlB1wFcJxWyM07xrG1tHb33Hi6XaPLW1xtf2RemOdOWiOfM vcEALMSjJ086jo7epDbzh8QVdkJ4eTHs+Uof/0Hb2UYHxmu8uL5cgnyJ3L085/TaeYP7pP Usf2sFrv2Mt7agvai2wgWozRGLKTjHk= From: Lance Yang To: david@kernel.org Cc: lance.yang@linux.dev, npache@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, yuzhao@google.com, usamaarif642@gmail.com, baohua@kernel.org, dev.jain@arm.com, ryan.roberts@arm.com, liam@infradead.org, baolin.wang@linux.alibaba.com, ziy@nvidia.com, ljs@kernel.org, akpm@linux-foundation.org Subject: Re: [RFC] mm: restrict zero-page remapping to underused THP splits Date: Mon, 18 May 2026 17:08:20 +0800 Message-Id: <20260518090820.8101-1-lance.yang@linux.dev> In-Reply-To: References: 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=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On Mon, May 18, 2026 at 10:24:26AM +0200, David Hildenbrand (Arm) wrote: >On 5/14/26 10:11, Lance Yang wrote: >> >> On Tue, May 12, 2026 at 09:02:38PM +0200, David Hildenbrand (Arm) wrote: >>> On 5/12/26 20:36, Nico Pache wrote: >>>> On Tue, May 12, 2026 at 1:05 AM David Hildenbrand (Arm) >>>> wrote: >>>> >>>> I meant before b1f202060afe ("mm: remap unused subpages to shared >>>> zeropage when splitting isolated thp"). Sorry, I should have been more >>>> specific. >>>> >>>> As in before the underutilized shrinker (and commit b1f202060afe), we >>>> had the exact problem you describe above and no way to handle it. >>>> Correct? >>> >>> Right. That's why the underused shrinker was added, to directly free pages that >>> have been over-allocated with a THP, but are actually never "used" (remain zero). >>> >>>> >>>> I guess at reclaim THPs would be split and we would swap out a zero filled page? >>> We don't necessarily split during swapout, we try to swap out the THP if >>> supported. But yes, that can happen. >>> >>> I'm more thinking about other reasons to split a THP (e.g., migration, partial >>> MADV_PAGEOUT/MADV_COLD/MADV_FREE), where the behavior would be changed. >> >> Yeah. Today any successful anon split gets TTU_USE_SHARED_ZEROPAGE. Would >> it be better to make KSM opt out, so other split paths keep the behavior >> they have today? >> >> That way we do not have to worry about changing anything else at the >> same time :D > >This is (1) here: > >https://lore.kernel.org/all/04ea0e68-de56-49c4-8c9f-1734139d5e7f@kernel.org/ > >There will still be interaction between both mechanisms. So I'd prefer that in >VM_MERGEABLE sections with KSM enabled, only KSM would take care of deduplicating. Cool. I'd go with that approach as well. It should avoid unexpected interaction between the two :) That should keep VM_MERGEABLE VMAs under KSM's control, while leaving the other split paths unchanged for now. Cheers, Lance