Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp631246pxf; Wed, 31 Mar 2021 11:55:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+/o0xJUHexkzYJBMAv0xPT1+hrAGhcipmABVtOrKsPvqoyYT9mytWdqrIeutUwF87IuDQ X-Received: by 2002:a17:906:add7:: with SMTP id lb23mr5096119ejb.273.1617216924256; Wed, 31 Mar 2021 11:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617216924; cv=none; d=google.com; s=arc-20160816; b=vBL6Peq+rVRbem3dbDSHcsaETude2X0FtXIIgYp+a2HcSp2WDc0hFS6m9AAEsNXIGT nCtWNul7kCiEFhoLQvhGilTiTYcC0NvKwl7neJmhogpHTzsMbvH9Kl2d8jyWa8ZMdA5b 1WI2Kcnfigm/JvwMvKTZxyIYKIbd23S/5UwBfyJujt65H82BkbWuAA5MRS1Ze+SMGKf0 H7yyIEQwgWl5vcvSxjTfGpZuvg8E1Lfr0sG6h30IICg/rYQWkchBQTrKkaheaN1FJLAS 3htlQHuqkb0isKjwp6mIH65iafm85y/xa7d+olDDLWiU5ISS8OEMTiCHW+m3VeFMqwvy bx8Q== 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=JlA5ruehMK2CGaD5kFtLsiXzEiTkhGCnUfrLrdzu4T4=; b=Wr+do1vPUbGxhVnuIkQ8Eb1P5hZBTVCoJyNMo0ZBfoFljV8NEwbHEXD11ukSAT76kO ZKSkKdjQLz24rKLTWUoz6QZM+68Sbq2hcxVoGUk59aYQcrbOMFAx1zroZRSqld81B0Im lNDb6Uwr/0FIUNsiCDnZ3sa7c7gENHmBedPLMEO98hEcXp8LikvujxgyY5bSoRIhiS2d alL2XtJVfohbHVuFId2pFp/o3znnbTJrUQjE7a1QD3C8fhce58FDFAfVSuJjzMxCDBv6 1t6Wb8tELOJBamvCMBbTLUNxeGc/TNxGo1nm50FVZZEZBi2LxfrSdnV0kA2/ffXvF7u/ umjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=h62Jc82o; 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 qu2si2245546ejb.373.2021.03.31.11.55.01; Wed, 31 Mar 2021 11:55:24 -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=h62Jc82o; 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 S235354AbhCaSyP (ORCPT + 99 others); Wed, 31 Mar 2021 14:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235869AbhCaSxs (ORCPT ); Wed, 31 Mar 2021 14:53:48 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CC12C061574; Wed, 31 Mar 2021 11:53:48 -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=JlA5ruehMK2CGaD5kFtLsiXzEiTkhGCnUfrLrdzu4T4=; b=h62Jc82oYIW/XhdBlBMPDnQPLh HkYeoNsCstVcsRipVE3njmaVhyTag8LvQpH143BEYNCf6iidjZOMjKBo1zEksv0wEKp9hFywdestY LvpsYXKpQ1nXd2EHU8SX6pDcTa1G0+Xrs0mEkq6t0U8m1v8D8bbp+IBv3EJgGhfgVTBaFvKXkdcTS X6AF7wiSI/OCg7Xr60kEJSarOkDCeIoUwpF8fYZZKH9yT818+o+t9o5XAyEhPBsOS/FTRq4U9NtbZ 8f1w/h3BBoecV2vsnHd1VxdIfbzCjPaF2adlfNen68nGRPlZLRfsBsKHl+1K9M6VbrAHJzQPi5dqE w1imIeYg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lRfxm-004zcv-9W; Wed, 31 Mar 2021 18:53:21 +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 Subject: [PATCH v6 15/27] mm/memcg: Add folio wrappers for various functions Date: Wed, 31 Mar 2021 19:47:16 +0100 Message-Id: <20210331184728.1188084-16-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210331184728.1188084-1-willy@infradead.org> References: <20210331184728.1188084-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) --- include/linux/memcontrol.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 0e8907957227..d8027831a681 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) { @@ -1473,6 +1487,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