From patchwork Wed Oct 18 20:32:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13427843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49E48CDB483 for ; Wed, 18 Oct 2023 20:33:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B6B38001F; Wed, 18 Oct 2023 16:33:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 23E8B8D0016; Wed, 18 Oct 2023 16:33:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B90E8001F; Wed, 18 Oct 2023 16:33:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id ECECC8D0016 for ; Wed, 18 Oct 2023 16:33:13 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BC80580559 for ; Wed, 18 Oct 2023 20:33:13 +0000 (UTC) X-FDA: 81359731866.06.B93AA42 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by imf22.hostedemail.com (Postfix) with ESMTP id 98483C0032 for ; Wed, 18 Oct 2023 20:33:11 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RHkQzeVY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697661191; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rvpcd99NjN7SPkeCiS8fl8F++V5hN5b5iiRnzQcVK8o=; b=Yk5rujcACCqKBx99tg/DS13a1oMxYNb7ZiCBnNA/kMxqAtVZ3QBOWZ3Fm8gt+yoha9StC+ 8pJJ9re98gYOmYR8A/kc6WWTtQpOjbu88nLEcnzH4yv/iJau3gMDYLWpZBzBo69DxwbjSj aUYh1bCEufjDA6ucYBc8KbSjg+iesUM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RHkQzeVY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697661191; a=rsa-sha256; cv=none; b=aFT52FOvNNOpcPQJdVqYyywLk/TJY6Yy/oO6BPip6NxVJlscp1koVTd78K3ySFhwspmrO4 NSwFDphR0C3IOd6EmBspqmlwCrbXqqOYumMiHWou7mY/Jex88pc1mi3CiH3Plz3+sfWjk6 NeVSMbputDyMc4n/Bos0UCK+WTQpNKU= Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1c9e06f058bso748415ad.0 for ; Wed, 18 Oct 2023 13:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697661190; x=1698265990; darn=kvack.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=rvpcd99NjN7SPkeCiS8fl8F++V5hN5b5iiRnzQcVK8o=; b=RHkQzeVYswahmrL8WkNn/fgVjqsWhgJfTNqvVtYRs6Tk5zGhPcihicpvtMD3g5pUpz vvCLdcX75PkibI6SujbrZkdXusERD/idgyKS0GmTxxqgSvBmT8W2YCCzgKGq3zy85lTL /k3/a86vcrgwRx74jN/MwBKN2NmrevHG/G+jTf8oZeJ7yfSfS5Dk07ywkEA+jYKHZSiU 4wgnts0JGAmXyMrQx6yA+yAeagt7JcvE458nyc58H/+/FaJXmKmpNnEWF+Aa8SqxJaSG 0XMma9vCAgy76kEb+g8vMoSNCraem09Gk3vcGyqN1dAEfI033GZeLZg+xUgUhgBDb8kV +vNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697661190; x=1698265990; 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=rvpcd99NjN7SPkeCiS8fl8F++V5hN5b5iiRnzQcVK8o=; b=mgfi60GcYwcACxJ21VLoEH0lylbhR14f6cUnZkOyartBPzyLxOUPc+XKtvCtzwyjdi kZLjqIeLeKlI+c1b6j9/qPAZsg3JncOI3+HlC2U43CXxR5+DPmE1QkOwzvFNK4Y+9PIS hcYKafVV5MU5X91H/bFc2KR4kW8YwwbHFW2UEPlazSXdm2PHGWqpDtV8UVxH3jQ36kXg Bp3gI90nbuN0QEXMqjZFL+X6yqD2GUkhZI3RaRgbJUkehK1gMa+FKiKk4BO7zUsyflFj +Mw/f9rjkanh+Gx5YWAiSdd7Wb+CuGlqVOHqwOo91Ok04wIsl0Az6GcVqjI9xOqeV4oK XBiQ== X-Gm-Message-State: AOJu0YyHt6LgAl9MSZQdTKYto4UJzJCG6GUtw5YRQfdHGKcCD0w5duzL c4X9RAlEEvo86nUt/R+exhqS9o6KyN8= X-Google-Smtp-Source: AGHT+IEX5D/uPbXU1tWc0zw0n/3MIN2cV8mRj2GKuowCEB+zQiYHmm8zVTMDrPAIhqcUNoWkYM/oPw== X-Received: by 2002:a17:902:d2ca:b0:1c5:7d49:570e with SMTP id n10-20020a170902d2ca00b001c57d49570emr615553plc.29.1697661190159; Wed, 18 Oct 2023 13:33:10 -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 w12-20020a170902d3cc00b001c61e628e9dsm354412plb.77.2023.10.18.13.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 13:33:09 -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 v2 4/5] mm/khugepaged: Convert alloc_charge_hpage() to use folios Date: Wed, 18 Oct 2023 13:32:12 -0700 Message-Id: <20231018203213.50224-5-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018203213.50224-1-vishal.moola@gmail.com> References: <20231018203213.50224-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 98483C0032 X-Stat-Signature: 68koowuguxobw3cugs67n16xeyxnh3it X-HE-Tag: 1697661191-440016 X-HE-Meta: U2FsdGVkX1+M1JdZKVk5mMca2ZkLJPuuxQiceMPVSVawrgNXU3XR/BfJCnZ1e5Qo7gf43y9agMJC5zth2KElPYVuxMD5rNzOORJC4gRBU6mNWZrzp+VXgsxz1rfNexlaCFYFu29KnWQp3ggOKHIia2OVsqqV85Tus8kLE52uaNG8j3OOBu5tjxqbmKGjwGJl7tH6F4JjOm5aB5iT/GoCHIAq6Mp5uAcESpZ7OLNX0j4rlCCvjdds2lSS/N2MuXgZbsE4vrh5n3ZYZdby9UOnVY9MbhB18SNTibfdmiaOVH+Kx/B/rxKac6AOCOQN3nd9566FG8a8GNReRhiGlKvzUvB86fDLikkteCUvVuuY5uKC0tNw3gLhKaz8Zvf9diO4V6ZTLcAxq7e0p84ybOg069YF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EsDMHE4QcDDEfnoSqJNCKxla0MWWF0u0vEVv5mAIImUgwNLZRdSVPLBjFvFTcqZN7EVSChX+HrgX2WnoR9mHRyekaRqYIRopamgu8Vx/gLm8g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Also remove count_memcg_page_event now that its last caller no longer uses it, and 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) --- include/linux/memcontrol.h | 14 -------------- mm/khugepaged.c | 15 ++++++++------- 2 files changed, 8 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_cgroup *memcg, local_irq_restore(flags); } -static inline void count_memcg_page_event(struct page *page, - enum vm_event_item idx) -{ - struct mem_cgroup *memcg = 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..d49aa22d99c9 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -888,16 +888,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; } @@ -1064,17 +1064,18 @@ 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; } - count_memcg_page_event(*hpage, THP_COLLAPSE_ALLOC); + count_memcg_folio_events(folio, THP_COLLAPSE_ALLOC, 1); + + *hpage = folio_page(folio, 0); return SCAN_SUCCEED; }