Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp63947lqc; Thu, 7 Mar 2024 10:20:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVrSrbd1sIopfBInIeg3ooaGrhCfV4STJHcLYA2xqJWeC6JNBcI+HZ4cReIpH3KbLqKu54kqO8dfI5eLTcrR3jarlsaRI5EWw8MsHwS3w== X-Google-Smtp-Source: AGHT+IHM8WtOfLIUP/rE4mF9K+GxXxoTCM42xvFDVw7z7l8J/TtibtMJ9Hv1XVwInWIfV0MCjKkb X-Received: by 2002:a50:cd5d:0:b0:565:e060:5567 with SMTP id d29-20020a50cd5d000000b00565e0605567mr382453edj.31.1709835653761; Thu, 07 Mar 2024 10:20:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709835653; cv=pass; d=google.com; s=arc-20160816; b=OiVoKcx3/D66fP4n7J58MvXan6BBds5A6kKfsmSjteSaUR7Z0n+yVRn1B7Q7km1GCm xcZ5oDSghunYUq2xat49V4ooYpCozr2i/VzBtXLJZIn0Zn7hxRt0H5dB8zeWzW8gBBVO QwDuxENlbExW8k+4D7k6iQKgOwIuearUXKmb4GEG5S5D30zct8xYvLF2KD8KnDBLKQci rNko6xGXMQFZLQOZwaLbDK+mPKY9qvuVUl9zMjiz0GIHSo8LJarA8uIHb2Ad/OVK2jqY 2gZgLfeNQ5WM/iGywKzIHxYXD5cDQ9XmLZBqhMV294CFcF2OQyZYK4CjCgaAhjniabiw WjfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=Bzn2/HzPoneEzIl1irDBBJLijK1Oy0SB9DI4n9G42+Y=; fh=Opwz5f/ecgPZ5yYa7V2uA2bYr4LOQx09UzuHc71L6GU=; b=GgjfiqsKR50kdKbhyIqhlI9KPIKBEhYtEUYs0/bjFk4Jxmko6k8qNpwlK4NeThOz+m +Shhnc8ZC87Q6vewjE4pTxHgYfSBqY+M9DKHQGg/dA54L8q7ru4k5r5byEbhOAjivACj KZGBojfuS0XdRmhHMnCTzWRiDnNhfpAYoWTQJ0FQ7Ool8v6iTzD3XAnhT61fePjjLKUX Td+6gO0bLtt3QyZ2RLwfUB9xT9iZuMYVqroXnyTqylKU3f6QuKnYaUJxSdVREWeLL+Ig zE8nazRioQrZipCgIidNTf2hPEqi1dUK9JdasuLf9wYrtI2kYmUZWyBtkfwP5rvrSR+8 Arow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b="ibb/EWQQ"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="e5s/BHxf"; arc=pass (i=1 spf=pass spfdomain=sent.com dkim=pass dkdomain=sent.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=sent.com); spf=pass (google.com: domain of linux-kernel+bounces-96011-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96011-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c32-20020a509fa3000000b0056734f8683esi4381833edf.473.2024.03.07.10.20.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 10:20:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96011-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b="ibb/EWQQ"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="e5s/BHxf"; arc=pass (i=1 spf=pass spfdomain=sent.com dkim=pass dkdomain=sent.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=sent.com); spf=pass (google.com: domain of linux-kernel+bounces-96011-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96011-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 617D41F233BF for ; Thu, 7 Mar 2024 18:20:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B7D27134CD4; Thu, 7 Mar 2024 18:20:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sent.com header.i=@sent.com header.b="ibb/EWQQ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="e5s/BHxf" Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) (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 0439E1332B3 for ; Thu, 7 Mar 2024 18:20:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709835633; cv=none; b=kUYFXdU2gYsOiVAntBVTKGsnv9BjLKsZAG9vvVxa4cU+tuIJDXkSTiW5wnMzweBs7jnu0mX5AtmSQtX/d+oxXz7uns6wIwG6g9+vWwOPnTmZBlewOIClO0EHGkqD1Pp6HVq1+mN7fC547fKJFwRkmiEWWVODQfRk53MjAdi9v+A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709835633; c=relaxed/simple; bh=NON2ceGg1hFi6ieg3vTLXF6y+q6yJWEQ1tvfazwCr+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CL6sI48IABf9uYucOw6DM81sNxyumbKiJB7VUQs5GQB980dJpEEyTo7cINN9a8bvZXEidyizxFyijR0dme3NVr543FO++NhWWWLluz/V6xEq507hA4dwFOuLNyCA6dOzy0jVu5nAmjxJL3dL7xRwbHMi8+PQeFHwCVyXodee69k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sent.com; spf=pass smtp.mailfrom=sent.com; dkim=pass (2048-bit key) header.d=sent.com header.i=@sent.com header.b=ibb/EWQQ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=e5s/BHxf; arc=none smtp.client-ip=64.147.123.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sent.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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 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="utf-8" Content-Transfer-Encoding: 8bit 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; -- 2.43.0