Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27193601rwd; Mon, 3 Jul 2023 22:49:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlG39LIuIT4JXCflWXNMBROaLrYswOIk+Yy6kYdlJIykK9xum2IiIEHEVAtqH0ijCp+Ydwjn X-Received: by 2002:a0d:e612:0:b0:56d:308f:1efa with SMTP id p18-20020a0de612000000b0056d308f1efamr12127280ywe.4.1688449741686; Mon, 03 Jul 2023 22:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688449741; cv=none; d=google.com; s=arc-20160816; b=tsBj3WVgOgEp9yWVfQ37vkIK+VwarLCz2um9JuktPRa9pjFYUdYuW6Dl+j2nU3YyoF +YCGSVPJ04/4sCpY11eQVDxbTxzbVzxcIv5qJzdOAijmUBDjwuf/ICIgypA28x5jOoVR Syuc3zWurJqwETPg5mvFVpq+MbB2gXd5wJoANmhkHVWmXdjARLQ8oUZgn9306eTolD1z GUojEN2TxWIHQtFCzDo60Zcx68qNyB0RlPQEQx2VTEKQttzhDaqsTkAYctj9v8fRp0DH TWI2HbrvIx0tU1pKi6dI04O+ppOEK8T4mCvooA69/EbMirCVkcL+WKBm52VghHGhrSXv r9Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=YigxfadlPchsL4MPXr4aopZ09B0BS+iCYyFqrVZec08=; fh=Hq0m2+cdW+g1vPhKKT4OtaPHRoP3FFbT/+Jl6c7EaXA=; b=R9L+zz/c8T1roNuNJYf7CMnyluB1w97z9xPnaZCSq+cMxQatYGrDcFUVvg2hEr3vRi UWipmM5ZXW0LhYJTHY4n+ZalhaWOPa/JE805HsIYvuEbSBQsY+6RIdzd4Er6zGKPeUac MD1BJVUAQTpy43Var6K+AOHj+gUQyIAfl4UYcWyP7eQ9vi1Zg9nSUw1UuGC2JM2XrS/f gqilaBUB/4eP5EVCZpPgfHrqvNqEaFgnnyLRlyAh3Juf/0c6d9di6na2QzTFYPDquWQR 9ZaBQ5C9X1CjNuLOuvMH5mEM38PzDLtc/z4Eu94Urln1zkMNG7b9y1Gyu181oYQyw334 cbaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=HTau2Iop; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m129-20020a632687000000b005537e4e7d59si20263038pgm.84.2023.07.03.22.48.48; Mon, 03 Jul 2023 22:49:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=HTau2Iop; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229779AbjGDFmw (ORCPT + 99 others); Tue, 4 Jul 2023 01:42:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbjGDFmu (ORCPT ); Tue, 4 Jul 2023 01:42:50 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98A9DE52 for ; Mon, 3 Jul 2023 22:42:47 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id d75a77b69052e-40371070eb7so40331cf.1 for ; Mon, 03 Jul 2023 22:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688449367; x=1691041367; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=YigxfadlPchsL4MPXr4aopZ09B0BS+iCYyFqrVZec08=; b=HTau2IopMSSukmHEEFT7Ajeb1RUP10fLukqvpMl7IZwm9gqqTNbIe/heoE4TID1yWf 79TN7IwbbNAicx9pSr/tIucLX+VIOW5x+UET95cJkBOO++e+PvUFOn73BCa7+fsCMUhW iUIu77EjCLYbzdpTz6QCH55aiFYjG1ybd07OyztYAin7wtawkd+0PNqlJp3YvhQISN8I DYu7Knk9NQuoDzhxx3uF0YBEbItm7jSE2qpp/rw9WYXw6cxgb6BMYb+UCZVhSX8f5laW VH4JeflX4FvhYx5ulzHv/kZlkc3ceK0+VITyFE5epcCs09nLDfDkeeBuPTQNkjZJuNIB 0OlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688449367; x=1691041367; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YigxfadlPchsL4MPXr4aopZ09B0BS+iCYyFqrVZec08=; b=DQ7+9PuQR/NseoQwwXRCjovSfk5Wwgn/+HswWrx1qKekQL4BlcH3Y5vrPl0nR1ynTO NdbPQZ8N7PKXmaeFfAcBSYjXs6DaU/HRoccTjhEDZ0OHlDL9EvjRmM5qAesdM2O3h1pE 54c7oHAUhpSKhaRvGYaBcvYSGpCD7qB+D0urBRKn/Zriw6axeiVWBzIaRuRwYfvvu7Hi VTQzL3S/fYA67w3Tb/RuxysBY/8Nf1NcaBy+FpRGkkpoyUVdT0CRYJookTfpW0M5FJGZ 7cdKT1yjHCk6p4aVWgbAav59Ajve0D4eWPOdEb6040vVls9cuzBFjrUT7+a7eCWJ38JI iVBg== X-Gm-Message-State: ABy/qLZ2dKqooj9X9aYLjkmVqOu8gVFZm47epOOF8KZYJZJml3ZYrGQj fbRh7z27u1dj+IQovt83XlRWn/MqF0nevGnQoxWxIHyovI4sc/VbCW5IMw== X-Received: by 2002:ac8:7f12:0:b0:3f8:5b2:aeee with SMTP id f18-20020ac87f12000000b003f805b2aeeemr58473qtk.22.1688449366648; Mon, 03 Jul 2023 22:42:46 -0700 (PDT) MIME-Version: 1.0 References: <20230703135330.1865927-1-ryan.roberts@arm.com> <20230703135330.1865927-4-ryan.roberts@arm.com> <4f86fa34-11d0-8a11-5adf-d099fc9e46b8@intel.com> In-Reply-To: <4f86fa34-11d0-8a11-5adf-d099fc9e46b8@intel.com> From: Yu Zhao Date: Mon, 3 Jul 2023 23:42:10 -0600 Message-ID: Subject: Re: [PATCH v2 3/5] mm: Default implementation of arch_wants_pte_order() To: "Yin, Fengwei" Cc: Ryan Roberts , Andrew Morton , Matthew Wilcox , "Kirill A. Shutemov" , David Hildenbrand , Catalin Marinas , Will Deacon , Anshuman Khandual , Yang Shi , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 On Mon, Jul 3, 2023 at 11:23=E2=80=AFPM Yin, Fengwei wrote: > > > > On 7/4/2023 11:59 AM, Yu Zhao wrote: > > On Mon, Jul 3, 2023 at 9:02=E2=80=AFPM Yu Zhao wrot= e: > >> > >> On Mon, Jul 3, 2023 at 8:23=E2=80=AFPM Yin, Fengwei wrote: > >>> > >>> > >>> > >>> On 7/3/2023 9:53 PM, Ryan Roberts wrote: > >>>> arch_wants_pte_order() can be overridden by the arch to return the > >>>> preferred folio order for pte-mapped memory. This is useful as some > >>>> architectures (e.g. arm64) can coalesce TLB entries when the physica= l > >>>> memory is suitably contiguous. > >>>> > >>>> The first user for this hint will be FLEXIBLE_THP, which aims to > >>>> allocate large folios for anonymous memory to reduce page faults and > >>>> other per-page operation costs. > >>>> > >>>> Here we add the default implementation of the function, used when th= e > >>>> architecture does not define it, which returns the order correspondi= ng > >>>> to 64K. > >>>> > >>>> Signed-off-by: Ryan Roberts > >>>> --- > >>>> include/linux/pgtable.h | 13 +++++++++++++ > >>>> 1 file changed, 13 insertions(+) > >>>> > >>>> diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > >>>> index a661a17173fa..f7e38598f20b 100644 > >>>> --- a/include/linux/pgtable.h > >>>> +++ b/include/linux/pgtable.h > >>>> @@ -13,6 +13,7 @@ > >>>> #include > >>>> #include > >>>> #include > >>>> +#include > >>>> > >>>> #if 5 - defined(__PAGETABLE_P4D_FOLDED) - defined(__PAGETABLE_PUD_F= OLDED) - \ > >>>> defined(__PAGETABLE_PMD_FOLDED) !=3D CONFIG_PGTABLE_LEVELS > >>>> @@ -336,6 +337,18 @@ static inline bool arch_has_hw_pte_young(void) > >>>> } > >>>> #endif > >>>> > >>>> +#ifndef arch_wants_pte_order > >>>> +/* > >>>> + * Returns preferred folio order for pte-mapped memory. Must be in = range [0, > >>>> + * PMD_SHIFT-PAGE_SHIFT) and must not be order-1 since THP requires= large folios > >>>> + * to be at least order-2. > >>>> + */ > >>>> +static inline int arch_wants_pte_order(struct vm_area_struct *vma) > >>>> +{ > >>>> + return ilog2(SZ_64K >> PAGE_SHIFT); > >>> Default value which is not related with any silicon may be: PAGE_ALLO= C_COSTLY_ORDER? > >>> > >>> Also, current pcp list support cache page with order 0...PAGE_ALLOC_C= OSTLY_ORDER, 9. > >>> If the pcp could cover the page, the pressure to zone lock will be re= duced by pcp. > >> > >> The value of PAGE_ALLOC_COSTLY_ORDER is reasonable but again it's a > >> s/w policy not a h/w preference. Besides, I don't think we can include > >> mmzone.h in pgtable.h. > > > > I think we can make a compromise: > > 1. change the default implementation of arch_has_hw_pte_young() to retu= rn 0, and > > 2. in memory.c, we can try PAGE_ALLOC_COSTLY_ORDER for archs that > > don't override arch_has_hw_pte_young(), or if its return value is too > > large to fit. > Do you mean arch_wants_pte_order()? Yes. This looks good to me. Thanks. Sorry, copied the wrong function from above and pasted without looking...