Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4976294iob; Mon, 9 May 2022 06:09:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfos+yZuTLAtnR00waNX+x78AbI//Cv7RnHUq8wtshTj/823TfiIqtqaTwq+wvyQMBvcU2 X-Received: by 2002:a17:90b:4d84:b0:1dc:6554:1bf2 with SMTP id oj4-20020a17090b4d8400b001dc65541bf2mr18186170pjb.86.1652101758578; Mon, 09 May 2022 06:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652101758; cv=none; d=google.com; s=arc-20160816; b=HbqnxvTSeAEhU3dB+VzoQwWLG9UuPwN6AK7D8N5PomcNiny7QHKN2/qmtsX6fl3lxt mDOlRbgT0GQTcQ60kR38AVwFhfYHnTNaddzR4ch3La9qQheBnC9m2RlG4I2xZhGkNzWc QYdAiXbeCjVt87gkvUaHwRDajgqF+AejaVL0eSfPbCCbw/D/QHOk8SIr9nWAtWzWL3yY Sbwvb6tdC2hCeCFaSLesNWnAdyOP4lvGE+Pi703BOAmV+BVAZgmykngscgYiCN++CU5g VeRUf7ogpboSsIZcGNdXeA30PCh6DczL6CVpi++HmUvnCxu8CPKNvRgvnjQL+ei1slCw uTwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gWUfslv3yfiAbWgvOAL6zRxNnwAOJbgOtrRLOryq0GE=; b=WV0qJSPniSzqy2gin9Gp0uG0CyycP7Tfz8i/sEz2rToIivqnMj3vXG4PbRdg0a1/Gh 8IAoUgj/9+1H/cPWKeVjoe/yCW1dHAlP9GcuxKAw96IX3YqWTWgoW17DGuE1g24tvDO/ fQPY/qOEAtkHDPuKNOFRjeqTmj+igbSJ1nLRGR0ugjHLs8j4NpAyfx57ampeFIuyri1T LHi7qL66x3RNU/PfOFiZac+Yx4lYKxslJgH1wcboNiftyB4m2cbofp8WMJlF25+Rwnzp TxOZyu8OXFod9SxB8LWmvBzpnejXo+Q8QSx4llNJHHXYavAcM027Jp3jlTv1O2ElAH0I RVzg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j1-20020a056a00130100b0050ebd76abccsi15588126pfu.2.2022.05.09.06.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 06:09:18 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 657512A4A21; Mon, 9 May 2022 06:08:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235165AbiEINMg (ORCPT + 99 others); Mon, 9 May 2022 09:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235146AbiEINMe (ORCPT ); Mon, 9 May 2022 09:12:34 -0400 Received: from outbound-smtp47.blacknight.com (outbound-smtp47.blacknight.com [46.22.136.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4614B2A3BED for ; Mon, 9 May 2022 06:08:39 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp47.blacknight.com (Postfix) with ESMTPS id 1D72EFA7A8 for ; Mon, 9 May 2022 14:08:38 +0100 (IST) Received: (qmail 18118 invoked from network); 9 May 2022 13:08:37 -0000 Received: from unknown (HELO morpheus.112glenside.lan) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPA; 9 May 2022 13:08:37 -0000 From: Mel Gorman To: Nicolas Saenz Julienne Cc: Marcelo Tosatti , Vlastimil Babka , Michal Hocko , LKML , Linux-MM , Mel Gorman Subject: [PATCH 2/6] mm/page_alloc: Use only one PCP list for THP-sized allocations Date: Mon, 9 May 2022 14:08:01 +0100 Message-Id: <20220509130805.20335-3-mgorman@techsingularity.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220509130805.20335-1-mgorman@techsingularity.net> References: <20220509130805.20335-1-mgorman@techsingularity.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The per_cpu_pages is cache-aligned on a standard x86-64 distribution configuration but a later patch will add a new field which would push the structure into the next cache line. Use only one list to store THP-sized pages on the per-cpu list. This assumes that the vast majority of THP-sized allocations are GFP_MOVABLE but even if it was another type, it would not contribute to serious fragmentation that potentially causes a later THP allocation failure. Align per_cpu_pages on the cacheline boundary to ensure there is no false cache sharing. After this patch, the structure sizing is; struct per_cpu_pages { int count; /* 0 4 */ int high; /* 4 4 */ int batch; /* 8 4 */ short int free_factor; /* 12 2 */ short int expire; /* 14 2 */ struct list_head lists[13]; /* 16 208 */ /* size: 256, cachelines: 4, members: 6 */ /* padding: 32 */ } __attribute__((__aligned__(64))); Signed-off-by: Mel Gorman --- include/linux/mmzone.h | 11 +++++++---- mm/page_alloc.c | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 962b14d403e8..abe530748de6 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -358,15 +358,18 @@ enum zone_watermarks { }; /* - * One per migratetype for each PAGE_ALLOC_COSTLY_ORDER plus one additional - * for pageblock size for THP if configured. + * One per migratetype for each PAGE_ALLOC_COSTLY_ORDER. One additional list + * for THP which will usually be GFP_MOVABLE. Even if it is another type, + * it should not contribute to serious fragmentation causing THP allocation + * failures. */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE #define NR_PCP_THP 1 #else #define NR_PCP_THP 0 #endif -#define NR_PCP_LISTS (MIGRATE_PCPTYPES * (PAGE_ALLOC_COSTLY_ORDER + 1 + NR_PCP_THP)) +#define NR_LOWORDER_PCP_LISTS (MIGRATE_PCPTYPES * (PAGE_ALLOC_COSTLY_ORDER + 1)) +#define NR_PCP_LISTS (NR_LOWORDER_PCP_LISTS + NR_PCP_THP) /* * Shift to encode migratetype and order in the same integer, with order @@ -392,7 +395,7 @@ struct per_cpu_pages { /* Lists of pages, one per migrate type stored on the pcp-lists */ struct list_head lists[NR_PCP_LISTS]; -}; +} ____cacheline_aligned_in_smp; struct per_cpu_zonestat { #ifdef CONFIG_SMP diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 63976ad4b7f1..ed2deb93a758 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -648,7 +648,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); - base = PAGE_ALLOC_COSTLY_ORDER + 1; + return NR_LOWORDER_PCP_LISTS; } #else VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER); @@ -662,7 +662,7 @@ static inline int pindex_to_order(unsigned int pindex) int order = pindex / MIGRATE_PCPTYPES; #ifdef CONFIG_TRANSPARENT_HUGEPAGE - if (order > PAGE_ALLOC_COSTLY_ORDER) + if (pindex == NR_LOWORDER_PCP_LISTS) order = pageblock_order; #else VM_BUG_ON(order > PAGE_ALLOC_COSTLY_ORDER); -- 2.34.1