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] [day] [month] [year] [list]
Message-ID: <CALWz4iwWdjqhOFDsuJ2OFPH2v8pgjtttQfrrjkPT=aX9zu-5hQ@mail.gmail.com>
Date:	Wed, 18 Apr 2012 11:18:06 -0700
From:	Ying Han <yinghan@...gle.com>
To:	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Cc:	"linux-mm@...ck.org" <linux-mm@...ck.org>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Michal Hocko <mhocko@...e.cz>,
	Johannes Weiner <hannes@...xchg.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Glauber Costa <glommer@...allels.com>,
	Konstantin Khlebnikov <khlebnikov@...nvz.org>,
	Suleiman Souhlal <suleiman@...gle.com>
Subject: Re: [RFC][PATCH 2/6] memcg: add pc_set_mem_cgroup_and_flags()

On Wed, Apr 18, 2012 at 12:23 AM, KAMEZAWA Hiroyuki
<kamezawa.hiroyu@...fujitsu.com> wrote:
> (2012/04/18 6:17), Ying Han wrote:
>
>> On Wed, Mar 28, 2012 at 3:51 AM, KAMEZAWA Hiroyuki
>> <kamezawa.hiroyu@...fujitsu.com> wrote:
>>> Consolidate a code for setting pc->mem_cgroup and USED bit which requires smp_wmb().
>>> And remove a macro PCGF_NOCOPY_AT_SPLIT which isn't helpful to read code, now.
>>>
>>> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
>>> ---
>>>  include/linux/page_cgroup.h |   18 ++++++++++++++++++
>>>  mm/memcontrol.c             |   18 ++++--------------
>>>  2 files changed, 22 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/include/linux/page_cgroup.h b/include/linux/page_cgroup.h
>>> index 92768cb..2707809 100644
>>> --- a/include/linux/page_cgroup.h
>>> +++ b/include/linux/page_cgroup.h
>>> @@ -1,6 +1,8 @@
>>>  #ifndef __LINUX_PAGE_CGROUP_H
>>>  #define __LINUX_PAGE_CGROUP_H
>>>
>>> +#include <linux/smp.h>
>>> +
>>>  enum {
>>>        /* flags for mem_cgroup */
>>>        PCG_LOCK,  /* Lock for pc->mem_cgroup and following bits. */
>>> @@ -94,6 +96,22 @@ pc_set_mem_cgroup(struct page_cgroup *pc, struct mem_cgroup *memcg)
>>>        pc->mem_cgroup = memcg;
>>>  }
>>>
>>> +static inline void
>>> +pc_set_mem_cgroup_and_flags(struct page_cgroup *pc, struct mem_cgroup *memcg,
>>> +                       unsigned long flags)
>>> +{
>>> +       pc->mem_cgroup = memcg;
>>> +       /*
>>> +        * We access a page_cgroup asynchronously without lock_page_cgroup().
>>> +        * Especially when a page_cgroup is taken from a page, pc's mem_cgroup
>>> +        * is accessed after testing USED bit. To make pc's mem_cgroup visible
>>> +        * before USED bit, we need memory barrier here.
>>> +        * See mem_cgroup_add_lru_list(), etc.
>>> +        */
>>> +       smp_wmb();
>>> +       pc->flags = flags;
>>> +}
>>> +
>>>  #else /* CONFIG_CGROUP_MEM_RES_CTLR */
>>>  struct page_cgroup;
>>>
>>> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
>>> index 8077460..d366b60 100644
>>> --- a/mm/memcontrol.c
>>> +++ b/mm/memcontrol.c
>>> @@ -2511,16 +2511,7 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg,
>>>                }
>>>        }
>>>
>>> -       pc_set_mem_cgroup(pc, memcg);
>>> -       /*
>>> -        * We access a page_cgroup asynchronously without lock_page_cgroup().
>>> -        * Especially when a page_cgroup is taken from a page, pc's mem_cgroup
>>> -        * is accessed after testing USED bit. To make pc's mem_cgroup visible
>>> -        * before USED bit, we need memory barrier here.
>>> -        * See mem_cgroup_add_lru_list(), etc.
>>> -        */
>>> -       smp_wmb();
>>> -       SetPageCgroupUsed(pc);
>>
>> I might be confused. We removed this SetPageCgroupUsed() but not
>> adding it back elsewhere ?
>>
>> --Ying
>>
>>> +       pc_set_mem_cgroup_and_flags(pc, memcg, BIT(PCG_USED) | BIT(PCG_LOCK));
>
>
> Added here. This sets
>
>  | memcg pointer | Used | Locked |

Ah. I missed that part.

Thanks

--Ying

>
>
> Thanks,
> -Kame
>
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