Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3958069rdg; Wed, 18 Oct 2023 10:31:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEBv1l/aXECMcKDTH1t1BfRNplaQ1Ct4sVhFvTPdlXw3txSseyW5pthn1hVxh+MydKwa7L4 X-Received: by 2002:a05:6359:3114:b0:135:5ede:f352 with SMTP id rh20-20020a056359311400b001355edef352mr6250315rwb.8.1697650299674; Wed, 18 Oct 2023 10:31:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697650299; cv=none; d=google.com; s=arc-20160816; b=BIaA+w0vDCckZ/quShb4AMHm2i9dH35Z2iLYPp5Rj5OfA4M6jgUaQU34hcOi9ZlYa3 0cX2kmGSOl9ANZeIn3WHQqFvDIKLjpECClRvN7MGagfMPrNd9zcNWpyQcEpwQFiB9TeH P55WzCQnbfl3RaV1+pVEIWOEAqkNtBlsJMIW3ewbm7bSIZGeBqP6MncnSF7rw1gM/3jX y3DUlKXSLH4jzA7w7OejaHrPfO2cZTn0+j+yQa1/n2DYyeObFp72GXyPBRbdEInaK7MI TJy+ulAkwbMwZSMphbZ4cVv0hA5SfwZBOsDozphDXg8KgWkjAXQOvkMYIUAy3YFVrak7 zWTA== 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=mlsllgD6PkaqFDw9HMpD0Og8oMtW0iTOecosrhmZCqs=; fh=kNaEbL0rvXOberLkqSL9vHQCPAe9/DkxXl4s3xUcpTI=; b=WhqPmVhnky1NAIH70IFwamGfZZMWXogwLjSjhLfRmH9Ug/g+Na3FZZb/B8VFE9Pdkt Z0wZPIfssAlTaPhaElR2jh11DonDsYUkr80z5BHrPdduBdUCsbCyazTx2PJ8ZBS+sBy0 e3wOfVDFV1Zqwc2byReB/Ff0LgCDAXkMdEsWroJj/ZcOP/fR7Kf21Man/jM+sOMnVbGY 2RTeQL0ruCRY2mE3YZXT0wpG2S+6zz2/w8Wso67rthOoVUH7olAbDG12lLi01FU8S0Mo cLoDYogGl97Ye6j8ciQcZf3NYSXyhl4n32uVtjIIOBC3PZCdsR2uFUlXVNxlupnli5Bi nAsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LcAgY3+o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id c30-20020a056a00009e00b0068a6f6d9f7dsi4315553pfj.57.2023.10.18.10.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:31:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LcAgY3+o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id CC09F8043EDA; Wed, 18 Oct 2023 10:31:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231375AbjJRRaz (ORCPT + 99 others); Wed, 18 Oct 2023 13:30:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231289AbjJRRaM (ORCPT ); Wed, 18 Oct 2023 13:30:12 -0400 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 771C53AA9 for ; Wed, 18 Oct 2023 10:21:38 -0700 (PDT) Received: by mail-yb1-xb2b.google.com with SMTP id 3f1490d57ef6-d9a6b21d1daso8215681276.3 for ; Wed, 18 Oct 2023 10:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697649697; x=1698254497; 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=mlsllgD6PkaqFDw9HMpD0Og8oMtW0iTOecosrhmZCqs=; b=LcAgY3+o6neSteIQbN3SQskkwqcRTyWbzdkkF6N+33nQaYSBsSVPSfF/GleI4cCITb PKzHPKkaLLcExIQRtIj5hVk8ix2uv2mhBNX6+CSG/getefCEokBZH7iXLoFS5+8Cbc4a uq+LIv8UfLm/fSsyVKwJB8FLWumMdYjJtg9qfCBgVq5oCfDMNzh1aKnvhBryGsnrUtST 06dv1Chem3MQ0Mw9zVa0XzUJJKcJAagwPNYH8SGEH9N3Bxsi1zuqCe0QyiGnZtcHoxlh cQIRL4+fJSH0LvinCWc8SQ2KotyunbKQ6F5WeDzYCoD8dAo8J3MGAPQJLp2tK46bpt/U HmiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697649697; x=1698254497; 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=mlsllgD6PkaqFDw9HMpD0Og8oMtW0iTOecosrhmZCqs=; b=skdBtdtixAJskYKT9dHEMQcOqpdhp1r1gZE5V+LWz287BiqA1REG+LmHs0R+T47dL2 DhswBkpglZNFcfTS2PNxsugm7oKHA6e8at2cDwv84W3WlSYJKfe4GEMgaUCKMwkhSnJB cLImLPndVfl/0XIymtlE8QtV7TPEbd65r5B1Rlrrkmu5+l24an3CJhmDdgzf1hxQlk8P 3wVTeucNaz+TsAY1hlkwgIDg49qHHWe3+kFCJhPhsWmMh281pxWsBlJcwJKJnu0dNebN ZDPGa4iUtExY7QnMuCvFNsk5xFhPQKiRNqkORXM+8n3qHAS5rpmHj/L9hb0MB/qK36iO 7n5A== X-Gm-Message-State: AOJu0Yw6uzSYuNrRyNJlTs3WgQmoaaZOr5vMun027BmBIEXIcwXPtHam 6SWy3SAJTUVXgOyJ9fd0W/+QmRbC6Z7Z6uv3hWZ12C2q X-Received: by 2002:a25:8a92:0:b0:d9a:bbe1:1b7a with SMTP id h18-20020a258a92000000b00d9abbe11b7amr5541586ybl.50.1697649697519; Wed, 18 Oct 2023 10:21:37 -0700 (PDT) MIME-Version: 1.0 References: <20231016200510.7387-1-vishal.moola@gmail.com> <20231016200510.7387-5-vishal.moola@gmail.com> <84cdc2c3-e5e3-469b-b265-8df3e72a8c2f@huawei.com> In-Reply-To: <84cdc2c3-e5e3-469b-b265-8df3e72a8c2f@huawei.com> From: Vishal Moola Date: Wed, 18 Oct 2023 10:21:25 -0700 Message-ID: Subject: Re: [PATCH 4/5] mm/khugepaged: Convert alloc_charge_hpage() to use folios To: Kefeng Wang Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, shy828301@gmail.com 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 18 Oct 2023 10:31:33 -0700 (PDT) On Mon, Oct 16, 2023 at 8:48=E2=80=AFPM Kefeng Wang wrote: > > > > On 2023/10/17 4:05, Vishal Moola (Oracle) wrote: > > Also convert 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) > > --- > > mm/khugepaged.c | 13 +++++++------ > > 1 file changed, 7 insertions(+), 6 deletions(-) > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > index fa21a53ce0c0..70bba8ddea13 100644 > > --- a/mm/khugepaged.c > > +++ b/mm/khugepaged.c > > @@ -886,16 +886,16 @@ static int hpage_collapse_find_target_node(struct= collapse_control *cc) > > } > > #endif > > > > -static bool hpage_collapse_alloc_page(struct page **hpage, gfp_t gfp, = int 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; > > } > > @@ -1062,15 +1062,16 @@ static int alloc_charge_hpage(struct page **hpa= ge, 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)) > > 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; > > } > > + > > + *hpage =3D folio_page(folio, 0); > > count_memcg_page_event(*hpage, THP_COLLAPSE_ALLOC); > > count_memcg_folio_events=EF=BC=88=EF=BC=89and kill count_memcg_page_event= ? > > > > return SCAN_SUCCEED; Thanks, I didn't notice that was the last caller.