From patchwork Mon Jan 13 13:16:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13937330 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 3B9F0C02180 for ; Mon, 13 Jan 2025 13:17:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE93E6B0099; Mon, 13 Jan 2025 08:16:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B98966B009A; Mon, 13 Jan 2025 08:16:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A14406B009B; Mon, 13 Jan 2025 08:16:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7D17A6B0099 for ; Mon, 13 Jan 2025 08:16:59 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 26A48801B7 for ; Mon, 13 Jan 2025 13:16:59 +0000 (UTC) X-FDA: 83002478958.01.E69DF17 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id EC608C0003 for ; Mon, 13 Jan 2025 13:16:56 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XVeM09GP; spf=pass (imf10.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736774217; a=rsa-sha256; cv=none; b=4/mg1EcbTbzVSR0FDWr41uBGdOQ6LxtU8KAxdyx8VRXgZAe8OxL48gKh01LrwCLLTBRWPa f9vFin3Y4F4oybzjodj50SX2N+opU7iZZaoHdLB4gl9HjkBpG++FQJX2rbJp+DSKp8+eRS yWVaJe+4Lo4RuuFAbiqzSSDkJ6RJGRk= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XVeM09GP; spf=pass (imf10.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736774217; 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=HRNEOcGf3GTMgcl4QTjKb5jV93l50oLMkY3MdRla6Ho=; b=hAMZ0jlXqk7Ig4EMt8bsKEpnsujUxFLd37vfkbrDwhXCITWqhfA1Rqqvdl3IP8R72FlRVr JDeFJR9TkyqihZddQPvUT8zbTPOq/bnOzsSHzQmVVd5SH39W+YukTN5XrT9F78BssXnBhg 2gpi2CdjTA2Q5b+2ciidexamivo+vlo= 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HRNEOcGf3GTMgcl4QTjKb5jV93l50oLMkY3MdRla6Ho=; b=XVeM09GPiVryyKNkNUnLgx4h+AEsRyObm+C+1Y9lFNP3BuiOpGUc0wlPTrmH5EfPyBYyCK gIy+LjqkIQAD59gbO/b+WWEhXO+zHsX/OTGhi9ma9Jx6ipBkWizorz9oS51Rz9D90DzBna CFMV9oQFSAeDat7pGY1evTtNOHs7NKg= 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-107-hFd_s03JM-ajGMRAkKQrAA-1; Mon, 13 Jan 2025 08:16:55 -0500 X-MC-Unique: hFd_s03JM-ajGMRAkKQrAA-1 X-Mimecast-MFC-AGG-ID: hFd_s03JM-ajGMRAkKQrAA Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4362552ce62so23356625e9.0 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=th7tyyiDyJQB0jCNM2tXixwaDk2NBnnQLgEsp+uMqvGHOHvuT8XYeMtyDP+3MGkXq/ 5yEUnP63UKxaGjbFyvPVeZRRJaEbVrp/+MqXAi+PWvZhx2c+2K2ipivM3ej0yLXtaLBx QQlh+c2uGCATytb2+F8Pl6Dnx8zztx/wPqrCtlmRhuVSaRK7OnfzeFVwft6jwepBLC9Q cBeMK7t2iFunWuBVBplecAZ0I2HiLxHvCVHlX3kUxalRCwv+6v7fcTArt1RXfYMj8ZIq 47ikFFQGh/dhriOON8bm4Himw6xrohGUy6EKY1L0R95Qbmsu2KEDQ8gmu/T+kBQr6p/u 19Pw== X-Gm-Message-State: AOJu0YxgFtSDf7/sJK8/O3CuBc2rnA/mb09cT2ELUlwmGvhfZMJs5pQK 73GjPMkT8FQ1XqXpKr1IqqRJfA2mROdjONcZVlqz9cbAtNfd6nEkLT3qJ6eoacWfV36Org74G1Z oQkWhEQTD7ExdDzqI06eo+SnHNO8XeewmBCMUt+wS8tBaOxiN X-Gm-Gg: ASbGncsR1+BBWJLkOYxC/rc2Po4JAMHELWvD8K8QXzt7cAvxmoNqOrSy2a/p08LTOVo ABUYK7l+OOhQ+w+xq5ym2af2T+x+aQQqnnrPB1h+sYBfX7LougK+pGfET5kprwM0V8hs7RSNcuS vroM0V4FlT46XvdABA3codlZ4jCuz67bOeOaxlFeO8RhMTFpK1Pe1PzNcptL+KZbwKGbmEz84eJ VQEEqFjSnmnS5oJZDZgymXkrxj2s7rnDhJ5vsnKuLSyEjVcpEQ1 X-Received: by 2002:a05:600c:3543:b0:434:f767:68ea with SMTP id 5b1f17b1804b1-436e2677c7dmr207456055e9.5.1736774213922; 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> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: qL6NW2CP1ozZj_6981OoB2j1-QKinL8T6sIPL4u9N_U_1736774214 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Queue-Id: EC608C0003 X-Stat-Signature: rijy6cyyjura3cx7cxk6937431493yim X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736774216-348683 X-HE-Meta: U2FsdGVkX19KFe5/NNzP/4VwauQA1Hk3xgYr5EN6KoZ64MtpIQFO4HtReygPMWnvEyjzzzAlvE3YI74U+6c4qpQFROsRLaDw4616cTZ3gdVGTTD0VJGc6FHvoOdMo9hO8OVSRLTrOEn7vJUSK5EqSr/Bp/XW+VHjfFuHsUExlzblvknBEIxG8FPfLXXLDCZs5wH4JnczqrM3B0CRtXX89uqvbKnK2Cxq13yi6W1Eb9yX4w39XRqwJERU9tlqDHjkP0S2z231U412kuBHRLZu2xXGW3EuRRWZM3KAMjXqKnxgEDP87m6vGWtRfdXJ3E3zsUBaGuhUcFJ60zCgy8PzxFpA7UJ7Rmn1SdhXi2rQvsH80fAss5lZA9GvgGo4omCTp2TY5ssaQArOv1BJrNFxWOh7WdygMNOVYpp90MhUyMuAI3+AxACqvrSsCdXMLqeuiQu5zyxhTNQ024xXQk8Ru959lTUMrbjDShCsCFO5n/JJs3T+/3u4ex+ys+OydnN8OrEtaOqa4JRH9Dlf51qCOmkbYsiU05Vb4Zr4rOzzfxRfiZQYaWknPVE+HA27SFqREtY9zSxoYhV4reOTnSMpCHONXh2aH/W4bL1B4YUUAB+vZfCmwji2izw93x4nZ18YUJj6yrzqxkoi3zbDAGhCP60uNZiXCb6x/QX1Ch2LwyQR5XRvI8BBjmmn4bxBJE+fVNkfNv/8l3jsFcBrgnr3rt3Q37xrXRzWgoDgSbJxM6XS+R4tUbwFKIipKJDzm3bGEfvXX6Han8286hw3PPMUp3ap24mBaQAeVdh4XeO+mWpH+Uk6gOpuB4Vd3lRqSIJynH78sP12IcDc1AhCDVsTSIMHss+7ZlGW0CAwL0x3W+NYTpZ+rb2Y0xCvMWVGUKI9AM6oIfN+5rzkq51PNcOaJ79dvepNdUWFAcqaEtJEqbfZZBWJZeI0Dge4gWL5PMsa3AmldcivOeRIG4j76Wb Skag+mc2 3Iivq77sr17neQDAYI9EeAoGgtNwEpUVnHowEyWC3V4lXNIjrlEXkUXSU9/lFQqMmlHurQE988P7GjdfnIPocmIw/f+QYuf8osUir22CJy9rj0bFFR2uYsTxhOPmSnwD3CUu5lman0UfOxS+lOwhBtAJggWAwucRs98MMkeDG68Fz07WaE1u8gIzt7P0SxZz0WU+32iJJTeMkZxmgCOoIUTNlBvM0PeTHlAzu87TsoPQNfeWPQj99Fr2yXoS/MSof4zIiVhVRLbAfpGAGXiphDbVjL3CyqH/LCfh1k+5eSGeai85K03A5N2Pz8r8PqN4DVNqmq4v+/n5w6A5Xz4d1B4LF3u6T4cNei0jMbeL6q2up/Or0R+38HbvZ7FbNH+o2tFWfOHIAlPfbjfXNIEPwb5VfEzkp7TMQMD+QloPtIe8Jk4WyVtZBa7NVRB8/KNhpi+CzQJsFhaAFW3e4BoQABe3jnSlPOmIDpcS7YXFyoQ6LWeputnq7HzJkSG3g9un48K0Gq4FrKD+cAvYkFIn6b+Cs5EE6b0EgQI6o25/UCTNKzf6zOWOFCzWvNwdCUnUDJEBxXIfdIL/G9Uz4e94xpi/3SC3pHapXtszUWsT+cC3kLCk= 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. 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_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); }