From patchwork Tue Jun 22 12:15:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12337179 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.5 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,URIBL_BLOCKED,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 EA3D2C2B9F4 for ; Tue, 22 Jun 2021 12:28:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8411D608FE for ; Tue, 22 Jun 2021 12:28:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8411D608FE 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 0A7386B007D; Tue, 22 Jun 2021 08:28:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 07E466B0082; Tue, 22 Jun 2021 08:28:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9B596B0083; Tue, 22 Jun 2021 08:28:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id B7CB76B007D for ; Tue, 22 Jun 2021 08:28:57 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4AE5E117FA for ; Tue, 22 Jun 2021 12:28:57 +0000 (UTC) X-FDA: 78281289114.39.8A71893 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf09.hostedemail.com (Postfix) with ESMTP id D1A3F60019DD for ; Tue, 22 Jun 2021 12:28:56 +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=LE1s1f8C2h8T4UyScp99hxGO6Hckcptj65nY+NL6uuE=; b=cfbW3Zw0GintsetvHWD3aJjhjB ZUF9vXySeo2gIzkgzdVe4C7Ao7VOlM1uR2Klnc6g3Sb9z2FT6ntx1T4eu+CQG1gOzhLfvssTiBheG 6VaI5lpFq5xDePZBe8GfFIdMyLgqC0Cn4lT/ZcZZvUzAV030M1tlMGAoQ+qiimZkqHyQkM/XSzQz/ 41AdUgzALUd+4KAdi+ui/91zB6nq+YUJRN8uk7m9NYycWkW39kUWlZWh9rCAWaL1c1mfwkZto6zN+ AC6rTOLvqv1a6XwQJtrWSByWYnAhZhESrIJobCz1IuXjxqf4iiPbxIZJg74Vhr+qIohDcfZo7I1CM PuSgTWmQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvfUw-00EH3D-AC; Tue, 22 Jun 2021 12:27:38 +0000 From: "Matthew Wilcox (Oracle)" To: akpm@linux-foundation.org Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 15/46] mm/memcg: Add folio_uncharge_cgroup() Date: Tue, 22 Jun 2021 13:15:20 +0100 Message-Id: <20210622121551.3398730-16-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210622121551.3398730-1-willy@infradead.org> References: <20210622121551.3398730-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D1A3F60019DD X-Stat-Signature: fjmxmfqanm1cyu8r1gheiwgwpea6auik Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cfbW3Zw0; dmarc=none; spf=none (imf09.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1624364936-511550 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Reimplement mem_cgroup_uncharge() as a wrapper around folio_uncharge_cgroup(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- include/linux/memcontrol.h | 5 +++++ mm/folio-compat.c | 5 +++++ mm/memcontrol.c | 14 +++++++------- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index a50e5cee6d2c..d4b2bc939eee 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -705,6 +705,7 @@ static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg) } int folio_charge_cgroup(struct folio *, struct mm_struct *, gfp_t); +void folio_uncharge_cgroup(struct folio *); int mem_cgroup_charge(struct page *page, struct mm_struct *mm, gfp_t gfp_mask); int mem_cgroup_swapin_charge_page(struct page *page, struct mm_struct *mm, @@ -1224,6 +1225,10 @@ static inline int folio_charge_cgroup(struct folio *folio, return 0; } +static inline void folio_uncharge_cgroup(struct folio *folio) +{ +} + static inline int mem_cgroup_charge(struct page *page, struct mm_struct *mm, gfp_t gfp_mask) { diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 1d71b8b587f8..d229b979b00d 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -54,4 +54,9 @@ int mem_cgroup_charge(struct page *page, struct mm_struct *mm, gfp_t gfp) { return folio_charge_cgroup(page_folio(page), mm, gfp); } + +void mem_cgroup_uncharge(struct page *page) +{ + folio_uncharge_cgroup(page_folio(page)); +} #endif diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 69638f84d11b..a6befc0843e7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6717,24 +6717,24 @@ static void uncharge_page(struct page *page, struct uncharge_gather *ug) } /** - * mem_cgroup_uncharge - uncharge a page - * @page: page to uncharge + * folio_uncharge_cgroup - Uncharge a folio. + * @folio: Folio to uncharge. * - * Uncharge a page previously charged with mem_cgroup_charge(). + * Uncharge a folio previously charged with folio_charge_cgroup(). */ -void mem_cgroup_uncharge(struct page *page) +void folio_uncharge_cgroup(struct folio *folio) { struct uncharge_gather ug; if (mem_cgroup_disabled()) return; - /* Don't touch page->lru of any random page, pre-check: */ - if (!page_memcg(page)) + /* Don't touch folio->lru of any random page, pre-check: */ + if (!folio_memcg(folio)) return; uncharge_gather_clear(&ug); - uncharge_page(page, &ug); + uncharge_page(&folio->page, &ug); uncharge_batch(&ug); }