Commit 074e3e26 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Andrew Morton

memcg: convert get_obj_cgroup_from_page to get_obj_cgroup_from_folio

As the one caller now has a folio, pass it in and use it.  Removes three
calls to compound_head().

Link: https://lkml.kernel.org/r/20230715042343.434588-4-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Domenico Cerasuolo <cerasuolodomenico@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Vitaly Wool <vitaly.wool@konsulko.com>
Cc: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 34f4c198
...@@ -1759,7 +1759,7 @@ int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order); ...@@ -1759,7 +1759,7 @@ int __memcg_kmem_charge_page(struct page *page, gfp_t gfp, int order);
void __memcg_kmem_uncharge_page(struct page *page, int order); void __memcg_kmem_uncharge_page(struct page *page, int order);
struct obj_cgroup *get_obj_cgroup_from_current(void); struct obj_cgroup *get_obj_cgroup_from_current(void);
struct obj_cgroup *get_obj_cgroup_from_page(struct page *page); struct obj_cgroup *get_obj_cgroup_from_folio(struct folio *folio);
int obj_cgroup_charge(struct obj_cgroup *objcg, gfp_t gfp, size_t size); int obj_cgroup_charge(struct obj_cgroup *objcg, gfp_t gfp, size_t size);
void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size); void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size);
...@@ -1843,7 +1843,7 @@ static inline void __memcg_kmem_uncharge_page(struct page *page, int order) ...@@ -1843,7 +1843,7 @@ static inline void __memcg_kmem_uncharge_page(struct page *page, int order)
{ {
} }
static inline struct obj_cgroup *get_obj_cgroup_from_page(struct page *page) static inline struct obj_cgroup *get_obj_cgroup_from_folio(struct folio *folio)
{ {
return NULL; return NULL;
} }
......
...@@ -3036,21 +3036,21 @@ __always_inline struct obj_cgroup *get_obj_cgroup_from_current(void) ...@@ -3036,21 +3036,21 @@ __always_inline struct obj_cgroup *get_obj_cgroup_from_current(void)
return objcg; return objcg;
} }
struct obj_cgroup *get_obj_cgroup_from_page(struct page *page) struct obj_cgroup *get_obj_cgroup_from_folio(struct folio *folio)
{ {
struct obj_cgroup *objcg; struct obj_cgroup *objcg;
if (!memcg_kmem_online()) if (!memcg_kmem_online())
return NULL; return NULL;
if (PageMemcgKmem(page)) { if (folio_memcg_kmem(folio)) {
objcg = __folio_objcg(page_folio(page)); objcg = __folio_objcg(folio);
obj_cgroup_get(objcg); obj_cgroup_get(objcg);
} else { } else {
struct mem_cgroup *memcg; struct mem_cgroup *memcg;
rcu_read_lock(); rcu_read_lock();
memcg = __folio_memcg(page_folio(page)); memcg = __folio_memcg(folio);
if (memcg) if (memcg)
objcg = __get_obj_cgroup_from_memcg(memcg); objcg = __get_obj_cgroup_from_memcg(memcg);
else else
......
...@@ -1258,7 +1258,7 @@ bool zswap_store(struct folio *folio) ...@@ -1258,7 +1258,7 @@ bool zswap_store(struct folio *folio)
* cgroup-aware entry LRU, we will push out entries system-wide based on * cgroup-aware entry LRU, we will push out entries system-wide based on
* local cgroup limits. * local cgroup limits.
*/ */
objcg = get_obj_cgroup_from_page(page); objcg = get_obj_cgroup_from_folio(folio);
if (objcg && !obj_cgroup_may_zswap(objcg)) if (objcg && !obj_cgroup_may_zswap(objcg))
goto reject; goto reject;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment