From patchwork Fri Jan 10 18:21:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13935196 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 6F89DE77188 for ; Fri, 10 Jan 2025 18:22:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE91E6B00B0; Fri, 10 Jan 2025 13:22:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E705A6B00B1; Fri, 10 Jan 2025 13:22:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC5656B00B4; Fri, 10 Jan 2025 13:22:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A69096B00B0 for ; Fri, 10 Jan 2025 13:22:11 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2DA07A0DA5 for ; Fri, 10 Jan 2025 18:22:11 +0000 (UTC) X-FDA: 82992361662.08.F192796 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 0330040018 for ; Fri, 10 Jan 2025 18:22:08 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DMjBiTeu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736533329; a=rsa-sha256; cv=none; b=Q+QJajN+UTQOXkc5VCkHny2txGkO9wDQub4BHxyhHOrJgam4YQbkLocMICcCW7dxfnQdV5 xghaQLC9MUzjveJKlyQz1oXJvOds/UW9EnY79XqT3apKUY2HV1ejZdOVg7eXjCHoD4EkGn w0uhdTASGeT9y7HpzdQDtHwxBE4NeM8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DMjBiTeu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf12.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736533329; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7Y6jXgybxRkLjI1AHQdA/uUdE381WdqnkZcDYSI/y9A=; b=nQGl3vLDJQiToCNbHe6yF+r2nrDEOpPywqftwF9PllCLKKQydr/3BpBIO3CxYnOCzoruED DjJr90znUhIEXHya9wla6bstcfiHmyjg+izaKAExA1/xu5wsr7ihR6MFsgarsNUbsIEIOb Vd1cAk9mFK6iZlEegmpeNTk8eyidNgo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736533328; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7Y6jXgybxRkLjI1AHQdA/uUdE381WdqnkZcDYSI/y9A=; b=DMjBiTeu2UBgD0g7++rFhaj/0JV1e+CaGurvRaeKCDGLra2jwmD+HDp/2n/qtiJ6LThw0m y++UFTGJ94KdR+/oHyiZbGRtv2ALANw3ntwPpjouQE6ZRRMpJ9GUG3/f4iANqcoXAStcCm tQAuVbsD4K1LnYu8T5r3SGJE0x2SfFk= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-116-9wxVbD_DOkuklWIWwdwfig-1; Fri, 10 Jan 2025 13:22:07 -0500 X-MC-Unique: 9wxVbD_DOkuklWIWwdwfig-1 X-Mimecast-MFC-AGG-ID: 9wxVbD_DOkuklWIWwdwfig Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4361a8fc3bdso11985895e9.2 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=g+AwTrevRpdHH3m2EKVvqNYfussUtLbt99tH7LAmfLNeRMbgv4O2OV7w3vvtJB9BAr 5ZetxSXmK6OxQsz95Lpn9i4iqW5eOgI7q88HXCCzHf2rwogZu9a3MC5MqOKe+HzsYuB1 r8QotbXf2pw02KtD+UigGcCmmcz+O6JCLqetu64I51NTeOIO76GkZd+ZZrPZmt6FcqO/ qt9dLkKAk16hc+mkpkuovOIeffyOhvv/3AvRgfVLN00CwX+GtVRDjqzSB8jvOUllG9Ku na3xZoVnTFrzgsTIUW8wWhuWwEEvHB3quUPJ9jIj69lZJ4+7G+8rKX3tv9TQ56PTX1NH Mezw== X-Gm-Message-State: AOJu0YxShQzv6SnWMXeideOJhAZ7Ff+IMHNxkV4Dx9eGecS87R3Jb+AS b6qnvRcrqEsVGA4G+JD66PbFJXZ1jryT6hyX4qhk+AMP18iV0D6mqpKrr5KLrESWOqDnUBVoFuK 7Gq4OPZVeG5C2MUVKOIgnZRgFC8LWSJ4f4mD7DJ6dG3w9C8hd X-Gm-Gg: ASbGnctlK+/6WaoQ31Em5IDkFNmerd0/YMAGqaRNk0SICvEOi+aUYtzUCkuQgMUbRee Vw1lrONkYvy5kJobzCE/2NaNwd3Amm2ZR3vtko7x2A9l/zeLYckJ2qvvTdm29S78WQSHCxu0uGM c6zFW6SEVOL2xf67sq/A6ZInjO91RFd+5i/ylXRHbOvNjI6C4L6us17hQ54r8OPEIWk67xeXMic dMHJ8WiQZzIOjMngLs8b+/zAZ6sfKw7z1GClbbTO7NpJbEs2bqzqD70+Y/D2qUEEUH86bEZaudF dqc6tB0/IOBijqQRaQL9aEgsnpRQAFR6Wr/3ztOofQ== X-Received: by 2002:a05:600c:138e:b0:431:55c1:f440 with SMTP id 5b1f17b1804b1-436e26f5f3fmr121514265e9.30.1736533325717; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: tiFZ2IZngdFCUBrBxSvo0rLZz5EJDN-VDBp0VcENDVg_1736533326 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0330040018 X-Stat-Signature: x8ddafau9gpnxuwf75o37nudwfuhuexa X-Rspam-User: X-HE-Tag: 1736533328-168710 X-HE-Meta: U2FsdGVkX1+TO+L+qBGuo0qLCwOLTna1cUtqyhhmha+TG7U03d/ycxgErTXkfnltFLPrMJ6bKyyC8GEpjnAVidCqI1ukeLazp7hTyTSFfpw1ontrD7zPxmIK0rQhFckYHmNdPA29QorlK8F4knzCTKJQSgvm0FzpjJOc6N0a/3GvIyg2OMGbbNwvJ8MXlOKqClKVNjRiiaLYJltMe4q01S3LNPyyiu0J1/Fp0rBcKbAlynpqhgG4z5E4JjHghALgyrCJNTYwqCrq2sXAZaO0KA0mltyVDXjHQjKRQ2t4gRc4p4PsMgdQbnasL3kEgYiRzSTbkFEXNV98MHcPizk6mwibAK2E8lSYHv5kxeDHlkO2SRhhSiGRN+pK8NNJot2AgLpwaNyvTuSkERN7xSpFYO4pTduzdBuRWoTPzC8TjdkxMGE6hrJOtBBMt5v6lwNaHpKN8DXMUPlNSTKfQ8lUGZx0Ramb3G6C1Ujcbvht9fa1wFLYY6wgYmme8/9Jt+HeOegy5NUEZXv5A/7bE4JThTkR4al9GzqIVcsNE/26dXTw59ChuHUdWja9oFUREDPeMQ/iVuhOblpsp3C7EmnHo1nNa5K6qQZm0bEIJFlWE7KCw8S2AlzcN2x1XwklBQiBwhUw4ZYHjdsJd3Or6vpG34TZDfhcudNk8tgtDV8/p6QenS+ZD6+oJxIsBTR/D4bn5dTD6BHEpTwJv00/E/yBryw851EeG5zT1ZBvTBLtCPU7nnjG5/flcjs3yrgRcI4ODvPJo3/JvFcI/Hl4V8mtiv0UJ2IoaNxgb2XBtB6v+42lIJy/eNv28cYVRdvwGaAxb2E9QAaBjdLu4gvNsxVdxY6SF58WIi+6/DIxqOKnY++e5ghgYF42RBLKvCGbWB1b5FeTWCj1I7L13KzWnHUBg3rFztZUcDqSb7bFI2vQQUg0hSPMVFyUHU9wQ8+R5RvRBrw2109hx8C8Rj5d+b7 AvpC8nYW VlQtHOjZU1Vb3ZZKxR+r31ftpYHwuWjQDyc5eFO90yZ7H9XO5mFgnBSJVHfRQTi5ny1pFG+xtaZLgzYSak2BYAQUFQQo5RKQQnuky6JG62fJrI00VJ1Ginrhtf2WWiZYbuQS9YD6beNPksqNN80NsUjyCV58EpvhiMGzTFsvq3LioeDMeTHRtimiNtcJIDLucGrVXvYrwzI8HbfjyYUyGhu4SpLxbrr/g+KMfceCILGOWx74p2jylIdPSqIRIuRZGIxgbhPlByh/RRmbxoJLq3P79AjyhuzYwdJnx/pwv4d3xTVU2AymdqRY/tCiKjhNF9TBN4XaEvRivLetkd9mJg08FPjrBondzunkdwMOIZyb0QJqOmC2JH7ptEPuCPsp5wX05ML8oK7JoAoyhvNbRfy7//vO7ao50bVCAr+tex4nvGQb54U4CMrFMzIaeICSQIfJVTmZ4orJtzwNYQ5v68FLw1NjP4u1RIfYyCdbxgO7okolnqcHUPTuRVnTRc/uDMgDEbnXgAzY/XvHEOv4ACnHHXA== 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: 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_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); }