lkml.org 
[lkml]   [2020]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v4 3/4] mm: introduce page memcg flags
On Wed, Sep 30, 2020 at 05:27:09PM -0700, Roman Gushchin wrote:
> @@ -448,7 +451,12 @@ static inline void set_page_memcg(struct page *page, struct mem_cgroup *memcg)
> */
> 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);

This fits on a single line.

> + return (struct obj_cgroup **)(memcg_data & ~MEMCG_DATA_FLAGS_MASK);
> }
>
> /*
> @@ -463,8 +471,9 @@ static inline struct obj_cgroup **page_objcgs_check(struct page *page)
> {
> 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 (struct obj_cgroup **)
> + (memcg_data & ~MEMCG_DATA_FLAGS_MASK);

if (!memcg_data || (memcg_data & MEMCG_DATA_OBJCGS))
return NULL;

return (struct obj_cgroup **)(memcg_data & ~MEMCG_DATA_FLAGS_MASK);

> @@ -479,7 +488,11 @@ static inline struct obj_cgroup **page_objcgs_check(struct page *page)
> static inline bool set_page_objcgs(struct page *page,
> struct obj_cgroup **objcgs)
> {
> - return !cmpxchg(&page->memcg_data, 0, (unsigned long)objcgs | 0x1UL);
> + unsigned long memcg_data = (unsigned long)objcgs;
> +
> + memcg_data |= MEMCG_DATA_OBJCGS;
> +
> + return !cmpxchg(&page->memcg_data, 0, memcg_data);

return !cmpxchg(&page->memcg_data, 0, memcg_data | MEMCG_DATA_OBJCGS);

\
 
 \ /
  Last update: 2020-10-01 15:46    [W:0.185 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site