From patchwork Tue Jun 4 09:14:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ge Yang X-Patchwork-Id: 13684929 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 723F5C25B78 for ; Tue, 4 Jun 2024 09:14:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E65336B00B3; Tue, 4 Jun 2024 05:14:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E14856B00B4; Tue, 4 Jun 2024 05:14:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D03706B00B5; Tue, 4 Jun 2024 05:14:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B2A506B00B3 for ; Tue, 4 Jun 2024 05:14:33 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 56C26C054C for ; Tue, 4 Jun 2024 09:14:33 +0000 (UTC) X-FDA: 82192645626.06.C92A044 Received: from m16.mail.126.com (m16.mail.126.com [220.197.31.6]) by imf06.hostedemail.com (Postfix) with ESMTP id 639F0180009 for ; Tue, 4 Jun 2024 09:14:29 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=126.com header.s=s110527 header.b=ddFR8wsg; spf=pass (imf06.hostedemail.com: domain of yangge1116@126.com designates 220.197.31.6 as permitted sender) smtp.mailfrom=yangge1116@126.com; dmarc=pass (policy=none) header.from=126.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717492471; a=rsa-sha256; cv=none; b=EiVTmOGjLd1zA2wUSezByZUEAjh1jULrj5zDQsjz9l0Avb/NfE5+l852+1spBPtBvPACWn WyjPyOJeAu/Iub7zUNXzT6qx63vMehYUehfTBgP5JYtzJFBwCe9kKW9RD0mkDTBPMamQ17 yh+IG3RwBica84By5QwyIfI1Eg2sYyI= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=126.com header.s=s110527 header.b=ddFR8wsg; spf=pass (imf06.hostedemail.com: domain of yangge1116@126.com designates 220.197.31.6 as permitted sender) smtp.mailfrom=yangge1116@126.com; dmarc=pass (policy=none) header.from=126.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717492471; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:dkim-signature; bh=OttNBT7tDdR+8AIHQKEdCnsXbEagpDW5BlvkbCVKymI=; b=eo3JlwElmqFDyVM4e919dpxCeEAWuwhNoO6DN3ZfoYAhG7ENSAoZSB3jG8H3gn+sH17POg esZc+Ii/VYvKGkVt9YTGAID8RUp4mBUF3g/NLZ1pKHv/nxDkQ/3EIRLJ4TUTnykpNEOqA9 J+Z7s5RwhP1yddCJihjHDHJRTtV53Qg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=OttNBT7tDdR+8AIHQK EdCnsXbEagpDW5BlvkbCVKymI=; b=ddFR8wsgl8hZrgVsG8OTgCSXkrFUJhIVwf v2H66v3QqIt65zB3rSIOvAhmve4LvEWC4aaldZKPoTqKc1DxuoB69mulzhyjTf0b ano9jtjGSmJBeM0gt1pPqvoNayaB5ghn7hz1u40wOOT0NNfN1FDr3aAHKfhWKuqW U86hDftYk= Received: from hg-OptiPlex-7040.hygon.cn (unknown [118.242.3.34]) by gzga-smtp-mta-g1-3 (Coremail) with SMTP id _____wAnFS7u2l5mNA2KAQ--.319S2; Tue, 04 Jun 2024 17:14:23 +0800 (CST) From: yangge1116@126.com To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, baolin.wang@linux.alibaba.com, liuzixing@hygon.cn, yangge Subject: [PATCH] mm/page_alloc: skip THP-sized PCP list when allocating non-CMA THP-sized page Date: Tue, 4 Jun 2024 17:14:20 +0800 Message-Id: <1717492460-19457-1-git-send-email-yangge1116@126.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: _____wAnFS7u2l5mNA2KAQ--.319S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7KFykXw18Ww1DXFy8GF1UAwb_yoW8XryxpF Wxua4jyayfXw13Ca97J3Wqkrsxuw4vgFWUCF4fXw1UZw13ta1293s7GF90vF1fAr98AF18 tr4ktr95ZF4qyaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jxJ5rUUUUU= X-Originating-IP: [118.242.3.34] X-CM-SenderInfo: 51dqwwjhrrila6rslhhfrp/1tbiGBPzG2VLblbknQABsN X-Rspamd-Queue-Id: 639F0180009 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: ui4inhsdx8wex6dy16hec6ijpe87b7ag X-HE-Tag: 1717492469-97351 X-HE-Meta: U2FsdGVkX19YGQMW86ZWu+S/8jQlBuP/4Qmg+7g7DkLgReCEgG2Hxa7GKYDGJjNWNkKS8v4/01ZCTo4YbKGwhSJsAyqCx4qJhkKAsrE9FO1RX2HLh4BYat+O0fHipgPNG0XV4QdlOsQpOjPvRTAhn8QPf3ZlRt+G3V2x14jxbxjzM3qOh1cBBGmgKHn/3uRyUJMbz2RtlZNeD8eVYUl9EivA21hD7raBopeCE/VfJyJjMcohuHGglRE2NMscDWk1iWliPK/1bFEfVn+Yh7kb/XlyQCg+LD+z0D54+IDHVgyOM7CYje28cvbxbpF0J03gBVnZjKDLbpjnwiH/NLPgpBqJcSZyjX8m9AprjKTe2e+4cAEy2D2JG6UW439RtHf9l8Q/ExiMAXf7uoNV+0Ox+oGIxE0NjNxWfcdoRqf46SL3J04B+AEc9e4h7H6+VftJ21n9vAmfI9xyv+ZEiWyvZffiwgV7XF6yNY9POebpv+uafzFt0cuRmXwCSM+ezZZlowJJKqyxVKRoaSPheHixUfRWuvXchFerzc29D+DPF48Mb85UXmHeRh6g9d7vbZBuHe7BWvqkH8jdgvfc+G8FViSmqmlaq/NbjBGdLGjZN1xdLc/07tRZN0DNd1XzQEAUFkBO1rkvdy0/8zuD7mcn13lFdbVVce9DgdvGbowT0uf8pQ+NF9Ew40GSrFX3/DLBpaLtdYZ+xVMm+0JWf+wdQ9uHOoZBPMvBFhMYxtiQXu51QkdgS+RrcWiW/E5VKJQR1OFZFonvX45qOHbqt9rLTeIMEIUHrKhlqn/azQYmuq8uFj9MmpNPQ6H5k5ijAI/nEe8kcQF8GlgNS2geBKlnGDtjXWlgqjd9dbKl6HIa4oWyXxm9AKZ6RWMlmH+Q6EUsEk0ry4qhVOVAhKQ2tr46BP7Xs6KM1kgZ+iUSdpnMCD2GFbc3kOQ6tzxj4iUvB94bSGA35Ia+o+/c1G5PhG3 LveqoZ8x S+eC2D0tw6Tl2lpTuEio73wrJVK5V2pUyvB+omhQU6z0gjdBdsQWTcexacUfr7Ol0+eF0JqvTWQXe32MLtfTYudff6QWH8LAjKvt6i+zRHwuZf2EgMQRy//ARpnVH5l6JAW3828fneiwVjHHT3Tkv+Pwi5vQBh8dL23+lrqTvV6c9zIwAZodXgwQqDTHXL9TkYb+oxQVKVH8bfbsjTF+IiMMFuiXhVZcswahGpjByV4ZmYTxXB7+f6P/ALfG75HlEDn6QKHqhpKck6bW+T3dHua9u3M2dvOXsxvPuqBh09dcNQKI= 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: yangge Since commit 5d0a661d808f ("mm/page_alloc: use only one PCP list for THP-sized allocations") no longer differentiates the migration type of pages in THP-sized PCP list, it's possible to get a CMA page from the list, in some cases, it's not acceptable, for example, allocating a non-CMA page with PF_MEMALLOC_PIN flag returns a CMA page. The patch forbids allocating non-CMA THP-sized page from THP-sized PCP list to avoid the issue above. Fixes: 5d0a661d808f ("mm/page_alloc: use only one PCP list for THP-sized allocations") Signed-off-by: yangge --- mm/page_alloc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2e22ce5..0bdf471 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2987,10 +2987,20 @@ struct page *rmqueue(struct zone *preferred_zone, WARN_ON_ONCE((gfp_flags & __GFP_NOFAIL) && (order > 1)); if (likely(pcp_allowed_order(order))) { +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + if (!IS_ENABLED(CONFIG_CMA) || alloc_flags & ALLOC_CMA || + order != HPAGE_PMD_ORDER) { + page = rmqueue_pcplist(preferred_zone, zone, order, + migratetype, alloc_flags); + if (likely(page)) + goto out; + } +#else page = rmqueue_pcplist(preferred_zone, zone, order, migratetype, alloc_flags); if (likely(page)) goto out; +#endif } page = rmqueue_buddy(preferred_zone, zone, order, alloc_flags,