From nobody Fri Dec 19 07:33:28 2025 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 6318B238736 for ; Mon, 13 Jan 2025 13:16:57 +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=1736774219; cv=none; b=UoYd6xlPdD3rMrMB1RB8RoxfZoVxVjcYo+b2ORbMM4Bjw15C7oNOn3IJ1kaVi3BKt9a9F+IvYO5UCMxD36C81GnhdrWqkno2+MvQGx5HdYadr0mDM/okMpmFLtRJeJJ+hioIb0/SYiuj5lEL4DvKDIsBsx+m5Y45nuhUDAMnBM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736774219; c=relaxed/simple; bh=mAbkQKhUmgY7AwQivD9IZksXDx3cLCtSBZFJMEs8ba4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ltcrNmcExIzic0/Im8DSSnXypebCh0Z1wA3Dt1rj7NbloR5kR4/uQuQd/olebYWe+R7pgQAzPppidEVzSiXT/6d/0mIE1A08kDiUFJu+aAf2ETkJu4i4YDUU4JY0JIv027VRXcFvU0pKWxKgjdXDhJRXkk7Er0lcoyyv3n/sFKU= 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=SdMx3i4h; 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="SdMx3i4h" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736774216; 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=HRNEOcGf3GTMgcl4QTjKb5jV93l50oLMkY3MdRla6Ho=; b=SdMx3i4hwf+23oieFzf8hxQKHtevUdVbV7qa7zZml67/XlQ52kn9O/SD6OVjKxiD0W9IRT ipZw2EpHU2nYeKurtlryTeFLUsTe+SncdRmtbhczU3422eKZkK9q9JHJcPZPfHl1/bs+uP znho5/buFwzEfI6pr/h0B4G+AvOxBng= 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-600-f5En8dJLP7GqlJNYgUkpYQ-1; Mon, 13 Jan 2025 08:16:55 -0500 X-MC-Unique: f5En8dJLP7GqlJNYgUkpYQ-1 X-Mimecast-MFC-AGG-ID: f5En8dJLP7GqlJNYgUkpYQ Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43619b135bcso23263425e9.1 for ; Mon, 13 Jan 2025 05:16:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736774214; x=1737379014; 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=HRNEOcGf3GTMgcl4QTjKb5jV93l50oLMkY3MdRla6Ho=; b=eJEua/a9GWVk/rSjVLpe01vDjlw3H0rfe2EKUR0FzBU2heFaKQxA7mqW9H7sDtTqwD dURb/Zl2+DisxVyw/lh/LV3nY/V1uW4QmO3LvEmThvPm/g4Z974gXHOBf3MOs9kq5m/Y dko7zrxEHkf24UbhDzLosFdViXKbMKR19fqlw12Pt2Dz4wdQgCYEk+10cR7byP5C88Sv TJC4RT6g4QCWAzLSyHtDAHSzoCVS5/bGdjAwYnnjArGpRensxNMZhL7cjjzx2C3XG7Sx we8FOIkdxR62HsJEepyvGyx2+2gQtazVPjz+IQ7aldoxpNvbTgTbQENdFnuf8LqKJ7h3 m7kg== X-Gm-Message-State: AOJu0Yz5vdKkdrZlPINGNx1NYMQOtDsfbOU6IQyohNe49692RBIArSLj czdf9k+y8RW8Q8idAWwuG6p6YHtXTLh+GXQ9Flj8u39NfvHNmSpU+0R00NMvr9Us5t9/9iJ6ZnN y09NoYxftEzGh/BKf85E2+b8KqudSDeI+2DgM6Gm2Y3fzRrd3xRjQEs0i7gR/1mH6c3tlXURZR6 H7ETDHwVC5BgGZTJLe/MJSnmEQvvF98kNmKTKDgymyRald X-Gm-Gg: ASbGncsTsJPs4Q/Qbu4GLdGjHtBSonoGSyFaXHMzUvJzEuGasHO+1405ENsdw8I2+od 7Y/hNQduciI/lIo8d336fr0vzTzQ2Kiwu87IHqNcjfBCvtS4jIsIcYEuoGysosJFhVT/k9WM1DZ xIgOjcsF3xSTjtEDrTs/rFpXVdZ0cTOaZmidptXJw3f5G9WIyl1/aDvEvFkuCWxkdLSSueNaxVE Ax0YdmvchZM5VAob1aM7HW7nbk+Hs+m0l/NeqDlyZa8UZN8w9Vw X-Received: by 2002:a05:600c:3543:b0:434:f767:68ea with SMTP id 5b1f17b1804b1-436e2677c7dmr207456135e9.5.1736774213989; Mon, 13 Jan 2025 05:16:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKTq+E4NJrcYvXWDYuu54JFXgVM2MwdOi9Ma73C8Zz4ZeGeNjp6vUj/uympH2bo3v62O1gRA== X-Received: by 2002:a05:600c:3543:b0:434:f767:68ea with SMTP id 5b1f17b1804b1-436e2677c7dmr207455755e9.5.1736774213570; Mon, 13 Jan 2025 05:16:53 -0800 (PST) Received: from localhost ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-436e2da66d9sm179456795e9.1.2025.01.13.05.16.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jan 2025 05:16:52 -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 v2 5/6] mm/hugetlb-cgroup: convert hugetlb_cgroup_css_offline() to work on folios Date: Mon, 13 Jan 2025 14:16:10 +0100 Message-ID: <20250113131611.2554758-6-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113131611.2554758-1-david@redhat.com> References: <20250113131611.2554758-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. This removes an unnecessary call to compound_head(). Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: David Hildenbrand --- 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