From patchwork Fri Aug 25 13:59:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13365794 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 8815DC7EE2C for ; Fri, 25 Aug 2023 13:59:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 891332800C5; Fri, 25 Aug 2023 09:59:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 83BB82800BB; Fri, 25 Aug 2023 09:59:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FC2B2800BB; Fri, 25 Aug 2023 09:59:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EDD112800BB for ; Fri, 25 Aug 2023 09:59:25 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C6B461A06BA for ; Fri, 25 Aug 2023 13:59:25 +0000 (UTC) X-FDA: 81162784290.13.53B579B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id 0A7E840009 for ; Fri, 25 Aug 2023 13:59:23 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=U63qpPXM; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692971964; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CdqQz781axet48KQidYLD3qY3rX/OHB467VTCpi9mOE=; b=qtN1muwg3eOP5zv7ntu9/Ee+oTaqy3xiiGSYJEDHi2L4Wx61Kxm9GLEqwYZu2Ozs4LDEt2 FJ5iCKwR5YZaE/kxqWQe6j5v1JtalydWjCnwDr+WpHrWwBYtdMM0ZZoXbsfFmuqVMFNYAk yCdG39hiS6NLKQU693Cc0bjjP8gOucQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692971964; a=rsa-sha256; cv=none; b=b/rLda72g2lQhktN1BXFf7y2tfAWPVeKPpsmKt1lgYiRnnCiY4OFI5d3h8zYx4pZyJ9z4g vSem0FWiO9Yu5sGv89uDq+EPpajCfFZTW1LWAIktI2vgoY1f+6H+hSjzaRHrgK/zBUyQjQ VdX2t8s+ZNjjD5dIEXs5TJC9XW80kAU= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=U63qpPXM; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=CdqQz781axet48KQidYLD3qY3rX/OHB467VTCpi9mOE=; b=U63qpPXMBk+wldMqManAPBRBNl BcGPVUTy0C5LAxj2n685rIO47vanLcxy1FQUxuEKEDeJUWwnPhMj0bdZL/JSKn1M31Kp99cTW6eNZ v1yIJJF2BlMgKgxopiqo1S0T07PglTDku/2EelJur11i02pVUP13ab8fMYuK0oYQIOENpUg5MttBY JD+SmozORdQwbdAc2fndBGOSxP2yRLgKwLFspaVSOLjsOZZ3IxTPw/upRmOXa3tMJTtJR82h09n55 NV1RUKdxqCOJ0Ir6xg3HwLiL55h6cP2fDQf/+Cy1bXSiBRHqrNhLycruLJWeBNZ9X+ekMa/pYqCLn +GV+yP+A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qZXLN-00HTQo-F0; Fri, 25 Aug 2023 13:59:21 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [RFC PATCH 05/14] memcg: Add mem_cgroup_uncharge_folios() Date: Fri, 25 Aug 2023 14:59:09 +0100 Message-Id: <20230825135918.4164671-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230825135918.4164671-1-willy@infradead.org> References: <20230825135918.4164671-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0A7E840009 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: gmo6e7naoyeouoa4ocnkcurgeo9dn5pn X-HE-Tag: 1692971963-918165 X-HE-Meta: U2FsdGVkX18eaU4jWUkFmrE1BgdS7X2oIzG942R3BllOflPQESwEh01p5pzGTBRMPJ5xiubR1eEfv2311CyP7yLhVFZk5oZy2HAzOF0sAEURSq9kYaLcuShVyIziSPlmvNd8Fthhe2sp8lOGSI97Mqqd0O2gWunv1DcUN6em8zowe1qQQQMAz+DZAzqgGQlz4RfUEwO+qpFPUaU0lqHomUq7q4P75UNaJbH9yrIGnUC1FnY6A5XbSOSVgeJOyVCjjHB33Ks1q2QbWaBcGtrDlSGIjzmrZn0vPRN186gwJLto2XIeh5X+SUDqBHAahHEgcNoRcFnFnSNU4ACyvFBslUFTTaFPTOs4Wgow5sFBSweUj6uPSwAj1GHNBybJgRiEpwb1fRjXeTY8584WznoG49v4YMViqLCgITXXvYjoA7lmcuX/aa7DnFPTazcLU6fcC06bmJyu8pDlpWQtC4QBEsfo8YrMchHKYtEW8XQ6Jt02WVKZam9XNamjbql0Y7za6R3VVKAJTtwSuxIzy9ncoN0NEaQaXFWfpjaBkkYTPsOa39HG1cEU0z8f/Qhtxeq482LYLjHrBEMVlE1Xm8ebskT+G2NBO7Nusj6/uF40UbHDTurXWBRxC02Ub4jQx+9atOo3ggnhsEd5UARzhrADYjwuSmmLV+5LKk4LQ7F38iQVhPhsEcHVQ/S1pvkR0nH+YAIu07LRyWBsBMvP5tBPohNIQHm8BhJy4NQOXPbd3xM2zsqEnuZ1ZMs5Stuti7/i3aNOxjDjTob+GlrxZuTN/M1zjwx67kNrSSp4YG4rX/UzTdzghBhVVkZ+ZjCs3o+gV0kYzh6uk3fhEHgJ+LBgNj1RYkKI13WILU/w2NjH/rTHBV8g2XBoGrad4KMcu9ibi/aN5z/4JMxImRwJWwv4SRzRYCQfXpX5DJ02Fc3aJvl+U8zMN5LsZpgrxCrh2T1zH6WoYoOJeInCNOCb54g fA9XNR/M lEuFHwlXs9svRMInbNqlEysIK3aln6RFA7PhuYJdLxTG6KzK97z+sadgZcxNsxCdstl/s+fbe8LOPqhEzR3lys43rHEq40BCe3TbFSJAbAM2Hccwkvc1Fx8zTa1v4VozTACmgm6lHMjzZnrX3xPhWCINd/CE+Ro6r8mhUbjjHhbV2gm+kBelIArkC8zuxQ2pQi8OzpPomG4NuIZceY8AhhuTgY7WbNAtRLNey8msy0lz2PHTxOCstGbgqtg9WBqHuA953 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: Almost identical to mem_cgroup_uncharge_list(), except it takes a folio_batch instead of a list_head. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Ryan Roberts --- include/linux/memcontrol.h | 12 ++++++++++++ mm/memcontrol.c | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index ab94ad4597d0..d0caeb1c1136 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -713,6 +713,14 @@ static inline void mem_cgroup_uncharge_list(struct list_head *page_list) __mem_cgroup_uncharge_list(page_list); } +void __mem_cgroup_uncharge_folios(struct folio_batch *folios); +static inline void mem_cgroup_uncharge_folios(struct folio_batch *folios) +{ + if (mem_cgroup_disabled()) + return; + __mem_cgroup_uncharge_folios(folios); +} + void mem_cgroup_migrate(struct folio *old, struct folio *new); /** @@ -1273,6 +1281,10 @@ static inline void mem_cgroup_uncharge_list(struct list_head *page_list) { } +static inline void mem_cgroup_uncharge_folios(struct folio_batch *folios) +{ +} + static inline void mem_cgroup_migrate(struct folio *old, struct folio *new) { } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 26ba9d1a66d1..a0fb008afa23 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -7190,6 +7191,18 @@ void __mem_cgroup_uncharge_list(struct list_head *page_list) uncharge_batch(&ug); } +void __mem_cgroup_uncharge_folios(struct folio_batch *folios) +{ + struct uncharge_gather ug; + unsigned int i; + + uncharge_gather_clear(&ug); + for (i = 0; i < folios->nr; i++) + uncharge_folio(folios->folios[i], &ug); + if (ug.memcg) + uncharge_batch(&ug); +} + /** * mem_cgroup_migrate - Charge a folio's replacement. * @old: Currently circulating folio.