Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2048192rda; Tue, 24 Oct 2023 10:40:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDKVWxovDu98mVAh1aM9bA/EQYjqfNmUkjAfU67NsXFtvbKP3tt8F964FXuxtqjpGEXHHl X-Received: by 2002:a17:902:ce88:b0:1ca:92a:df0 with SMTP id f8-20020a170902ce8800b001ca092a0df0mr14219845plg.59.1698169212002; Tue, 24 Oct 2023 10:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698169211; cv=none; d=google.com; s=arc-20160816; b=pW6c91XjruBmPgBp1caH4jPBGUBhc+oTf7J7byvdxcfpT/L8ghfSYbRDrBo6mZQ/xW 9Xss0y0ro7MosSpcisfeSfn5weU8abcoHKo4o52Wnrt17IJhyL84FDOIsImIt1q/gQSq uOfgCJegM4r70Uy7/zCC3vZTDOxBLLRwUSjy7TMvpPK8WKGy0CCwPM6JbPcZ9PEMsXU5 GQQxLf2ZVsCZmGBhiHZ9rP9l5UaQTLJFAWI9v/8RimcFq78T5JATEaG+Jo0i2GRnvvoI TG6ncB+JTYBvsS9cCxEZaA2WOM7gkIQAqoa44SyAZImbN16ekMKOAkEW8Z2pDqoMNVxn V3sw== 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=0jqecopWEo5Tu0tYTbEKGg8fX65wX9DmJTQg6zHcs64=; fh=LOC492lplOqC4GkaMZEta4CHkilCnlhS9LUDSBPxgEk=; b=faTjiBOu5zTBs91YAehC6wUiKGE4Sow1jJYnNd0UaIq/m0f10xpsBWUu6fWuiDBInr Gl71DT3qLhpQfNRnMJ82M2AB8HT7OEoGQQr0GFGXGfKsIwEgiwZGNLX4eDsfwRTqUMqy Ht0h0PplHPzK0fbiC5Et4eHUuNkrMhLPdtyA5cq/iqM545CGTNZ5+raJYos/jZF6jsDn YiecQSVyBNMbj/z6YCNBHDVvhAAg/3jbAtD5TNuG1CnVtpABao0BAWM4muQ+nNsmBCEr PliM5rQQF5pekITgKkJApDXE66huQZrZDbZaaXk3oc+iT80YVcrLTyHRsAivyjN7CppD 43vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FlD4tfHa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id y7-20020a170902b48700b001bde9e8a29fsi8330374plr.183.2023.10.24.10.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 10:40:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FlD4tfHa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B1D6B8025045; Tue, 24 Oct 2023 10:40:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234857AbjJXRkE (ORCPT + 99 others); Tue, 24 Oct 2023 13:40:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229743AbjJXRkD (ORCPT ); Tue, 24 Oct 2023 13:40:03 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B605A1 for ; Tue, 24 Oct 2023 10:40:01 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-27dc1e4d8b6so4082374a91.0 for ; Tue, 24 Oct 2023 10:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698169200; x=1698774000; darn=vger.kernel.org; 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=0jqecopWEo5Tu0tYTbEKGg8fX65wX9DmJTQg6zHcs64=; b=FlD4tfHaw5+yN4q116nrN4uczNqU8QPe3WA6vrYCX3G3kj0RwEEJxNoZb7wyb+ckQ5 M1NFBgOQkNbHt4TxOrTgHMy6RDDCZXuGYPdOiSMLUW9aOxS3JVOCsz6Zuv33kRoIX/7U cmAaGOJkPvzLGEGkGQoqvb7OIFpSyBs50Z0vpam3/3kKg+/t9YZeWKduucSERiaEOUPp mmG9wLIMowQOCC8uTijKC05SD6BvQrYjBJ30rzQpVvRDXBBZom9By+ngOILNvVtR6gD9 iHE/MZjVemLiMsZihddKyEXG7ysfeGOI7J9OMkbihD3q7118G59+OXZzkJKaB/tissP2 A4/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698169200; x=1698774000; 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=0jqecopWEo5Tu0tYTbEKGg8fX65wX9DmJTQg6zHcs64=; b=v3B6NG5SH+ZxzSrBlDqiYK3HR2Ik1nOss/9nT+LvR2AkTFlPKgrNHQ5vdW/Gk9wpz0 SA0DQynTSzhz/akAcfT3AqvRiQfBIiKsUqdU1jt9gpJsNfIPWkqcT9P6B5f5GB2UhXuw Y70HY3F2Rjiw74vIfgNLowCOON8r5IHNPPIa01TDszhZEw8RbViHgOnczFQeO6he1a3r ppmbCuRGBUNPnAxQZ/2aFxyGjFURCpFLze9pxaRhJ/U23+3H8hIcElZZhGELqLzRe0nY 8Yii+QiNTcrADq6RhEaGlD6ItnNsvQjlHV6NzXejo1+kYhbyPyr4NY2Ci4Ntd3NpvxwO MynQ== X-Gm-Message-State: AOJu0YxFA7k5Y0hqVj2CohD2zchBdJ55nM+l+uTxU/UQY8rxO2AG++79 U90jDMG8CO/WZOgB8moVZ1LQEUEzM6tWJzBFEfc= X-Received: by 2002:a17:90a:2ec5:b0:27d:97e5:f3fa with SMTP id h5-20020a17090a2ec500b0027d97e5f3famr13021834pjs.29.1698169200572; Tue, 24 Oct 2023 10:40:00 -0700 (PDT) MIME-Version: 1.0 References: <20231020183331.10770-1-vishal.moola@gmail.com> <20231020183331.10770-5-vishal.moola@gmail.com> In-Reply-To: <20231020183331.10770-5-vishal.moola@gmail.com> From: Yang Shi Date: Tue, 24 Oct 2023 10:39:48 -0700 Message-ID: Subject: Re: [PATCH v3 4/5] mm/khugepaged: Convert alloc_charge_hpage() to use folios To: "Vishal Moola (Oracle)" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 24 Oct 2023 10:40:09 -0700 (PDT) On Fri, Oct 20, 2023 at 11:34=E2=80=AFAM Vishal Moola (Oracle) wrote: > > Also remove count_memcg_page_event now that its last caller no longer use= s > it and reword hpage_collapse_alloc_page() to hpage_collapse_alloc_folio()= . > > This removes 1 call to compound_head() and helps convert khugepaged to > use folios throughout. > > Signed-off-by: Vishal Moola (Oracle) Reviewed-by: Yang Shi > --- > include/linux/memcontrol.h | 14 -------------- > mm/khugepaged.c | 17 ++++++++++------- > 2 files changed, 10 insertions(+), 21 deletions(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index ab94ad4597d0..3126bde982e8 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -1080,15 +1080,6 @@ static inline void count_memcg_events(struct mem_c= group *memcg, > local_irq_restore(flags); > } > > -static inline void count_memcg_page_event(struct page *page, > - enum vm_event_item idx) > -{ > - struct mem_cgroup *memcg =3D page_memcg(page); > - > - if (memcg) > - count_memcg_events(memcg, idx, 1); > -} > - > static inline void count_memcg_folio_events(struct folio *folio, > enum vm_event_item idx, unsigned long nr) > { > @@ -1565,11 +1556,6 @@ static inline void __count_memcg_events(struct mem= _cgroup *memcg, > { > } > > -static inline void count_memcg_page_event(struct page *page, > - int idx) > -{ > -} > - > static inline void count_memcg_folio_events(struct folio *folio, > enum vm_event_item idx, unsigned long nr) > { > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > index 9efd8ff68f06..6a7184cd291b 100644 > --- a/mm/khugepaged.c > +++ b/mm/khugepaged.c > @@ -888,16 +888,16 @@ static int hpage_collapse_find_target_node(struct c= ollapse_control *cc) > } > #endif > > -static bool hpage_collapse_alloc_page(struct page **hpage, gfp_t gfp, in= t node, > +static bool hpage_collapse_alloc_folio(struct folio **folio, gfp_t gfp, = int node, > nodemask_t *nmask) > { > - *hpage =3D __alloc_pages(gfp, HPAGE_PMD_ORDER, node, nmask); > - if (unlikely(!*hpage)) { > + *folio =3D __folio_alloc(gfp, HPAGE_PMD_ORDER, node, nmask); > + > + if (unlikely(!*folio)) { > count_vm_event(THP_COLLAPSE_ALLOC_FAILED); > return false; > } > > - folio_prep_large_rmappable((struct folio *)*hpage); > count_vm_event(THP_COLLAPSE_ALLOC); > return true; > } > @@ -1064,17 +1064,20 @@ static int alloc_charge_hpage(struct page **hpage= , struct mm_struct *mm, > int node =3D hpage_collapse_find_target_node(cc); > struct folio *folio; > > - if (!hpage_collapse_alloc_page(hpage, gfp, node, &cc->alloc_nmask= )) > + if (!hpage_collapse_alloc_folio(&folio, gfp, node, &cc->alloc_nma= sk)) { > + *hpage =3D NULL; > return SCAN_ALLOC_HUGE_PAGE_FAIL; > + } > > - folio =3D page_folio(*hpage); > if (unlikely(mem_cgroup_charge(folio, mm, gfp))) { > folio_put(folio); > *hpage =3D NULL; > return SCAN_CGROUP_CHARGE_FAIL; > } > - count_memcg_page_event(*hpage, THP_COLLAPSE_ALLOC); > > + count_memcg_folio_events(folio, THP_COLLAPSE_ALLOC, 1); > + > + *hpage =3D folio_page(folio, 0); > return SCAN_SUCCEED; > } > > -- > 2.40.1 >