Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp52435lqb; Tue, 4 Jun 2024 05:02:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2w7f2vfSlw4d2TZEYxG3O9u+AvM3k5Yz1kk8HXdOG5JDhrgmdEReW70xlvuarU2KzhLjG0x7ozTCaivfSgUfo6+euRfrMv70Sn3Zq5w== X-Google-Smtp-Source: AGHT+IGKArhDHTSNps3Y+jDV8Iwd75Hxq+D3i6KpE7aEKTdaK1I4ccfpvESORix2rY1+h9T0bTh8 X-Received: by 2002:a05:6214:29ee:b0:6ad:73f9:7ade with SMTP id 6a1803df08f44-6aff72735f2mr41221456d6.8.1717502528681; Tue, 04 Jun 2024 05:02:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717502528; cv=pass; d=google.com; s=arc-20160816; b=ByP6LNAIdCFed8vjl/QkAIo21plrdEcwCE3gXUeim3zKCoo5y7BCDwym6nB2QfZlBN NvEHZDyKqDsugMcWUigHZSroCrs6Vz/HD70winhDjBS6T3mjypsAOxDku6dXJ7BjMXJw h9Qz65DT8j842BSOsP0qzhsdha7UAdmEWehv6OvhDE+NTO1kspI674pnFuZQT8+c3OuX wF8IPsnKYzJ4o4R887rVPS7uQE34la8c1PSgh3HLEHlPYdEveLZrjdrG4qXYoD2U9nIT /uaiUcSfzVPFNL1wDZ5uWdwrHZAg+2PA7azmhzsqNdn3si0WmNWwca1GFXoWx/rlF6dj 17Qg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=wyzfS+26xWdhAEKu22Jk/trE6TdLI2JG9ktldvYMwZg=; fh=+URQHMcyPWHXho/LykV2u9ULlf+XKkDyMtY9pLsJc68=; b=oI4YgsFcVzGrfa3luzFdMMWQWd5zwwVgoswRH43/Z3Jg+oUaDdcAv+i3lCPIbxUSr3 u+xpI5OMj5NMh1t7oPX1TwaPRqAXRaTNRNswhASglSNVjxEPzLG3nWtxRSQpwWenvxPn y4ZB/aE0Kh3/T5ZTdBI6/LH3GVVBrTfjDs7zikstUfyqzxOocKIar+O7HRrK/OoUjcZQ QDIygukT2MIKKCbiByKt5fXABKOjqJhtV95ZWNwwUKSKxuV/FkpbUH+tP3dscSU6HRgj FSE5Pk8qI2nxezdJoVZ4NbmFz6qLF54DHECa026RFUhe1iH0AkLng924Gbor1lLFjHqH aBjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=aF3qRNJR; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-200558-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200558-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6ae4b401f8csi18251896d6.311.2024.06.04.05.02.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 05:02:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200558-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=aF3qRNJR; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-200558-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200558-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 65EA81C224B4 for ; Tue, 4 Jun 2024 12:02:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A9CF145B06; Tue, 4 Jun 2024 12:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="aF3qRNJR" Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (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 9519D1411E9 for ; Tue, 4 Jun 2024 12:01:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717502523; cv=none; b=Ibk+bJDFex89UQQB8mycDZoTWS5YBSlz2CdEy2IMXAm74YgP68EOz9LtDJUlz5ONGQiI4osfIPUzwWh3OIodopNZb2gnHkhQK686y1HsAtS2nMeL0f7XXttdCm1tLdzwHI2Oggn9vS5QlUPwK242WOZU3eoRk+WXQCILJWRtPE8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717502523; c=relaxed/simple; bh=vtntBnIejSYUixurJH5mLsIFDrhSlkp9RiJD8WK+5Oo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=A7YWXyWPE+jBolX2Y6yopfODNjRAQ5uRFph6CmHsP9a4lLXS4/isW4NuhN6R8IUL7kk+hLYPSGx8UAeBjFjkr6FFOU51TjC4GkD/zpIg/JSCecxLzuxtw1U49T6jYuPkYYYVFtal76K2TpRqcnq4krCm5p5Mdd8adrVMsTolkeI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=aF3qRNJR; arc=none smtp.client-ip=115.124.30.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1717502516; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=wyzfS+26xWdhAEKu22Jk/trE6TdLI2JG9ktldvYMwZg=; b=aF3qRNJRusm1X4cEiIbOv3j3VWZqymagb0KCp1ZLXPyLAe5yhiFAbAibTqXcp8A9es/lGXj5bcMRC25q/xyH/+Xh8HbEwsho2Nz6qEKDDnr9Smas0oyxtmzwEFRF93lUt/a4Yw8LQNV6LQTUhnzPVSX0rTJLheey9YQB5xyb2OI= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R421e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067112;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0W7r2oJB_1717502514; Received: from 30.97.56.67(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W7r2oJB_1717502514) by smtp.aliyun-inc.com; Tue, 04 Jun 2024 20:01:55 +0800 Message-ID: Date: Tue, 4 Jun 2024 20:01:54 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/page_alloc: skip THP-sized PCP list when allocating non-CMA THP-sized page To: yangge1116@126.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, liuzixing@hygon.cn, Johannes Weiner , Vlastimil Babka , Zi Yan References: <1717492460-19457-1-git-send-email-yangge1116@126.com> From: Baolin Wang In-Reply-To: <1717492460-19457-1-git-send-email-yangge1116@126.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc Johannes, Zi and Vlastimil. On 2024/6/4 17:14, yangge1116@126.com wrote: > 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) { Seems you will also miss the non-CMA THP from the PCP, so I wonder if we can add a migratetype comparison in __rmqueue_pcplist(), and if it's not suitable, then fallback to buddy? > + 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,