From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 293BBC07E96 for ; Thu, 15 Jul 2021 04:11:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C608861279 for ; Thu, 15 Jul 2021 04:10:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C608861279 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2528F6B010D; Thu, 15 Jul 2021 00:11:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2030E6B010E; Thu, 15 Jul 2021 00:11:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CC178D002C; Thu, 15 Jul 2021 00:11:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id DEA9A6B010D for ; Thu, 15 Jul 2021 00:10:59 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CFF628248047 for ; Thu, 15 Jul 2021 04:10:58 +0000 (UTC) X-FDA: 78363496596.38.E3DACB5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 957579000704 for ; Thu, 15 Jul 2021 04:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=LhLgT/A81qTgkpFgiK6rglyDaGYwyRzTGflj66w3+ZY=; b=fJrDNGD5uJImOq3WZXtvSxcsiw rg415nhpmS9tMRq8sHBD39yJqJH77myZ7VyLGp4w2Pr8EOGdHv6nIsGh/RgpCSos3Iu8swMnY7M08 X+NaQxvSIVQqxG2hn0+FLlqsqQukn0b+45PNxux9GeP8Oqjwfk8dKKuvzlqhmMj7FZ3xjKRANccnW 29xVRSMZwUIB4bf+UvbtPqr4+zlaW8wYU74D1mQrWPinXXfGT+KcYL38j9IUHoZWacLuTDFbX4j6B FcKArWO0RvQASrPBOac/suYF86ao8h+zhsMkuBaXwCl7c2DzC2TUKnHvLbbuRcT/H3wzeZiWtUCw3 nut/wVHQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m3sgu-002wGw-VB; Thu, 15 Jul 2021 04:09:57 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig Subject: [PATCH v14 041/138] mm/memcg: Convert uncharge_page() to uncharge_folio() Date: Thu, 15 Jul 2021 04:35:27 +0100 Message-Id: <20210715033704.692967-42-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715033704.692967-1-willy@infradead.org> References: <20210715033704.692967-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=fJrDNGD5; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam02 X-Stat-Signature: uiqb5btfanuyawuxucxg9ddmpg434k87 X-Rspamd-Queue-Id: 957579000704 X-HE-Tag: 1626322258-204686 Content-Transfer-Encoding: quoted-printable 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: Use a folio rather than a page to ensure that we're only operating on base or head pages, and not tail pages. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- mm/memcontrol.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 03283d97b62a..c257cb71a3b0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6832,24 +6832,23 @@ static void uncharge_batch(const struct uncharge_= gather *ug) memcg_check_events(ug->memcg, ug->nid); local_irq_restore(flags); =20 - /* drop reference from uncharge_page */ + /* drop reference from uncharge_folio */ css_put(&ug->memcg->css); } =20 -static void uncharge_page(struct page *page, struct uncharge_gather *ug) +static void uncharge_folio(struct folio *folio, struct uncharge_gather *= ug) { - struct folio *folio =3D page_folio(page); unsigned long nr_pages; struct mem_cgroup *memcg; struct obj_cgroup *objcg; - bool use_objcg =3D PageMemcgKmem(page); + bool use_objcg =3D folio_memcg_kmem(folio); =20 - VM_BUG_ON_PAGE(PageLRU(page), page); + VM_BUG_ON_FOLIO(folio_test_lru(folio), folio); =20 /* * Nobody should be changing or seriously looking at - * page memcg or objcg at this point, we have fully - * exclusive access to the page. + * folio memcg or objcg at this point, we have fully + * exclusive access to the folio. */ if (use_objcg) { objcg =3D __folio_objcg(folio); @@ -6871,19 +6870,19 @@ static void uncharge_page(struct page *page, stru= ct uncharge_gather *ug) uncharge_gather_clear(ug); } ug->memcg =3D memcg; - ug->nid =3D page_to_nid(page); + ug->nid =3D folio_nid(folio); =20 /* pairs with css_put in uncharge_batch */ css_get(&memcg->css); } =20 - nr_pages =3D compound_nr(page); + nr_pages =3D folio_nr_pages(folio); =20 if (use_objcg) { ug->nr_memory +=3D nr_pages; ug->nr_kmem +=3D nr_pages; =20 - page->memcg_data =3D 0; + folio->memcg_data =3D 0; obj_cgroup_put(objcg); } else { /* LRU pages aren't accounted at the root level */ @@ -6891,7 +6890,7 @@ static void uncharge_page(struct page *page, struct= uncharge_gather *ug) ug->nr_memory +=3D nr_pages; ug->pgpgout++; =20 - page->memcg_data =3D 0; + folio->memcg_data =3D 0; } =20 css_put(&memcg->css); @@ -6915,7 +6914,7 @@ void mem_cgroup_uncharge(struct page *page) return; =20 uncharge_gather_clear(&ug); - uncharge_page(page, &ug); + uncharge_folio(page_folio(page), &ug); uncharge_batch(&ug); } =20 @@ -6929,14 +6928,14 @@ void mem_cgroup_uncharge(struct page *page) void mem_cgroup_uncharge_list(struct list_head *page_list) { struct uncharge_gather ug; - struct page *page; + struct folio *folio; =20 if (mem_cgroup_disabled()) return; =20 uncharge_gather_clear(&ug); - list_for_each_entry(page, page_list, lru) - uncharge_page(page, &ug); + list_for_each_entry(folio, page_list, lru) + uncharge_folio(folio, &ug); if (ug.memcg) uncharge_batch(&ug); } --=20 2.30.2