From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C22033A6B96 for ; Tue, 7 Apr 2026 09:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775554998; cv=none; b=WcDIqpXVTjA6UVNXW9ZqRlRBXJOzpO0iG+gnVl9FppDVou4Ec1shwEkTz1qsLX3+Uv9JwYYOV20wi2W3YtZlPrPT6hIsZIRdYQr7dd++YiQVd7FhROJcu0PN70AHFebd0ToqE0+24n7MFFRGi3foBiOJ5OCbgpU5up8EDcuqknI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775554998; c=relaxed/simple; bh=YgnbCZ/PlXqZfBNZylsy/NQmWaxBLGRGqWF3Vx8vf2M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TTfRNp2nY8lUTNnkYlboDkFsrjozeznF8jO4eASWOVNyyI3QJg1TChYn1F6dR3fVVADQmSY6s/HoUcXdgavtgqdpFrdzwZHRSk5imJEgwRKkPdgzCQodD4UKFY3t6YtbVqk4OrRkt7LbZuvVgpG8MTCbfuFvS/q5bwi26VWGbso= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M8vGXNiL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M8vGXNiL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D096C2BCAF; Tue, 7 Apr 2026 09:43:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775554997; bh=YgnbCZ/PlXqZfBNZylsy/NQmWaxBLGRGqWF3Vx8vf2M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=M8vGXNiLZ4uoTTuW/1OzIrvqrP8aTwkJHYrLRW4RN0yvsEeEf4sa7nmL9znUdjY2h /COUlUvjP4OIf5nBqcmLqJbEGgEYxO6R61Bl8KJ9fE58urltoaB/ndm7+0FDrn7x/N oBp/wjqkhzAehzr9B18xzI6h2RY9Rzm3iUJuilnjGx/vsKVqAplg3SWuabgoQUuIYZ B83yy4zFM2SHk9Y0KESVhA5TvrgPwNi1b9Z2jwZlPE1RTo9uNxOGpYgEtIujH5AuSk vqubOBW0cweY0Aug77PlDNAesXkjZ9xXLD+AiexEmli11drGK9ZaQypvkdEnqvgxwk kN01hq29VEWqQ== Date: Tue, 7 Apr 2026 10:43:12 +0100 From: "Lorenzo Stoakes (Oracle)" To: Andrew Morton Cc: Hugh Dickins , xu.xin16@zte.com.cn, david@kernel.org, chengming.zhou@linux.dev, wang.yaxin@zte.com.cn, yang.yang29@zte.com.cn, Michel Lespinasse , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] ksm: Optimize rmap_walk_ksm by passing a suitable address range Message-ID: References: <20260212193045556CbzCX8p9gDu73tQ2nvHEI@zte.com.cn> <02e1b8df-d568-8cbb-b8f6-46d5476d9d75@google.com> <20260405140132.3a518740c6c1d68843f44aaf@linux-foundation.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: <20260405140132.3a518740c6c1d68843f44aaf@linux-foundation.org> On Sun, Apr 05, 2026 at 02:01:32PM -0700, Andrew Morton wrote: > On Sat, 4 Apr 2026 21:44:14 -0700 (PDT) Hugh Dickins wrote: > > > This is a very attractive speedup, but I believe it's flawed: in the > > special case when a range has been mremap-moved, when its anon folio > > indexes and anon_vma pgoff correspond to the original user address, > > not to the current user address. > > > > In which case, rmap_walk_ksm() will be unable to find all the PTEs > > for that KSM folio, which will consequently be pinned in memory - > > unable to be reclaimed, unable to be migrated, unable to be hotremoved, > > until it's finally unmapped or KSM disabled. > > > > But it's years since I worked on KSM or on anon_vma, so I may be confused > > and my belief wrong. I have tried to test it, and my testcase did appear > > to show 7.0-rc6 successfully swapping out even mremap-moved KSM folios, > > but mm.git failing to do so. However, I say "appear to show" because I > > found swapping out any KSM pages harder than I'd been expecting: so have > > some doubts about my testing. Let me give more detail on that at the > > bottom of this mail: it's a tangent which had better not distract from > > your speedup. > > > > If I'm right that your patch is flawed, what to do? > > Thanks, Hugh. Administreevia: > > I've removed this patch from the mm-stable branch and I reworked its > [1/2] "ksm: initialize the addr only once in rmap_walk_ksm" to be > presented as a singleton patch. > > For now I've restaged this patch ("ksm: optimize rmap_walk_ksm by > passing a suitable address range") at the tail of the mm-unstable > branch and I'll enter wait-and-see mode. > Given we're at -rc7 now, I think we should delay this patch until 7.2, unless I'm much mistaken wrt Hugh's concerns. I'm concerned this is a subtle way of breaking things so we really want to be confident. We should also bundle up the test at https://lore.kernel.org/all/20260407140805858ViqJKFhfmYSfq0FynsaEY@zte.com.cn/ with this patch (should we find it's ok) as a separate series. Really overall I think safest to yank until 7.2 honestly. Thanks, Lorenzo