Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp102511pxv; Wed, 14 Jul 2021 23:50:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygIHiLpAjW6iB+FpRCSQ7cTXidf7eh4HhQIwwNfLnDgpzqZcBwcUcL6wtPGr1T7cahts0R X-Received: by 2002:aa7:cd96:: with SMTP id x22mr4672504edv.102.1626331846264; Wed, 14 Jul 2021 23:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626331846; cv=none; d=google.com; s=arc-20160816; b=NQoga4Vtd6odZy5X5sPC5Zmt/X2PLPYciMeW7Zgg2EGLS15fpGtVmQ0dJJpPITLwF7 oKZmrUt9Jy+iqMhUn4iwPA1qe5gt3DcS0pJJG/i6AN+9DvG53AdNaHErsTyGpYLupkRh VtVlEDtbeeBKI5P++ozVPOx3Ui5aBopjinjewpdH3wlxDlE/0fgc9q1rgijAFSGkOa65 B/3esKxFzT1DSlS7oo4VvKpMNXTRc4BCssMY5XsPtwDlrM9E71DSpimsIRG2VAd5Y53o yh2Iqlxka1rAWiQL1tzvUZ9/7ry1VH9R0n6shrpNF81JDC6nLs7Quwjcsgv5dNKtnWjK wjXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LhLgT/A81qTgkpFgiK6rglyDaGYwyRzTGflj66w3+ZY=; b=rGgB92g43Jt1/YcVyl++ZQuMnHac7CD5SBSwO85R5+5IBpBPBCwcPXA3RFztfKfpVE cpvWPj3fMvCPawphOXKEGOBPloLawrHnCXybfMQRSZ0fq6sLcOzE2/IJDmhnXTfplTX/ oz7AalUMmDzOhEFM2qgHCDE/urAvHvIbMUCt3miqRVay6InGwlymIw9fVziSmXcJ0VbP eKaB8YO86kGVzx/SRg7F1AMelBsCqGUrAWgV8YhWN6QPNOL5p/cFt/w/51EI7d3IYRCG vDjJq/WW/XH6O/GeupA3dyeAOexTdbUtSnyC6DRKxz5uZJdJWfJRv7XFtvMqPuO3+gIN 2xBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=fJrDNGD5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb8si7022838edb.414.2021.07.14.23.50.24; Wed, 14 Jul 2021 23:50:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=fJrDNGD5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235139AbhGOEON (ORCPT + 99 others); Thu, 15 Jul 2021 00:14:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231298AbhGOEOG (ORCPT ); Thu, 15 Jul 2021 00:14:06 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFB68C06175F; Wed, 14 Jul 2021 21:10:58 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); - /* drop reference from uncharge_page */ + /* drop reference from uncharge_folio */ css_put(&ug->memcg->css); } -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 = page_folio(page); unsigned long nr_pages; struct mem_cgroup *memcg; struct obj_cgroup *objcg; - bool use_objcg = PageMemcgKmem(page); + bool use_objcg = folio_memcg_kmem(folio); - VM_BUG_ON_PAGE(PageLRU(page), page); + VM_BUG_ON_FOLIO(folio_test_lru(folio), folio); /* * 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 = __folio_objcg(folio); @@ -6871,19 +6870,19 @@ static void uncharge_page(struct page *page, struct uncharge_gather *ug) uncharge_gather_clear(ug); } ug->memcg = memcg; - ug->nid = page_to_nid(page); + ug->nid = folio_nid(folio); /* pairs with css_put in uncharge_batch */ css_get(&memcg->css); } - nr_pages = compound_nr(page); + nr_pages = folio_nr_pages(folio); if (use_objcg) { ug->nr_memory += nr_pages; ug->nr_kmem += nr_pages; - page->memcg_data = 0; + folio->memcg_data = 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 += nr_pages; ug->pgpgout++; - page->memcg_data = 0; + folio->memcg_data = 0; } css_put(&memcg->css); @@ -6915,7 +6914,7 @@ void mem_cgroup_uncharge(struct page *page) return; uncharge_gather_clear(&ug); - uncharge_page(page, &ug); + uncharge_folio(page_folio(page), &ug); uncharge_batch(&ug); } @@ -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; if (mem_cgroup_disabled()) return; 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); } -- 2.30.2