2008-02-18 06:01:35

by Li Zefan

[permalink] [raw]
Subject: [PATCH 2/3] memcgroup: fix typo in VM_BUG_ON()

No need for VM_BUG_ON(pc), since 'pc' is the list entry. This should
be VM_BUG_ON(page).

Signed-off-by: Li Zefan <[email protected]>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>
---
mm/memcontrol.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 6bded84..c2959ee 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -534,7 +534,7 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
if (scan >= nr_to_scan)
break;
page = pc->page;
- VM_BUG_ON(!pc);
+ VM_BUG_ON(!page);

if (unlikely(!PageLRU(page)))
continue;
--
1.5.4.rc3


2008-02-18 06:18:19

by Balbir Singh

[permalink] [raw]
Subject: Re: [PATCH 2/3] memcgroup: fix typo in VM_BUG_ON()

Li Zefan wrote:
> No need for VM_BUG_ON(pc), since 'pc' is the list entry. This should
> be VM_BUG_ON(page).
>
> Signed-off-by: Li Zefan <[email protected]>
> Acked-by: KAMEZAWA Hiroyuki <[email protected]>

pc is of type page_cgroup and we use list_for_each_entry_safe_reverse. Not sure
why we can't bug on pc.



--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL

2008-02-18 06:22:21

by YAMAMOTO Takashi

[permalink] [raw]
Subject: Re: [PATCH 2/3] memcgroup: fix typo in VM_BUG_ON()

> Li Zefan wrote:
> > No need for VM_BUG_ON(pc), since 'pc' is the list entry. This should
> > be VM_BUG_ON(page).
> >
> > Signed-off-by: Li Zefan <[email protected]>
> > Acked-by: KAMEZAWA Hiroyuki <[email protected]>
>
> pc is of type page_cgroup and we use list_for_each_entry_safe_reverse. Not sure
> why we can't bug on pc.

pc is dereferenced before this VM_BUG_ON.

YAMAMOTO Takashi

>
>
>
> --
> Warm Regards,
> Balbir Singh
> Linux Technology Center
> IBM, ISTL
> _______________________________________________
> Containers mailing list
> [email protected]
> https://lists.linux-foundation.org/mailman/listinfo/containers

2008-02-18 06:24:49

by Balbir Singh

[permalink] [raw]
Subject: Re: [PATCH 2/3] memcgroup: fix typo in VM_BUG_ON()

YAMAMOTO Takashi wrote:
>> Li Zefan wrote:
>>> No need for VM_BUG_ON(pc), since 'pc' is the list entry. This should
>>> be VM_BUG_ON(page).
>>>
>>> Signed-off-by: Li Zefan <[email protected]>
>>> Acked-by: KAMEZAWA Hiroyuki <[email protected]>
>> pc is of type page_cgroup and we use list_for_each_entry_safe_reverse. Not sure
>> why we can't bug on pc.
>
> pc is dereferenced before this VM_BUG_ON.
>
> YAMAMOTO Takashi
>

OK, so the VM_BUG_ON needs to move to an earlier location. Agreed.

--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL

2008-02-18 06:40:14

by YAMAMOTO Takashi

[permalink] [raw]
Subject: Re: [PATCH 2/3] memcgroup: fix typo in VM_BUG_ON()

> No need for VM_BUG_ON(pc), since 'pc' is the list entry. This should
> be VM_BUG_ON(page).
>
> Signed-off-by: Li Zefan <[email protected]>
> Acked-by: KAMEZAWA Hiroyuki <[email protected]>
> ---
> mm/memcontrol.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 6bded84..c2959ee 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -534,7 +534,7 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
> if (scan >= nr_to_scan)
> break;
> page = pc->page;
> - VM_BUG_ON(!pc);
> + VM_BUG_ON(!page);

can't page be NULL here if mem_cgroup_uncharge clears pc->page behind us?
ie. bug.

