From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 87DC131353C for ; Tue, 9 Jun 2026 14:14:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781014491; cv=none; b=f46SeLvXt73eCVUKb/mLogbktgYW/VFzCpiEzyO7hrsohVRXtOAAA6UfIA7ZUZ9W+lQ2mLfPf4lSWy4rBXSRvAs/oa8b+uDLO9J9atewg5TV/IYwyg4LPzU2U5515VJgcFkLeRn7HqsgvnL92/MVaOjfTth8QENkUsb919QzpHk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781014491; c=relaxed/simple; bh=mJ4VVCk8b3uVlpBKEcearz96XlwdmJj00YBRDzReuoI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NGS/X8QHCLpBaBWdTtTTojzCnhEHq+YEVYakUbNDyETqDpTUFco5Z3mXE4CF7eqH8FDlPx+zkE/fJqwSXe9AbRK51zy8hbctT8Scib+IXjAuaDKGBnKmTX1OMkmyy9FA4M+SqpUe2Oqk5AKLjOrNmgdVMJ5cc4g/Y9foAll5No4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TvN2nY/l; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TvN2nY/l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0EF11F00893; Tue, 9 Jun 2026 14:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781014490; bh=mJ4VVCk8b3uVlpBKEcearz96XlwdmJj00YBRDzReuoI=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=TvN2nY/ls2OFvcWdWp3WS+jzCQIy55YVd10EicT/K15ZWj69VXwsbypjG9msithuY bi7iADq5nTY7FZASSHGqHh7zr0V7zq5jb0U4+FsOQo0bi7HSPqi0aqC+jQm0wh/B2y n6jc7rOELuwhOQWL+Q/DMhtyJOd/A03BdwMDqyhQ87PlxrSRksCG2sw5IaFyFPMm09 U6rMLQNoAJKucdYU/B1GNCQPiwYJtA/pUVY2uOB/e4ONZyR4PyFMNCudapSh3d3CBY MFp+AuFW2hAPWBEpUSNlnQLpVevD6AVaQ2+oHHjMb+focdiQ/ZWMaG3PX8LPiA6i+D E6wL8W4+0oj1g== Date: Tue, 9 Jun 2026 15:14:41 +0100 From: Lorenzo Stoakes To: xu.xin16@zte.com.cn Cc: npache@redhat.com, david@kernel.org, lance.yang@linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, usamaarif642@gmail.com, yuzhao@google.com, aarcange@redhat.com, akpm@linux-foundation.org, chengming.zhou@linux.dev, ziy@nvidia.com, baolin.wang@linux.alibaba.com, liam@infradead.org, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, matthew.brost@intel.com, joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net, ying.huang@linux.alibaba.com, apopple@nvidia.com, wang.yaxin@zte.com.cn Subject: Re: [PATCH mm-unstable v1 2/3] mm/migrate.c: Prevent folio splitting from interacting with KSM Message-ID: References: <20260609214947060zpq8Z6jdYop1TceXXcLoQ@zte.com.cn> 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: <20260609214947060zpq8Z6jdYop1TceXXcLoQ@zte.com.cn> On Tue, Jun 09, 2026 at 09:49:47PM +0800, xu.xin16@zte.com.cn wrote: > > > >AFAIU, KSM and THP do often conflict with each other. THP tries hard to collapse > > > >a huge page (which may contain many zero pages). If KSM is enabled and part of > > > >that huge page is mergeable, it can easily be split by KSM, rendering THP's > > > >efforts futile. > > > > > > > >Therefore, in our actual production environment, we typically avoid making the > > > >same region both KSM mergeable and THP always. > > > > > > Right, some setups may choose to avoid using KSM and THP always on the > > > same region. But that is not something the kernel can assume :) > > > > > > David noted in the RFC that QEMU may use both MADV_HUGEPAGE and > > > MADV_MERGEABLE, while KSM can be enabled later system-wide. > > > > > > And I think Nico means something different from KSM spliting THPs in > > > general. > > > > > > KSM has been able to split THP before. the new part from b1f202060afe is > > > that a KSM-triggered split can also remap zero-filled subpages to the > > > shared zeropage, outside KSM's own use_zero_pages/pages_to_scan controls. > > > > > > Maybe the changelog could spell that out :) > > > > Yeah maybe I didnt properly explain that :p > > > > After some thought I still think the alternative approach i mentioned > > in the RFC may be better. > > > > ie) prevent the zero-page merging that results from KSM splitting a > > folio. The check we add here is more general and will skip this > > zero-page merging with all MERGEABLE mappings, not just those causing > > the issue (the KSM splitting). The result is that even migrations, etc > > that are also MERGEABLE will be skipped needlessly. > > > > If we use this approach we also don't need the first patch of the series. > > Yeah, That's also what I want to suggest. I guess I'll hold off on review until the new version is posted then. This feels like something we should have worked out in the RFC though? Thanks, Lorenzo