Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2732759rdg; Mon, 16 Oct 2023 13:07:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjUCcDHoYDi0zxfkxAEflwMMsl2vXyRd7hwvQhleyn8M8JSOvnOfqManc87/Ql4OaRbXdB X-Received: by 2002:a05:6358:799:b0:15a:8dfd:9c66 with SMTP id n25-20020a056358079900b0015a8dfd9c66mr495990rwj.28.1697486876345; Mon, 16 Oct 2023 13:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697486876; cv=none; d=google.com; s=arc-20160816; b=ibaQAs5YJGK3GYXGSq4N9g/qiatUVrz01MKmKt+Z/hmJ+5OyFuYw46X03U1fFF91rC KRjVpbr8dzJqJVa1ia654IedTPi2UwSmxaYq3ajGDDcofyzdtbD4m0B0R/M6sgAGkx7z tskB7nxyqwl43m5JsLIXfOtv3qqqlEL4wakEP5m/ZTTgHgyOpjUrFEQeov0lKi+SAI9i DxNaOr9uEkIrq6W/DIdwYPfOzrkETICXHnTgE/0NnLAzHpBFwMNg3hpF4zEAIEE7dypP Dd27ML0HPJMmBtGS2DZsd5J1pDdSet1DZku83jKzxQwt/d7A3Dzkf8oE6tEPEHur/jWV hcJg== 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 :dkim-signature; bh=mwAjlmpq6KKWWorM+tiqR60ij8VY2bcU8cxZ+UqJifo=; fh=8QxY+O3ixhfYmsFkOjVWPUpalTwBFBIvZrV0f3Brsxg=; b=Lz39oqSnpJZFSLGLWQ9Ct3KGuHxYDvO4O5a9oChQninsnMpjH1in/iXNp4ZFM5VpmP m2/2ozheRq98lVilFChNI7oCVGYia9k6q2/LqjRuFm1NHqDaPpgQh8dO3BhmI4nnDser OnWWELq+FIekTIfRxmCnhL3e8/fl0h85GpMvtoKrBYyCIFUbw2xHulNIDti4zKC3nYjq Rl5dskjIWp1WRqVGg7yhdPrCqRU4TrjPKG6HgkssWzuJRSlEsEBdRYz2I8LLJ3SVYPil Ujq+q0y2z7L1DB3uT/RQIafcBsAEb+o/cz5oIAtRjZuQfsOcGc7QsROoMj4y95JR7m3s Q5ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DIDrAM59; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id c10-20020a056a00248a00b006bdd721a84asi532679pfv.299.2023.10.16.13.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 13:07:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DIDrAM59; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 14E2F8021751; Mon, 16 Oct 2023 13:07:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234100AbjJPUHQ (ORCPT + 99 others); Mon, 16 Oct 2023 16:07:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233191AbjJPUHD (ORCPT ); Mon, 16 Oct 2023 16:07:03 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2172C103 for ; Mon, 16 Oct 2023 13:07:00 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so3676691a12.1 for ; Mon, 16 Oct 2023 13:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697486819; x=1698091619; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mwAjlmpq6KKWWorM+tiqR60ij8VY2bcU8cxZ+UqJifo=; b=DIDrAM59k6y4oW+uDak6ZadlF9PGYiZzi1Pk22E1PYPAhi9/VcS6qJa3aW9tRdPHbc DEGgOfxXfJIWEWUtYF3hfigUYpsL/MVoHQm4rIf/VihJ1iuvkk668hKTIL60dwj4nhDl B6fD+Sn2NKaXZpgJ7YPviLXgWQ4vQ3QLbyPnZgvVJsH2zbl6e18Hm1fv/2Q/UjKGLcmf KlN0aovvejO4cZy7smeAV/3brDh1ts2MYsRl4V8mRPI5oP0zYpC0y7eNfwhk/l5/GpZg pgA9Lyx2ZYCaFCQytF6bLj6WCiU1XNvlBbHT45/9ylGZ05Ha7JJBBH7HXlmLWTY8TdML 1dMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697486819; x=1698091619; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mwAjlmpq6KKWWorM+tiqR60ij8VY2bcU8cxZ+UqJifo=; b=DnWIHCCJKPyYRTVBqTtqWgL6PeDZyGAPnL3MTVpCjY86ijvcGuhgmncVBE8p/FkSH0 LNcikHrROZHQYeDR1OdpmxVQFRodZPT2rU5e4XeXfEiESJIonlUDb20i4k/I6uuAM5k0 M5EmN4IFEY1n9yWCNwt7Gy1PMEastmhrLxME8+YTX8YHCvYAy2c0h2dCg3qenNkNplJ9 1ft4MtcjdjvGbfyrrUfakdWZZude1FHK7jySc2/66lThSGGvxsdUMDWlGroWs3mg14ne /2q/I1TLpTPnGU3wv+fZM6yVQ5DhcSbp645wPsdalzc90RO7ap8o6v7c9+XiTCp7U60S ee5A== X-Gm-Message-State: AOJu0Yy3wmT3zGUFJ/SzEYGgCNnSNGnem1cXLeJgH0CwXcShIbmDjfKm wQN2vQ8pGvTAIGppHwFKdvaoF4QKw2U= X-Received: by 2002:a17:90b:245:b0:27d:4259:b7ef with SMTP id fz5-20020a17090b024500b0027d4259b7efmr190516pjb.23.1697486819203; Mon, 16 Oct 2023 13:06:59 -0700 (PDT) Received: from fedora.. (c-73-170-51-167.hsd1.ca.comcast.net. [73.170.51.167]) by smtp.googlemail.com with ESMTPSA id t16-20020a17090b019000b002772faee740sm5162367pjs.5.2023.10.16.13.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 13:06:58 -0700 (PDT) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, shy828301@gmail.com, "Vishal Moola (Oracle)" Subject: [PATCH 4/5] mm/khugepaged: Convert alloc_charge_hpage() to use folios Date: Mon, 16 Oct 2023 13:05:09 -0700 Message-Id: <20231016200510.7387-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231016200510.7387-1-vishal.moola@gmail.com> References: <20231016200510.7387-1-vishal.moola@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 16 Oct 2023 13:07:54 -0700 (PDT) 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 = __alloc_pages(gfp, HPAGE_PMD_ORDER, node, nmask); - if (unlikely(!*hpage)) { + *folio = __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 **hpage, struct mm_struct *mm, int node = 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_nmask)) return SCAN_ALLOC_HUGE_PAGE_FAIL; - folio = page_folio(*hpage); if (unlikely(mem_cgroup_charge(folio, mm, gfp))) { folio_put(folio); *hpage = NULL; return SCAN_CGROUP_CHARGE_FAIL; } + + *hpage = folio_page(folio, 0); count_memcg_page_event(*hpage, THP_COLLAPSE_ALLOC); return SCAN_SUCCEED; -- 2.40.1