From patchwork Wed Apr 3 13:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13616203 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 DFDE4CD1288 for ; Wed, 3 Apr 2024 13:47:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46AAA6B008A; Wed, 3 Apr 2024 09:47:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41ACF6B0092; Wed, 3 Apr 2024 09:47:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 309086B0099; Wed, 3 Apr 2024 09:47:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 12F186B008A for ; Wed, 3 Apr 2024 09:47:36 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BF0251C0E4D for ; Wed, 3 Apr 2024 13:47:35 +0000 (UTC) X-FDA: 81968348070.05.3FD14D8 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) by imf30.hostedemail.com (Postfix) with ESMTP id 005BD8000E for ; Wed, 3 Apr 2024 13:47:31 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="V/7Ha1dj"; spf=pass (imf30.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.111 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712152054; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=X9pWo0FjPI342T+clcPjmo12buEGVLbb75wO5yLR45U=; b=uvVt+G23V4gMXm8hs8YQDiwfktaH7EuuBFsUcTbgXrM4aoGJKvjp7OqQQJ+mjF37ONuoBQ 72kj1RamQKPePtcnGDaNU6JU8ACJS2qJ180fdUHTTjdcRGPxMCAO8Op3rTQ8PWHAHDDXiP U12OTwIVXHQG1yu3x9T7wnLLumsUEMA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712152054; a=rsa-sha256; cv=none; b=0rcfPcwH0OAz0uYsyeuPy6xTxTn+w2QG5mHAx96HAszDFuT7TYYfL33OXd2hH9BhNDzBNT R9HVa3A0UuBRHAfxMwjleUwPAPugPliJb0S//hFa/9Gbm95+SF07T/THzbRvpHzqujyiX8 EWR5wiFT4PRA3up55zBc41DzYPzt7gI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b="V/7Ha1dj"; spf=pass (imf30.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.111 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1712152048; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=X9pWo0FjPI342T+clcPjmo12buEGVLbb75wO5yLR45U=; b=V/7Ha1dju0IrqZxTq09sHN0Hjd4TDLpjHc+l8RzMPDj9bv945mXVw0gN7whES3SHKb2QkNkTDwmv/KaAQCuQVBGT7L7pf/qeRu5QqC6BePZWS1o4XpeLcg9HyLu/zFQxnPVvjFIgbZUkThoaAy6A9mijXIz7j1Q8GU3aaY/rTZs= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0W3rs253_1712152046; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W3rs253_1712152046) by smtp.aliyun-inc.com; Wed, 03 Apr 2024 21:47:27 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: mgorman@techsingularity.net, vbabka@suse.cz, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: page_alloc: use the correct THP order for THP PCP Date: Wed, 3 Apr 2024 21:47:21 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Stat-Signature: 7ek3gkh9nnbwjrryg5nspycwym1ic7tm X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 005BD8000E X-Rspam-User: X-HE-Tag: 1712152051-24279 X-HE-Meta: U2FsdGVkX1+i7nz4+xjicl/1U3Iw6K19TswAflTwaiCjijYZp7Z27hEavUbGi1LydyrHUiYHdlVHI8NRz6YvhI/u8WsXMKLacOnOyTvrpI9q0HIkrkYmazOQhSqDz2dYbTlWkaB3NwR1cwaf5zeS3QkEGZRyD3uSwWeCB3ZwCoORma75X3ffBHwE8PBkLho7SSs0hZdYLPiRm1X8l484bXyNL7eA38dA9HAdHtuu6ZuxywQ2OWv1AkEGvswlY8SW16d3QO6FF2me9Fuv0jks+RJUBQjJ3nl1he4wzRdp4U8uMfrW+64QU96iNQRkGXV7MtuGadyf6IE214KIj+t2jU7dutGLA9yvswS36wIp/WF0Y+Qk0yDPmiDYcid7v25h9Mg73XZQ/ZoiWXpjGvEwTKwnb4JxaV3zRne058VXrWvWJQfjk2+v0z62s5lvPJ5LgxttUDwdaPotdchckqUnQ9Ky4VeJ5FdWD70v/W3u8xeMymOcvBqJnZQargjRBjf3hjDFaC5kdtRJjAvMtfoOrYHMjFyzT72mWfe6kXWAkF8lQ5/pm+NURHG24bYwqH86VIk3ezxChuNK2G/WvAmGZumRLzx3Us5Ov1IGx27dyE1zsapfJi/uTsE4ERG02cOnDAgb8MM/Exk1ySJsNcaccq2t1wO+BGMMNUGWBRYguejDDHE3aGHSPOrScJzegMh65GJYqb2KL3+gHAEgxIPgBB/Om0oh7aF9/nJ/fWWLx1YPMDLiFE4RSqfM8/ygWzhXJbiSKw8mI0nWPdmetYe0tLZvHj2QqYepA4bCHNf8MCZQcijq6FmfH8d3X1huiksCEuJKdAH46fCECoMqWSWA3/nNOOdUErfQ18etpPhtvfiOCWBOKYPc9z6g1vrmioabWZuNjvmp4GjHqMp+Bc8xQJZhMtMqexaxzpwyTDaGGlTESJDfhJn61/3oq5R4XgK997rqg8537JJjMkfrFey 5zOSoC/N bdHW9cBz3imEtzp60MO8XeyEhhqILzK0ybhYIBi88neRZnOh/ZucBTdUNuO/5s/mzxvLUYfYTbKxGgpZIZRfP0ir4xyU/zl92UsoRkS1qtMsmBDrSv6Wic9LUO6vLn8uYGrGbWhlw/y2lSNrRZ5HgFKHLgGGh3Ezqr4L60MUPMJtoGcwvx4+15rFKIdhs4t9P0FqouMkyeXeh1do17W4tqx8vGjOkz/R6VZak2Q+qQVtSV9SnkVBQuzPlvtOuur3TvlbHhVoYFLVcOjRPSzHjYLGILg== 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: Commit 44042b449872 ("mm/page_alloc: allow high-order pages to be stored on the per-cpu lists") extends the PCP allocator to store THP pages, and it determines whether to cache THP pags in PCP by comparing with pageblock_order. But the pageblock_order is not always equal to THP order, it might also be MAX_PAGE_ORDER, which could prevent PCP from caching THP pages. Therefore, using HPAGE_PMD_ORDER instead to determine the need for caching THP for PCP can fix this issue Fixes: 44042b449872 ("mm/page_alloc: allow high-order pages to be stored on the per-cpu lists") Signed-off-by: Baolin Wang Acked-by: Vlastimil Babka Reviewed-by: Barry Song --- mm/page_alloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1beb56f75319..915f4ef070da 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -506,7 +506,7 @@ static inline unsigned int order_to_pindex(int migratetype, int order) { #ifdef CONFIG_TRANSPARENT_HUGEPAGE if (order > PAGE_ALLOC_COSTLY_ORDER) { - VM_BUG_ON(order != pageblock_order); + VM_BUG_ON(order != HPAGE_PMD_ORDER); return NR_LOWORDER_PCP_LISTS; } #else @@ -522,7 +522,7 @@ static inline int pindex_to_order(unsigned int pindex) #ifdef CONFIG_TRANSPARENT_HUGEPAGE if (pindex == NR_LOWORDER_PCP_LISTS) - order = pageblock_order; + order = HPAGE_PMD_ORDER; #else VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER); #endif @@ -535,7 +535,7 @@ static inline bool pcp_allowed_order(unsigned int order) if (order <= PAGE_ALLOC_COSTLY_ORDER) return true; #ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (order == pageblock_order) + if (order == HPAGE_PMD_ORDER) return true; #endif return false;