From patchwork Thu Mar 7 18:18:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13586113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14636C54798 for ; Thu, 7 Mar 2024 18:20:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 966826B0258; Thu, 7 Mar 2024 13:20:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 922806B0259; Thu, 7 Mar 2024 13:20:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DEA16B025A; Thu, 7 Mar 2024 13:20:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6EC006B0258 for ; Thu, 7 Mar 2024 13:20:32 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3E9FB4122B for ; Thu, 7 Mar 2024 18:20:32 +0000 (UTC) X-FDA: 81871058304.24.AE0FDB9 Received: from wfhigh3-smtp.messagingengine.com (wfhigh3-smtp.messagingengine.com [64.147.123.154]) by imf15.hostedemail.com (Postfix) with ESMTP id 31BDAA0011 for ; Thu, 7 Mar 2024 18:20:28 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="D vgTWnp"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=HhyYVyOK; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf15.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.154 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709835629; h=from:from:sender:reply-to: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: references:dkim-signature; bh=arK+NBGKdHWZ6efyHQWXlXfgQ1L/CzF1zSO+BWgFZXQ=; b=zhMO1Tkn5zsQ9Ob6YfEg2Bc96zQkuxro3YqInUS+sxNrcc5wBg7lu3tBLFPmhYndI8KB39 GCP2tVBRbagj3U/ERaA78zNvVtX+9GnfoJf6NSkBXGdLXnp+IZLcNXnX02Geq4NH/VHCbt YEcxPiOL8k+JZAUkG8tt4w28TLSpC1w= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="D vgTWnp"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=HhyYVyOK; dmarc=pass (policy=none) header.from=sent.com; spf=pass (imf15.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.154 as permitted sender) smtp.mailfrom=zi.yan@sent.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709835629; a=rsa-sha256; cv=none; b=Rp9/okCuoR19JdMrKAmgTxki3omX7IarlPRyCozjChrQjDnEuwszInWjvXzd0ok587XDa8 8xuYwkPj5WwjNhHDu9Fj5o0tqetYLb9Fw3KdjPkSnvr96xaGkEvkdkxuLWMKIZZbmdvPRs 40GIMkfv7+uCUwwQu8WnphKpmBCXL2Q= Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.west.internal (Postfix) with ESMTP id A0CBA18000CA; Thu, 7 Mar 2024 13:20:26 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 07 Mar 2024 13:20:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:message-id:mime-version:reply-to :reply-to:subject:subject:to:to; s=fm1; t=1709835626; x= 1709922026; bh=arK+NBGKdHWZ6efyHQWXlXfgQ1L/CzF1zSO+BWgFZXQ=; b=D vgTWnpExQF81NowzJzUTgnd9lYg2Yxvqc1NFwSGjL4AdA/ycBpKzffa/5eluXgj7 eGl2AI8DFJLCb9n+kKOPGQs6CmonlhWsXWHJG82SQSoCtPIz5oWbhopO04OPw2La AEq39UGxN4q/bkS6UPbKCu3C/EPrGyiBC9rlJ6iT3JL+7K63cyKYElGPm61RNxRy RqBkKANLzyKDZU+OsOC64aYA4tmbSo9UaNa8uqpA0mLHaFATy9e/OgdAhHtRvXJ2 k7AJ5Bn8uVgKQmdr2tFqIIfnDEW0eIK2XN/SGjnlVoJVDf/My0t6V8FEYV1yDaZf 3UDt9B5WFLG1KcxFYSV9w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:message-id:mime-version:reply-to:reply-to :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1709835626; x=1709922026; bh=a rK+NBGKdHWZ6efyHQWXlXfgQ1L/CzF1zSO+BWgFZXQ=; b=HhyYVyOKsumEySrPt Hqr9GLVr2KX7esjQZZTMMsuPDt9AmLAKtHvXNIhBjS9nMlkq/kyRKIlRGAJUnhnE vQ54uiRxjCnMD4jfYENEPLSYRJvNB0R1OWDkG3Sjzz71vEXDIFCcifM6v1v2ETBI 6fYgQ1AriMBHhHAnL4Z/VgPKf0AVTKtp/3XBjdM5ZP7FC8ODc8QDXnhQ42qF/xx/ 1DbTftHtGOiZzALLeRcWP9TbKN4/to4sJdG0QK38MCxUTZJa/ypoG+D8qGKGFRow Wp0K01SALTlNQ8fZixzm/s12GIzH6MkpKfGgn0OqHh/n19WkwnWWFk7huL4ZogEB yFQgg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrieefgdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofhrgggtgfesthekredtredtjeenucfhrhhomhepkghiucgj rghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepteduve ehteehheeiteeihfejveejledtgfdvieeuiedutefftdevtdfhteevtdffnecuffhomhgr ihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Mar 2024 13:20:25 -0500 (EST) From: Zi Yan To: Andrew Morton , linux-mm@kvack.org Cc: Zi Yan , Dan Carpenter , "Pankaj Raghav (Samsung)" , "Matthew Wilcox (Oracle)" , David Hildenbrand , Yang Shi , Yu Zhao , "Kirill A . Shutemov" , Ryan Roberts , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm/huge_memory: check new folio order when split a folio Date: Thu, 7 Mar 2024 13:18:53 -0500 Message-ID: <20240307181854.138928-1-zi.yan@sent.com> X-Mailer: git-send-email 2.43.0 Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Queue-Id: 31BDAA0011 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ipsw6k4ry3x6nikanugqfdwtzpj17187 X-HE-Tag: 1709835628-225209 X-HE-Meta: U2FsdGVkX1/PwSoFmXPWp0zxysmEMlCbF0QDlZOQla7VaE7Gxbex5I1RqXzgejV1qowho2xEECWRwMGHszarY7aM+MA3feK3UvZRrTZzuJ52WnwqlNDML+2IbwRApdJRHEmIKc5Il+gC7d7xzwKhvVrBa2Rc/wINn5Wf8RU7Gph5Zzu1x8bUjqrrSXH8L6DTYvANIWMx396K0Xt12pjZr2tSCbyOFjUHplvVjxsMLYr92LHxeOdp1aJgCkKCGzTLGdpZPsV2tKBVn89ekQBx86w0hj6tWgjMuqvaVFgYv0FVDmExDkjCZpNQOV4dR37wv5KPFtTPuxkzcVRb+/ITFzGREoN0dz8/BgJupQA3X8oy7uqgvzIFFItBEsW59sQQcvOKyK3owCPBETiliAE1nemhWjkjJzy+GWTEyriPlAcxvJTVn/cOEA4xYYgIOCJ2gZ/xcMpUwWqJImmPe16e605Qc24XMkn+3qENP2Av44EVtyDbbmYZGKD/uaimTLbuXlTcXCVbY3uodRYBQVCGorIqQ7GlRJI4YFWLC17AfGdmccHgyZGguwMlnT7PHZyKoBAC/Kr7uUyxak/kdxn3wtROHmwe7ku2vN2eWI4vGLZtoXvU/wLEQRluowO0khGSIwIVvfQKGM3Yiy3wI0Iol+vdkMJPRyR7nBMtQZkCabDg2R+gf8xaYvotb6nv6IK+kiY5PeZsibB5lwQF/JhztRbgdKPa4nJKfqI2KAmHj2b+0/ojFZUaM5G5o/C1iw38fANLTgwSZZSUnrNMeJjY/lmGmxeNP42kqPnIyZeWnQaklD2BGudWVdtuxpqaKVv3h0C7OFcgJMOs/NIEhvk8P3aVQby+jxa52AOFi/c+xcmEfK7rQM/gXO+nPqMNTg3S+DmFER+yVtVSfj4GVU8mEOaOdPKs1Day8Xz13PinTdpq3RuVZ48yzl9oinXwygXBjLYGJWT33Dj/l+MZodE Dp6J1BQv yIz13EBHgy3v+1trOY6yBG0BcOfjbZhUsxQz8nK9wnUNEHLwFzYAETUbYQKK+wqzgNo+uE29RUE+1knvNqQWZuBIGx4Gutl/0zZgy7GLnxDmB8lU0pkw2Yt9JGd6hsms8QhxtTZfyZ8tdWWC2YMRjrHYPAWi/lY34MroD X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Zi Yan A folio can only be split into lower orders. Check new_order to make sure it is smaller than input folio order. Link: https://lore.kernel.org/linux-mm/7dda9283-b437-4cf8-ab0d-83c330deb9c0@moroto.mountain/ Fixes: c010d47f107f ("mm: thp: split huge page to any lower order pages") Signed-off-by: Zi Yan --- mm/huge_memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index a81a09236c16..57fca7bffd20 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3052,6 +3052,9 @@ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list, VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio); VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); + if (new_order >= folio_order(folio)) + return -EINVAL; + /* Cannot split anonymous THP to order-1 */ if (new_order == 1 && folio_test_anon(folio)) { VM_WARN_ONCE(1, "Cannot split to order-1 folio");