YAMAMOTO Takashi

2008-02-18 06:48:46

by Li Zefan

[permalink] [raw]
Subject: Re: [PATCH 2/3] memcgroup: fix typo in VM_BUG_ON()

Balbir Singh wrote:
> YAMAMOTO Takashi wrote:
>>> Li Zefan wrote:
>>>> No need for VM_BUG_ON(pc), since 'pc' is the list entry. This should
>>>> be VM_BUG_ON(page).
>>>>
>>>> Signed-off-by: Li Zefan <[email protected]>
>>>> Acked-by: KAMEZAWA Hiroyuki <[email protected]>
>>> pc is of type page_cgroup and we use list_for_each_entry_safe_reverse. Not sure
>>> why we can't bug on pc.
>> pc is dereferenced before this VM_BUG_ON.
>>
>> YAMAMOTO Takashi
>>
>
> OK, so the VM_BUG_ON needs to move to an earlier location. Agreed.
>

No, 'pc' has been dereferenced in list_for_each_entry_safe_reverse().


#define list_for_each_entry_safe_reverse(pos, n, head, member) \
for (pos = list_entry((head)->prev, typeof(*pos), member), \
n = list_entry(pos->member.prev, typeof(*pos), member); \
^^^^^^^^^^^
&pos->member != (head); \
^^^^^^^^^^^
pos = n, n = list_entry(n->member.prev, typeof(*n), member))

2008-02-18 07:05:37

by Balbir Singh

[permalink] [raw]
Subject: Re: [PATCH 2/3] memcgroup: fix typo in VM_BUG_ON()

Li Zefan wrote:
> Balbir Singh wrote:
>> YAMAMOTO Takashi wrote:
>>>> Li Zefan wrote:
>>>>> No need for VM_BUG_ON(pc), since 'pc' is the list entry. This should
>>>>> be VM_BUG_ON(page).
>>>>>
>>>>> Signed-off-by: Li Zefan <[email protected]>
>>>>> Acked-by: KAMEZAWA Hiroyuki <[email protected]>
>>>> pc is of type page_cgroup and we use list_for_each_entry_safe_reverse. Not sure
>>>> why we can't bug on pc.
>>> pc is dereferenced before this VM_BUG_ON.
>>>
>>> YAMAMOTO Takashi
>>>
>> OK, so the VM_BUG_ON needs to move to an earlier location. Agreed.
>>
>
> No, 'pc' has been dereferenced in list_for_each_entry_safe_reverse().
>
>
> #define list_for_each_entry_safe_reverse(pos, n, head, member) \
> for (pos = list_entry((head)->prev, typeof(*pos), member), \
> n = list_entry(pos->member.prev, typeof(*pos), member); \
> ^^^^^^^^^^^
> &pos->member != (head); \
> ^^^^^^^^^^^
> pos = n, n = list_entry(n->member.prev, typeof(*n), member))
>

Hmm.. We used to have a for loop with !list_empty() as a termination condition
and VM_BUG_ON(!pc) is a spill over. With the new loop, VM_BUG_ON(!pc) does not
make sense.


--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL

2008-02-18 07:16:07

by Li Zefan

[permalink] [raw]
Subject: Re: [PATCH 2/3] memcgroup: fix typo in VM_BUG_ON()

