From nobody Sun Feb 8 12:19:12 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69BA7214238 for ; Fri, 10 Jan 2025 18:22:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736533332; cv=none; b=So3jLW7/PK1otwohzbJrQPec+18EyJUE+HIV3WO9+Im0pQMA8PUccRkgEOcfPXhDdfeRGjdR2ezE5OPnNUGmwkVh5d7NnpDXA7b4pUwrg7F61RnmLMytRdZUcUENnAsQ8N5EDVRJvlgcWPSbjWyWNArczXCYw1ZdiczwsHZUKdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736533332; c=relaxed/simple; bh=8yRm31RVXs28F/17HMbcSmPgKLu6NOYU1V1JMoeGwoA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dAwUwQ3rvIP7PvtJc/cZIUXZ4QR4CrTilKdplSSWmfqMatUUB6l77bQUL1Wko2E2LgVZcsKRV4b7kZPN/MRtA7A5i73hjEbb0TC9/zKwrpYhrRRyMoYMXeyfO8n5azCtyvtE+5ZjTZwIYMsyHXvZCBdB1Ph0H93q8gzRW7vmxf0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PYa1JOSU; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PYa1JOSU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736533329; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Y6jXgybxRkLjI1AHQdA/uUdE381WdqnkZcDYSI/y9A=; b=PYa1JOSU2TGNoBqeHqME9vvcFUqdqgAYhz6mo0LcX1xeQUfP/gChNOj2d/urVfybTHSGq3 3pixoCZgvvronrp6C7Y4XwgQ/RiflQzW2QQ0lvB4OrBA4QL6rV/swwuaJVokutgXX1b5kj L70/4Gwkx4ywX+o3EdI4O0xLjqxESjs= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-338-agxhUekVN56-q_NpkPE-aA-1; Fri, 10 Jan 2025 13:22:07 -0500 X-MC-Unique: agxhUekVN56-q_NpkPE-aA-1 X-Mimecast-MFC-AGG-ID: agxhUekVN56-q_NpkPE-aA Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43619b135bcso12022415e9.1 for ; Fri, 10 Jan 2025 10:22:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736533326; x=1737138126; 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=7Y6jXgybxRkLjI1AHQdA/uUdE381WdqnkZcDYSI/y9A=; b=mpLL8U5pTBv+u3koDECqnP1P6NhkiGWXppBBR+O3DErnf7PHSpUD1uVTsO9fOLSixM fglnlnL/MW/gclycqvCJWrBAorHQBGjVauzdQAcqdWCcc/wRtNeTg9Qa4w+N3+SYngNN oNJvBlFXsFVNbfLF0oKXhszqF8yVFqxDDdd+LLPDVkR/ASX1mLf1kHxq7f6gOLv9xy0m T9qP/yGgOetQwmwvRV4GXJC7EvI1UkNpaSRDq+Ac3gO1U9ORJxcMrUppuAnxzELly2YZ 8tREFzxpy0GTZgSmzDO7e/14qaLv7ayrxXN72YSNgqr8ir6fx55GL4gzKd0ns8uyaUim k7LA== X-Gm-Message-State: AOJu0YzDUKm745HKw+y1qJktIEvKM5pd5WTY4Vu5+IKQ/s/g8yVpj+CL HZqiWvQpHXpGWHQqfNyRAZzWxSzndnX8+BOZmEEylzLL4iM1weSTa+aKWVYiSUW1GoHQCnVv9v8 ot+xjXtJq2y2jMkxv79HAAHeYBR2T10w2Jl9ekIPTM210TY1YldUyEhAaIkHPKEGAUM8NwGxiyt 6tqC3yiu3vQBRZSmo4Tc0bPdIianChFLVMJbhEEZDu872Z X-Gm-Gg: ASbGncsb3+HDi4HKaO++WZYEiwYnbczLIqqiS43VxmxlAwIFL+hbG6B/BLsO+g51zLL TWllAga89ARNFBtCHx9883RUHXIwlivPwv0W1iN5+nLeK8f9t1aDy32+S2v2Q5N+blgP2+iZ68J A71OeXaY90CP+pP0V/8FGkGQv/RQ/Vg+PyY1vJaH/BOPQRqYTJL+CDCclIWLyv/x02pHfazR3+L 1mpr2BkTAnMGgdBBegadxNPq1ZhDXeAq7ReNBw2FMumotMtMRN8UvgUeJJimT2P5U9IcHx6FYD3 3qrwT+akBGbuoEGm99K8HdOUzLwzQ9lyQbtJ89q9hw== X-Received: by 2002:a05:600c:138e:b0:431:55c1:f440 with SMTP id 5b1f17b1804b1-436e26f5f3fmr121514375e9.30.1736533325803; Fri, 10 Jan 2025 10:22:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfyPcq4pW/J8BG/r5An3xGWFuEtFy8aWLFQ30egdSLXBVyBhWxqaKAHMz46OsWfBiI1GqFlA== X-Received: by 2002:a05:600c:138e:b0:431:55c1:f440 with SMTP id 5b1f17b1804b1-436e26f5f3fmr121514035e9.30.1736533325352; Fri, 10 Jan 2025 10:22:05 -0800 (PST) Received: from localhost (p200300cbc708e1004f41ff29a59f8c7a.dip0.t-ipconnect.de. [2003:cb:c708:e100:4f41:ff29:a59f:8c7a]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-436e2da65a3sm95656095e9.7.2025.01.10.10.22.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jan 2025 10:22:04 -0800 (PST) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Muchun Song , "Matthew Wilcox (Oracle)" Subject: [PATCH v1 5/6] mm/hugetlb-cgroup: convert hugetlb_cgroup_css_offline() to work on folios Date: Fri, 10 Jan 2025 19:21:48 +0100 Message-ID: <20250110182149.746551-6-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250110182149.746551-1-david@redhat.com> References: <20250110182149.746551-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Matthew Wilcox (Oracle) --- 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 89a8ad45a533d..bb9578bd99f98 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -195,24 +195,23 @@ static void hugetlb_cgroup_css_free(struct cgroup_sub= sys_state *css) * cannot fail. */ static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_c= g, - 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 =3D parent_hugetlb_cgroup(h_cg); - struct folio *folio =3D page_folio(page); =20 - page_hcg =3D hugetlb_cgroup_from_folio(folio); + hcg =3D 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 !=3D h_cg) + if (!hcg || hcg !=3D h_cg) goto out; =20 - nr_pages =3D compound_nr(page); + nr_pages =3D folio_nr_pages(folio); if (!parent) { parent =3D 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 =3D hugetlb_cgroup_from_css(css); struct hstate *h; - struct page *page; + struct folio *folio; =20 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); =20 spin_unlock_irq(&hugetlb_lock); } --=20 2.47.1