From patchwork Fri Nov 8 16:20:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13868438 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 544A4D64065 for ; Fri, 8 Nov 2024 16:20:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B77E6B009B; Fri, 8 Nov 2024 11:20:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C8FF6B009C; Fri, 8 Nov 2024 11:20:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 544D66B009D; Fri, 8 Nov 2024 11:20:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2EAF06B009B for ; Fri, 8 Nov 2024 11:20:55 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DEFB180E2E for ; Fri, 8 Nov 2024 16:20:54 +0000 (UTC) X-FDA: 82763440914.04.93F5E93 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf01.hostedemail.com (Postfix) with ESMTP id 3A4E740018 for ; Fri, 8 Nov 2024 16:20:24 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=2xqxyL89; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of 3YzouZwUKCNAFwxxw2AA270.yA8749GJ-886Hwy6.AD2@flex--tabba.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3YzouZwUKCNAFwxxw2AA270.yA8749GJ-886Hwy6.AD2@flex--tabba.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731082792; a=rsa-sha256; cv=none; b=N8ovMRwU8nrf7oEXfb8tmQemfXuK9BEtSVChWiY1kacCiJ1yN2isw9Ua6kG7ZyuYTckICD Vj4OTFfo65pqfJaNassxLPQeHzGjUeRqwsxq0cbI2tvla5VsCTAkSaAahVV1g5A0jrF2a9 SUdGexND5IRdP5Bx/7FNrHHMkkKLN6A= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=2xqxyL89; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of 3YzouZwUKCNAFwxxw2AA270.yA8749GJ-886Hwy6.AD2@flex--tabba.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3YzouZwUKCNAFwxxw2AA270.yA8749GJ-886Hwy6.AD2@flex--tabba.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731082792; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xoczasfH3EjGVlSybMjc91OekbCn/q1l859VFPlt17E=; b=a89crMn1g+Se2QEiOZbKbgyKjQRzuiNEbAoY9rOnLQ3Giewl6hKfddoJHRyRInxiy7s6Z3 E5NJ1s+Fq2Js6qr6RN3z5YLEW3UMfatAkqAojjdqVr4h2KlsBNptDH8HPS1NMOe73/JN/k TgWa3k77LLslZz2A1EiaJNOAn3QFzmE= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6eae6aba6d4so8324367b3.3 for ; Fri, 08 Nov 2024 08:20:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1731082852; x=1731687652; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xoczasfH3EjGVlSybMjc91OekbCn/q1l859VFPlt17E=; b=2xqxyL89Rj64KEsHCF1NiQshRZo2+avxutUcPnaNmDJCFgIhVvXfbbqzDcUoF2Gcoy nhwBcnlFn8LwD7+EYgiEglnMY6GV0YMeKL+Ib5fYbkx5FI8KCJraAsYWqiKvCvx2vGhw lscWlEjTEMjTuv5koSsWpAZ7KdiLLQh8gX6IHjAVXA9b1H9Vz7CN72K9fO5uqsbTERuC Kuw/y4WWl6wslemT+XRCirrSpgo7jTYb0mt2qooW3Ph2Rm2/SHFWPiQaT2t2Mv0BnNba duCvTteshzMCTBbjr0pRHBftrY5G4gD2fxoqLa4gqIIsL1ys+JKmXrRBaem4zMCUbT4I tugA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731082852; x=1731687652; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xoczasfH3EjGVlSybMjc91OekbCn/q1l859VFPlt17E=; b=GTEPiXZrSkT49mChmU/rwsC78rLmFm1cZ6sLU1XGEQB/delpjiOu4toaT3GlC/ohKk T7zrm1pslQNmMhwBL9ZRXVFwo/uoq29TgZDQdIK/BxeGQTfOBKJHuPbhPu00z99muO2C xR0G0KLM1ccjrAYbmTwGhshQuIE8VoDg95JJG+6mpLjygOwId698KXr27RtDgOcGheXy d9YUHHa9sg0FTcWuh/QjzfIwy97wEuQMghMxsG+3g60PVWUpPMXIc6kq/hyZSQg9Ygrg N8bB8m8G6R/Bi9UpFrh5QwvM2VCNZ0A9e2U/ELsueGbDuSp2wwVtyeU5UfmrDggek/bl KAkw== X-Gm-Message-State: AOJu0Yztjz2gOVFt2y3dfo9xHYOjqGU4+TDD/9cc6SojHLprx2yez8lb rHXAsSUiOPbLNlbIg/tKDCHlJkCXgPRG6fnoWU9IP5t345Q1+Pt05fNoSQE02i+E3y+axPoHZro pEU7T8hmGlxPnBe9kspi9g+DDrNwpJibgg7f7qBGJGYwmQw5PnbtGtHgfCY+fka1PxCQ5RCtwMJ Hv4Vc2Zassks8c3WHxkDNQhg== X-Google-Smtp-Source: AGHT+IGi0dElEr9qu8fzvtM9cId0LpD1vPVzTDBDvUodGuNk9OVUxqdu5KHHQFxgVeqHmDaBFP7u+PMuDw== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a05:690c:4b13:b0:6ea:decd:84e with SMTP id 00721157ae682-6eadecd0dd3mr590627b3.5.1731082851750; Fri, 08 Nov 2024 08:20:51 -0800 (PST) Date: Fri, 8 Nov 2024 16:20:34 +0000 In-Reply-To: <20241108162040.159038-1-tabba@google.com> Mime-Version: 1.0 References: <20241108162040.159038-1-tabba@google.com> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog Message-ID: <20241108162040.159038-5-tabba@google.com> Subject: [RFC PATCH v1 04/10] mm/hugetlb-cgroup: convert hugetlb_cgroup_css_offline() to work on folios From: Fuad Tabba To: linux-mm@kvack.org Cc: kvm@vger.kernel.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, david@redhat.com, rppt@kernel.org, jglisse@redhat.com, akpm@linux-foundation.org, muchun.song@linux.dev, simona@ffwll.ch, airlied@gmail.com, pbonzini@redhat.com, seanjc@google.com, willy@infradead.org, jgg@nvidia.com, jhubbard@nvidia.com, ackerleytng@google.com, vannapurve@google.com, mail@maciej.szmigiero.name, kirill.shutemov@linux.intel.com, quic_eberman@quicinc.com, maz@kernel.org, will@kernel.org, qperret@google.com, keirf@google.com, roypat@amazon.co.uk, tabba@google.com X-Rspam-User: X-Rspamd-Queue-Id: 3A4E740018 X-Rspamd-Server: rspam01 X-Stat-Signature: 5kx6uypip7b9dgnf31s6dbdnnw94ixm3 X-HE-Tag: 1731082824-223788 X-HE-Meta: U2Fsd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UwABvwGPJxF5f3ehiSjtNTINLUCRKOwnGcZz395yvA9tZAcxL5okCYMYySX+aw/TXnWurVpS6chG1u58fopR5n+bh0ZMBvKft6xqW22fXOp9SpPaOG6HLa2PqT21gY5Y9M5BC6Re3CLaRl9NBR5Ado7gRrQwRH4qOU/nv6qj7g9orNWmrD4N8YzGGJoDBP6lySP1MLdpWoxvGWeVv7ZCwTZYWwIXoxTRJ0WtYIjpN2wAFypIMcN0EXLTRlUVRN+6QIMNr8MHtrE9jlHGsN9UqkZX5J6ehaQNYw0l/cXCQNvKE6STg0APjwnNZ90/2mTDj6IYizlNCKwtoWe5JEoFtxeidKnYgTVrUXzkhCe/uBU48W5E79ynOgFqeLltiNw/V+jmlNJcWsyNZJR/m/SN4aFbJh9mX9ik7wzjZmGgUb86uc3c2T4AwTmsJvvEKKCJVnaxhIIZRZvgrMwwbxgI8YI3F/hlLYMaMz6BYpn0QMkXJ0RF41g6hJhOKG7tu0eeGEUEjBeiOqrkvsoYieMcdwvykH2rU//dGngkB3/1+PZxhPrWAdArxKko7eCr3E9w== 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: List-Subscribe: List-Unsubscribe: From: David Hildenbrand Let's convert hugetlb_cgroup_css_offline() and hugetlb_cgroup_move_parent() to work on folios. hugepage_activelist contains folios, not pages. While at it, rename page_hcg simply to hcg, removing most of the "page" terminology. Signed-off-by: David Hildenbrand Signed-off-by: Fuad Tabba --- mm/hugetlb_cgroup.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index d8d0e665caed..1bdeaf25f640 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -195,24 +195,23 @@ static void hugetlb_cgroup_css_free(struct cgroup_subsys_state *css) * cannot fail. */ static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg, - struct page *page) + struct folio *folio) { unsigned int nr_pages; struct page_counter *counter; - struct hugetlb_cgroup *page_hcg; + struct hugetlb_cgroup *hcg; struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(h_cg); - struct folio *folio = page_folio(page); - page_hcg = hugetlb_cgroup_from_folio(folio); + hcg = hugetlb_cgroup_from_folio(folio); /* * We can have pages in active list without any cgroup * ie, hugepage with less than 3 pages. We can safely * ignore those pages. */ - if (!page_hcg || page_hcg != h_cg) + if (!hcg || hcg != h_cg) goto out; - nr_pages = compound_nr(page); + nr_pages = folio_nr_pages(folio); if (!parent) { parent = root_h_cgroup; /* root has no limit */ @@ -235,13 +234,13 @@ static void hugetlb_cgroup_css_offline(struct cgroup_subsys_state *css) { struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_css(css); struct hstate *h; - struct page *page; + struct folio *folio; do { for_each_hstate(h) { spin_lock_irq(&hugetlb_lock); - list_for_each_entry(page, &h->hugepage_activelist, lru) - hugetlb_cgroup_move_parent(hstate_index(h), h_cg, page); + list_for_each_entry(folio, &h->hugepage_activelist, lru) + hugetlb_cgroup_move_parent(hstate_index(h), h_cg, folio); spin_unlock_irq(&hugetlb_lock); }