Balbir Singh wrote:
> Li Zefan wrote:
>> Balbir Singh wrote:
>>> YAMAMOTO Takashi wrote:
>>>>> Li Zefan wrote:
>>>>>> No need for VM_BUG_ON(pc), since 'pc' is the list entry. This should
>>>>>> be VM_BUG_ON(page).
>>>>>>
>>>>>> Signed-off-by: Li Zefan <[email protected]>
>>>>>> Acked-by: KAMEZAWA Hiroyuki <[email protected]>
>>>>> pc is of type page_cgroup and we use list_for_each_entry_safe_reverse. Not sure
>>>>> why we can't bug on pc.
>>>> pc is dereferenced before this VM_BUG_ON.
>>>>
>>>> YAMAMOTO Takashi
>>>>
>>> OK, so the VM_BUG_ON needs to move to an earlier location. Agreed.
>>>
>> No, 'pc' has been dereferenced in list_for_each_entry_safe_reverse().
>>
>>
>> #define list_for_each_entry_safe_reverse(pos, n, head, member) \
>> for (pos = list_entry((head)->prev, typeof(*pos), member), \
>> n = list_entry(pos->member.prev, typeof(*pos), member); \
>> ^^^^^^^^^^^
>> &pos->member != (head); \
>> ^^^^^^^^^^^
>> pos = n, n = list_entry(n->member.prev, typeof(*n), member))
>>
>
> Hmm.. We used to have a for loop with !list_empty() as a termination condition
> and VM_BUG_ON(!pc) is a spill over. With the new loop, VM_BUG_ON(!pc) does not
> make sense.
>
>

I see, and I'll post a new patch to just remove it.

2008-02-18 07:36:23

by Li Zefan

[permalink] [raw]
Subject: [PATCH] memcgroup: remove a useless VM_BUG_ON()

Remove this VM_BUG_ON(), as Balbir stated:

We used to have a for loop with !list_empty() as a termination condition
and VM_BUG_ON(!pc) is a spill over. With the new loop, VM_BUG_ON(!pc) does not
make sense.

Signed-off-by: Li Zefan <[email protected]>
---
mm/memcontrol.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 718acf8..631002d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -534,7 +534,6 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
if (scan >= nr_to_scan)
break;
page = pc->page;
- VM_BUG_ON(!pc);

if (unlikely(!PageLRU(page)))
continue;
--
1.5.4.rc3

2008-02-18 08:16:05

by Balbir Singh

[permalink] [raw]
Subject: Re: [PATCH] memcgroup: remove a useless VM_BUG_ON()

Li Zefan wrote:
> Remove this VM_BUG_ON(), as Balbir stated:
>
> We used to have a for loop with !list_empty() as a termination condition
> and VM_BUG_ON(!pc) is a spill over. With the new loop, VM_BUG_ON(!pc) does not
> make sense.
>
> Signed-off-by: Li Zefan <[email protected]>
> ---
> mm/memcontrol.c | 1 -
> 1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 718acf8..631002d 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -534,7 +534,6 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
> if (scan >= nr_to_scan)
> break;
> page = pc->page;
> - VM_BUG_ON(!pc);
>
> if (unlikely(!PageLRU(page)))
> continue;

This seems much better

Acked-by: Balbir Singh <[email protected]>


--
Warm Regards,
Balbir Singh
Linux Technology Center
IBM, ISTL

2008-02-18 08:46:15

by Kamezawa Hiroyuki

[permalink] [raw]
Subject: Re: [PATCH] memcgroup: remove a useless VM_BUG_ON()

On Mon, 18 Feb 2008 15:34:48 +0800
Li Zefan <[email protected]> wrote:

> Remove this VM_BUG_ON(), as Balbir stated:
>
> We used to have a for loop with !list_empty() as a termination condition
> and VM_BUG_ON(!pc) is a spill over. With the new loop, VM_BUG_ON(!pc) does not
> make sense.
>
> Signed-off-by: Li Zefan <[email protected]>
> ---
> mm/memcontrol.c | 1 -
> 1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 718acf8..631002d 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -534,7 +534,6 @@ unsigned long mem_cgroup_isolate_pages(unsigned long nr_to_scan,
> if (scan >= nr_to_scan)
> break;
> page = pc->page;
> - VM_BUG_ON(!pc);
>
> if (unlikely(!PageLRU(page)))
> continue;
> --
> 1.5.4.rc3
>
Acked-by: KAMEZAWA Hiroyuki <[email protected]>

Thanks,
-Kame