lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201001134452.GD469663@cmpxchg.org>
Date:   Thu, 1 Oct 2020 09:44:52 -0400
From:   Johannes Weiner <hannes@...xchg.org>
To:     Roman Gushchin <guro@...com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Shakeel Butt <shakeelb@...gle.com>,
        Michal Hocko <mhocko@...nel.org>, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, kernel-team@...com
Subject: Re: [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);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