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 2BF5B28643F for ; Tue, 29 Jul 2025 15:09:35 +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=1753801776; cv=none; b=PVAgbChuTymNyuEym9pldR8TykgjHEw101UfQBgo/NC2U/gmHtq5+3j2/IFG0itKWnF0sd3GFkRjdOGQNY++heSNF/Mwpg71Z4QtW4nW+nPn+Z1JxvfVtijWTfPe7Wm6lgIjoD1ZqX7TDAQ8yFnrTYh3PZFQcKSmtYJ1iIbSXOI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753801776; c=relaxed/simple; bh=KUWUQrI+8FWHdxXSTmyu9N2HSa7QPXqVWrgprJ1np3U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Jn/dTeM/+I74ThlvwetPYUiOmVzHT/hQOHYK12HS6KbVvdfwKtNNJ1HQwQ8EhE5H2ejW9gW9j0obgZ1ph1XoBZMLiyoRgdGtz6YeKKJohQiP5YQzSAxaRD1UlCU6/KDpDrZL6sBvLm5GEljcH9CF6sG74kIFCnYGT3SHLlePu5s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E1rCrO5K; 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="E1rCrO5K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F996C4CEF5; Tue, 29 Jul 2025 15:09:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753801775; bh=KUWUQrI+8FWHdxXSTmyu9N2HSa7QPXqVWrgprJ1np3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E1rCrO5K1KrHGDgchM3gnwCnW92w9H4jL28DSJkOb7c/1y8rkvfkY8Cv5guXED+lA Matjb9rttFCo22L7DvPThkXy+BpBJccX9+VYNkIjZe40pxoMcGphAdTCnpEsV4+Nwo xz7BsWq+/HMWjBaQRYyRvRTE5ZmLfvKOTPmquQMJ8OFayvXpF6uBwvlLeuBtOfHskC hkKKDA5KzvxTlNFKR+tE1P/FwdMCyhdD7D9ue2jIHOMpdCYZ5FZd1B2MG5cPS6SdDb 928m+Kts4yThBJP3iWLCiJVsvoxl5RZTBmBAW706b8Qwacy7USDR0zKWvgFWhia2rz ajLq1PlTLJDgg== From: Sasha Levin To: stable@vger.kernel.org Cc: Harry Yoo , David Hildenbrand , Sergey Senozhatsky , Minchan Kim , Andrew Morton , Sasha Levin Subject: [PATCH 5.10.y 2/2] mm/zsmalloc: do not pass __GFP_MOVABLE if CONFIG_COMPACTION=n Date: Tue, 29 Jul 2025 11:09:29 -0400 Message-Id: <20250729150929.2729341-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250729150929.2729341-1-sashal@kernel.org> References: <2025072810-footgear-grumpily-4fd5@gregkh> <20250729150929.2729341-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Harry Yoo [ Upstream commit 694d6b99923eb05a8fd188be44e26077d19f0e21 ] Commit 48b4800a1c6a ("zsmalloc: page migration support") added support for migrating zsmalloc pages using the movable_operations migration framework. However, the commit did not take into account that zsmalloc supports migration only when CONFIG_COMPACTION is enabled. Tracing shows that zsmalloc was still passing the __GFP_MOVABLE flag even when compaction is not supported. This can result in unmovable pages being allocated from movable page blocks (even without stealing page blocks), ZONE_MOVABLE and CMA area. Possible user visible effects: - Some ZONE_MOVABLE memory can be not actually movable - CMA allocation can fail because of this - Increased memory fragmentation due to ignoring the page mobility grouping feature I'm not really sure who uses kernels without compaction support, though :( To fix this, clear the __GFP_MOVABLE flag when !IS_ENABLED(CONFIG_COMPACTION). Link: https://lkml.kernel.org/r/20250704103053.6913-1-harry.yoo@oracle.com Fixes: 48b4800a1c6a ("zsmalloc: page migration support") Signed-off-by: Harry Yoo Acked-by: David Hildenbrand Reviewed-by: Sergey Senozhatsky Cc: Minchan Kim Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- mm/zsmalloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 5f314ec2ff81..f5f80981ac98 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1067,6 +1067,9 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, if (!zspage) return NULL; + if (!IS_ENABLED(CONFIG_COMPACTION)) + gfp &= ~__GFP_MOVABLE; + zspage->magic = ZSPAGE_MAGIC; migrate_lock_init(zspage); -- 2.39.5