From patchwork Thu Mar 7 18:18:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13586114 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 D85BCC54E4A for ; Thu, 7 Mar 2024 18:20:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C1BF6B0259; Thu, 7 Mar 2024 13:20:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 547246B025B; Thu, 7 Mar 2024 13:20:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C05C6B025C; Thu, 7 Mar 2024 13:20:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2E6536B0259 for ; Thu, 7 Mar 2024 13:20:34 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CC3A6C0C07 for ; Thu, 7 Mar 2024 18:20:33 +0000 (UTC) X-FDA: 81871058346.12.34FDACC Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by imf24.hostedemail.com (Postfix) with ESMTP id 8864F180028 for ; Thu, 7 Mar 2024 18:20:31 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="ibb/EWQQ"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b="e5s/BHxf"; spf=pass (imf24.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.25 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709835631; 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:in-reply-to:references:references:dkim-signature; bh=Bzn2/HzPoneEzIl1irDBBJLijK1Oy0SB9DI4n9G42+Y=; b=qyv4WjZqZDCeeIwZTAxcaZtoMJyuiF6hR/psOexYPpYLGojzU/zqfhwdBh1SAoayysjDG8 /qIiwJn2hUz63WSQiJUHTHnGNU6Y46Q4QO6XNOFkZ8asLGFqPFKYP+5zOYXb4DcX7bxN61 3USu0SThRbOF094NVX9U8bW4FGiTZl4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709835631; a=rsa-sha256; cv=none; b=gWLdipYgwEnl09HIsI2kX9FphHK452fRLqSjqEz16moqgTJY7/VsNHdGC3lR1viQkxiuuE K4t3t2ENL3Lsg0x9smZ6rq9aNPhUZPshohJR0duOHq/sbtNvsCIFIO0CEy1N43Yw7eAIfs ad0eNexy3yHsm8RoLU49OQgI3JpAMtU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b="ibb/EWQQ"; dkim=pass header.d=messagingengine.com header.s=fm1 header.b="e5s/BHxf"; spf=pass (imf24.hostedemail.com: domain of zi.yan@sent.com designates 64.147.123.25 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 1C5743200319; Thu, 7 Mar 2024 13:20:29 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 07 Mar 2024 13:20:30 -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:in-reply-to:message-id:mime-version :references:reply-to:reply-to:subject:subject:to:to; s=fm1; t= 1709835628; x=1709922028; bh=Bzn2/HzPoneEzIl1irDBBJLijK1Oy0SB9DI 4n9G42+Y=; b=ibb/EWQQhLxTZOSpDi4pGqyLnOsBGSO6hMrqx9bkeyTLNT+mIe4 hMm7msjhD5zh3dkM1dzTsiUuiBNw01j+0CntWimywpNLGE9TvaEI6KWmZQU6PctD 6F1ypPcUp6bUsTCYeNFIjdhNGleUwlwbGHTZNagBVHqhPYun0d5yI/R6pmrNgzTb f/SioJNNGNg4So5tZffWJCFAH8vJy2VIrxIdejVe2LxspFC9Kv3lzEBljTjxyGOi 1BTnX+ABz1OlleBN+uNfhiQrwWCNf1oykj5QYWKvJHJBtKYWXSd1sobvhkX/GkfS nhckEHMjOaNzNYZFw+7XBj/DSXVE1+LjyCQ== 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:in-reply-to:message-id:mime-version :references: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= 1709835628; x=1709922028; bh=Bzn2/HzPoneEzIl1irDBBJLijK1Oy0SB9DI 4n9G42+Y=; b=e5s/BHxf7qUOEHEosBWBlYKgqSQWZDXP8+wtrwv81GGqXmPB3hA EIHYZp/HxRbpNHAUlVONkGj6IIuX8/MSp8dv7aKb/SR3xR7zY+tUA8NZnhlSLcI2 mUwqsmxzd9Vc9w+ehKwBZnX2Arj9uApvebvjZnDcaxDR+Y0ul/9V2CxjTM94yUqc Zwmi2vd9mT6VR+J/5Ug26K0LfqMZo/G9WLDBhztsrr7KZ+oPEvuXJGxGD8I+Ou1S CMOQQX3qDl+FdV63rVNqzmwC1WBhiO9t+L4xc8XoK9coEmaiXdXdsfHMM5VNfida EsbPrOSGgqklOtGcBUG++Vwt3XB/Z35VkFQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrieefgdduudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhhrgggtgfesthekredtredtjeenucfhrhhomhepkghi ucgjrghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepte dtkeejffekjedulefhueetkeeijeeiheejfedvfeeihfetveegjeehgeekgffgnecuffho mhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpeiiihdrhigrnhesshgvnhhtrdgtohhm X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Mar 2024 13:20:27 -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 2/2] mm/huge_memory: skip invalid debugfs new_order input for folio split Date: Thu, 7 Mar 2024 13:18:54 -0500 Message-ID: <20240307181854.138928-2-zi.yan@sent.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240307181854.138928-1-zi.yan@sent.com> References: <20240307181854.138928-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Queue-Id: 8864F180028 X-Rspam-User: X-Stat-Signature: gbgy81e4yoqw9w968ebskest75nhtpfk X-Rspamd-Server: rspam03 X-HE-Tag: 1709835631-342629 X-HE-Meta: U2FsdGVkX1/TkwZgK9XaxYSy0uI3qyEdH3LLFbcMO86wZzF1VMCt2RU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diJ05mA9tQBnDnLcwsntH1fWCbzMUD/sXDSHfMG4c3K40JImMK9UewdSbCDTx1PE/J+de6eTFMr76oALjS1tmXTep2F7IBaMf0zZlLTgmZS6C8hbcVpbx+LPhc02bAUW6HNY+btLOpBhaBuIaUM9vnQOU/G3AqztuEcsZKvEUm1IAWKCh0HbR474druJ4XODIdUivBPI8l9Mkc2J3IBlrMpEjYmgWkvnnHC+Opwf3B33IxJmFTzsjlbd+yQu5XwlLqP8golCcgGP5NpEGjlsHvj418gg56SLxibMOcj217h5iwOD04r6xQeYmw9vctvdSi0yQXpa1Fj7VqsO4rSfL7YAdLT86Ajrn8q2E3tmz2yjEO4IBwtRj9SGxeIhQ5vQ6tw7wugLCSkMaoK9RZCLKyrgtqSFHqcKMt/aUQmJ+CsA== 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 User can put arbitrary new_order via debugfs for folio split test. Although new_order check is added to split_huge_page_to_list_order() in the prior commit, these two additional checks can avoid unnecessary folio locking and split_folio_to_order() calls. Link: https://lore.kernel.org/linux-mm/7dda9283-b437-4cf8-ab0d-83c330deb9c0@moroto.mountain/ Signed-off-by: Zi Yan --- mm/huge_memory.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 57fca7bffd20..9859aa4f7553 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3486,6 +3486,9 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, if (!is_transparent_hugepage(folio)) goto next; + if (new_order >= folio_order(folio)) + goto next; + total++; /* * For folios with private, split_huge_page_to_list_to_order() @@ -3553,6 +3556,9 @@ static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start, total++; nr_pages = folio_nr_pages(folio); + if (new_order >= folio_order(folio)) + goto next; + if (!folio_trylock(folio)) goto next;