diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 89e4f01c571069ee716e15dfb2f2d4af3543cb22..600cda4ea1be53ee22d9e6340ba33e325a4ac06c 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1873,10 +1873,13 @@ void mem_cgroup_track_foreign_dirty_slowpath(struct page *page, static inline void mem_cgroup_track_foreign_dirty(struct page *page, struct bdi_writeback *wb) { + struct mem_cgroup *memcg; + if (mem_cgroup_disabled()) return; - if (unlikely(&page_memcg(page)->css != wb->memcg_css)) + memcg = page_memcg(page); + if (unlikely(memcg && &memcg->css != wb->memcg_css)) mem_cgroup_track_foreign_dirty_slowpath(page, wb); }