* + mm-introduce-page-memcg-flags.patch added to -mm tree
@ 2020-10-28 23:29 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2020-10-28 23:29 UTC (permalink / raw)
To: guro, hannes, mhocko, mm-commits, shakeelb
The patch titled
Subject: mm: introduce page memcg flags
has been added to the -mm tree. Its filename is
mm-introduce-page-memcg-flags.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/mm-introduce-page-memcg-flags.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/mm-introduce-page-memcg-flags.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Roman Gushchin <guro@fb.com>
Subject: mm: introduce page memcg flags
The lowest bit in page->memcg_data is used to distinguish between struct
memory_cgroup pointer and a pointer to a objcgs array. All checks and
modifications of this bit are open-coded.
Let's formalize it using page memcg flags, defined in enum
page_memcg_data_flags.
Additional flags might be added later.
Link: https://lkml.kernel.org/r/20201027001657.3398190-4-guro@fb.com
Signed-off-by: Roman Gushchin <guro@fb.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/memcontrol.h | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
--- a/include/linux/memcontrol.h~mm-introduce-page-memcg-flags
+++ a/include/linux/memcontrol.h
@@ -343,6 +343,15 @@ struct mem_cgroup {
extern struct mem_cgroup *root_mem_cgroup;
+enum page_memcg_data_flags {
+ /* page->memcg_data is a pointer to an objcgs vector */
+ MEMCG_DATA_OBJCGS = (1UL << 0),
+ /* the next bit after the last actual flag */
+ __NR_MEMCG_DATA_FLAGS = (1UL << 1),
+};
+
+#define MEMCG_DATA_FLAGS_MASK (__NR_MEMCG_DATA_FLAGS - 1)
+
/*
* page_memcg - get the memory cgroup associated with a page
* @page: a pointer to the page struct
@@ -404,13 +413,7 @@ static inline struct mem_cgroup *page_me
*/
unsigned long memcg_data = READ_ONCE(page->memcg_data);
- /*
- * The lowest bit set means that memcg isn't a valid
- * memcg pointer, but a obj_cgroups pointer.
- * In this case the page is shared and doesn't belong
- * to any specific memory cgroup.
- */
- if (memcg_data & 0x1UL)
+ if (memcg_data & MEMCG_DATA_OBJCGS)
return NULL;
return (struct mem_cgroup *)memcg_data;
@@ -429,7 +432,11 @@ static inline struct mem_cgroup *page_me
*/
static inline struct obj_cgroup **page_objcgs(struct page *page)
{
- return (struct obj_cgroup **)(READ_ONCE(page->memcg_data) & ~0x1UL);
+ unsigned long memcg_data = READ_ONCE(page->memcg_data);
+
+ VM_BUG_ON_PAGE(memcg_data && !(memcg_data & MEMCG_DATA_OBJCGS), page);
+
+ return (struct obj_cgroup **)(memcg_data & ~MEMCG_DATA_FLAGS_MASK);
}
/*
@@ -444,10 +451,10 @@ static inline struct obj_cgroup **page_o
{
unsigned long memcg_data = READ_ONCE(page->memcg_data);
- if (memcg_data && (memcg_data & 0x1UL))
- return (struct obj_cgroup **)(memcg_data & ~0x1UL);
+ if (!memcg_data || !(memcg_data & MEMCG_DATA_OBJCGS))
+ return NULL;
- return NULL;
+ return (struct obj_cgroup **)(memcg_data & ~MEMCG_DATA_FLAGS_MASK);
}
/*
@@ -460,7 +467,8 @@ static inline struct obj_cgroup **page_o
static inline bool set_page_objcgs(struct page *page,
struct obj_cgroup **objcgs)
{
- return !cmpxchg(&page->memcg_data, 0, (unsigned long)objcgs | 0x1UL);
+ return !cmpxchg(&page->memcg_data, 0, (unsigned long)objcgs |
+ MEMCG_DATA_OBJCGS);
}
#else
static inline struct obj_cgroup **page_objcgs(struct page *page)
_
Patches currently in -mm which might be from guro@fb.com are
mm-memcontrol-use-helpers-to-read-pages-memcg-data.patch
mm-memcontrol-slab-use-helpers-to-access-slab-pages-memcg_data.patch
mm-introduce-page-memcg-flags.patch
mm-convert-page-kmemcg-type-to-a-page-memcg-flag.patch
mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings.patch
mm-vmstat-fix-proc-sys-vm-stat_refresh-generating-false-warnings-fix.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-28 23:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 23:29 + mm-introduce-page-memcg-flags.patch added to -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.