Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1586876pxf; Fri, 9 Apr 2021 12:08:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZNR9aQ/fiHl+iWLl/WPQLNhyIHXMt6VFkofw0X7kVKwMpTfUZ+9YK2+gpWnEPQpTp1esh X-Received: by 2002:a17:906:cc49:: with SMTP id mm9mr17105437ejb.339.1617995306042; Fri, 09 Apr 2021 12:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617995306; cv=none; d=google.com; s=arc-20160816; b=GPa/7WeUMjZqy61CuSWlZVuqTy81N0w2TaKs/RM01hGsx7E6Rf6Oek31bvUwqXZBPV 0BG8sHvo4qhejQPX/5DREf6D4CTC7g4dA6S2reQHvILc26QdljN1/Z0h/CGobfRNDXYT FSu7J4uZ37w1P+14nAcGBOPTr+7sPbpnUWA1GXxG7vsJeFekBPxWBi0IOxbnNXCyNsYq h/UXS2Nd2E1etU/4C32PNhsak9cvDrGq5U8UemTw/RSrMA3ygK3GE3H7Ov5wOZK64ief SZRFGcOdaBMG5jQ1HxvwrZoyx6NiJwxGzyvjP3qWvaoJ/FqFLoAdR9w8931jCmK9Q9PK SU8Q== 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=xsjVcs0dKXDgvwkPyLRuNn8BGjcZ+u9/VPT+aQCiWxE=; b=tcFA2NRmavtJcZn1CVIx5upvqLxI3gLwJTfVvBqF2+1yuuc+HSX4gLqpPyOUNZY3hu cvMnG4GSO7DUV0bWpwYd1qy1ppZ4vsNtA8mNOrye/brvB8mAsI8gm1bbE8bkWYh7dXP1 B02sxkR1sC6Y/6Y2z0anZHAItR1jAJmY3WNwSo/ermvVoFQF+ZxAdC4N7+sGLwx3HIEY 1wH0tjGwwy/jqg97UKzrtm//Yhcir9+C8gPk5i00Uc+M/lgpolDKsmqNP+pQYMcfulTq JWlqzfZLryZHfbseUCZ6FZsxuBj06BYg726wLNPDqwEL6zoQm9Ms1jdIYi+lBbnRB0SB YvxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=fvCb9CS6; 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 b12si2740595edd.19.2021.04.09.12.08.02; Fri, 09 Apr 2021 12:08:26 -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=fvCb9CS6; 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 S234806AbhDITFT (ORCPT + 99 others); Fri, 9 Apr 2021 15:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234692AbhDITFS (ORCPT ); Fri, 9 Apr 2021 15:05:18 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CACC3C061762; Fri, 9 Apr 2021 12:05:04 -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=xsjVcs0dKXDgvwkPyLRuNn8BGjcZ+u9/VPT+aQCiWxE=; b=fvCb9CS6VRSUjtEGURGh7JUAey CrlAG6UVilys94ZnzkMJ2H1/WXdLkgUYBOdo60iSMgs+cWBd5raVOQ4vbZSZTIcI/hitiCEZgz0NL YbXSGOuyhmPXuj5qRwE6TIPyzy48PosJyGYMAMMxavYtvuGGYxJFkxn7E2eoTDcGUNE1w5jP2xpff yMDXjjGSW5MwhIACG3rOaeS5Y6VhS4t3zqSZ5W0bYUgQdobAmktLiihA25DcdL+Ye6vYNdedTA+eR zMbN9nhctVMTI8zaNuFZaCMA4UDJ9B+YdFA5rTEzH+h96/2SR3qz07UOswlZNbZ0U6DOaBkpdTNuB VgcKGhNg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lUwPH-000o7W-CF; Fri, 09 Apr 2021 19:03:18 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, Christoph Hellwig , Jeff Layton Subject: [PATCH v7 16/28] mm/memcg: Add folio wrappers for various functions Date: Fri, 9 Apr 2021 19:50:53 +0100 Message-Id: <20210409185105.188284-17-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210409185105.188284-1-willy@infradead.org> References: <20210409185105.188284-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add new wrapper functions folio_memcg(), lock_folio_memcg(), unlock_folio_memcg(), mem_cgroup_folio_lruvec() and count_memcg_folio_event() Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Acked-by: Jeff Layton --- include/linux/memcontrol.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index b8b0a802852c..f15b46f5b06c 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -456,6 +456,11 @@ static inline struct mem_cgroup *page_memcg(struct page *page) return __page_memcg(page); } +static inline struct mem_cgroup *folio_memcg(struct folio *folio) +{ + return page_memcg(&folio->page); +} + /* * page_memcg_rcu - locklessly get the memory cgroup associated with a page * @page: a pointer to the page struct @@ -1052,6 +1057,15 @@ static inline void count_memcg_page_event(struct page *page, count_memcg_events(memcg, idx, 1); } +static inline void count_memcg_folio_event(struct folio *folio, + enum vm_event_item idx) +{ + struct mem_cgroup *memcg = folio_memcg(folio); + + if (memcg) + count_memcg_events(memcg, idx, folio_nr_pages(folio)); +} + static inline void count_memcg_event_mm(struct mm_struct *mm, enum vm_event_item idx) { @@ -1471,6 +1485,22 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, } #endif /* CONFIG_MEMCG */ +static inline void lock_folio_memcg(struct folio *folio) +{ + lock_page_memcg(&folio->page); +} + +static inline void unlock_folio_memcg(struct folio *folio) +{ + unlock_page_memcg(&folio->page); +} + +static inline struct lruvec *mem_cgroup_folio_lruvec(struct folio *folio, + struct pglist_data *pgdat) +{ + return mem_cgroup_page_lruvec(&folio->page, pgdat); +} + static inline void __inc_lruvec_kmem_state(void *p, enum node_stat_item idx) { __mod_lruvec_kmem_state(p, idx, 1); -- 2.30.2