* 34-rc1-git3 build failure with CGROUP_MEM_RES_CTLR_SWAP=y
@ 2010-03-14 10:48 Sachin Sant
2010-03-15 1:02 ` [BUGFIX][PATCH] memcg: avoid use cmpxchg in swap cgroup maintainance (Was " KAMEZAWA Hiroyuki
2010-03-15 1:04 ` Michael Ellerman
0 siblings, 2 replies; 6+ messages in thread
From: Sachin Sant @ 2010-03-14 10:48 UTC (permalink / raw)
To: Linux/PPC Development; +Cc: lizf, nishimura, linux-kernel, Balbir Singh
On a PowerPC box, latest 34-rc1 git(d89b218b8...) fails to build
with CGROUPS_MEM_RES_CTRL_SWAP=y.
LD init/built-in.o
LD .tmp_vmlinux1
mm/built-in.o: In function __xchg:
arch/powerpc/include/asm/system.h:331: undefined reference to .__xchg_called_with_bad_pointer
mm/built-in.o: In function __cmpxchg:
arch/powerpc/include/asm/system.h:474: undefined reference to .__cmpxchg_called_with_bad_pointer
make: *** [.tmp_vmlinux1] Error 1
The code in question was added via commit 024914477e...
memcg: move charges of anonymous swap
Thanks
-Sachin
--
---------------------------------
Sachin Sant
IBM Linux Technology Center
India Systems and Technology Labs
Bangalore, India
---------------------------------
^ permalink raw reply [flat|nested] 6+ messages in thread
* [BUGFIX][PATCH] memcg: avoid use cmpxchg in swap cgroup maintainance (Was Re: 34-rc1-git3 build failure with CGROUP_MEM_RES_CTLR_SWAP=y
2010-03-14 10:48 34-rc1-git3 build failure with CGROUP_MEM_RES_CTLR_SWAP=y Sachin Sant
@ 2010-03-15 1:02 ` KAMEZAWA Hiroyuki
2010-03-15 2:14 ` Balbir Singh
` (2 more replies)
2010-03-15 1:04 ` Michael Ellerman
1 sibling, 3 replies; 6+ messages in thread
From: KAMEZAWA Hiroyuki @ 2010-03-15 1:02 UTC (permalink / raw)
To: Sachin Sant
Cc: nishimura, lizf, linux-kernel, Linux/PPC Development,
akpm@linux-foundation.org, Balbir Singh
On Sun, 14 Mar 2010 16:18:06 +0530
Sachin Sant <sachinp@in.ibm.com> wrote:
> On a PowerPC box, latest 34-rc1 git(d89b218b8...) fails to build
> with CGROUPS_MEM_RES_CTRL_SWAP=y.
>
> LD init/built-in.o
> LD .tmp_vmlinux1
> mm/built-in.o: In function __xchg:
> arch/powerpc/include/asm/system.h:331: undefined reference to .__xchg_called_with_bad_pointer
> mm/built-in.o: In function __cmpxchg:
> arch/powerpc/include/asm/system.h:474: undefined reference to .__cmpxchg_called_with_bad_pointer
> make: *** [.tmp_vmlinux1] Error 1
>
> The code in question was added via commit 024914477e...
>
> memcg: move charges of anonymous swap
>
Oh..ok, powerpc (and other archs?) can't do 2byte cmpxchg and xchg.
Then, we should use spinlock rather than that.
How about this ? Nishimura-san, could you consider something better ?
We need a quick fix.
==
swap_cgroup uses 2bytes data and uses cmpxchg in a new operation.
2byte cmpxchg/xchg is not available on some archs. This patch replaces
cmpxchg/xchg with operations under lock.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
---
mm/page_cgroup.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
Index: mmotm-2.6.34-Mar11/mm/page_cgroup.c
===================================================================
--- mmotm-2.6.34-Mar11.orig/mm/page_cgroup.c
+++ mmotm-2.6.34-Mar11/mm/page_cgroup.c
@@ -284,6 +284,7 @@ static DEFINE_MUTEX(swap_cgroup_mutex);
struct swap_cgroup_ctrl {
struct page **map;
unsigned long length;
+ spinlock_t lock;
};
struct swap_cgroup_ctrl swap_cgroup_ctrl[MAX_SWAPFILES];
@@ -353,16 +354,22 @@ unsigned short swap_cgroup_cmpxchg(swp_e
struct swap_cgroup_ctrl *ctrl;
struct page *mappage;
struct swap_cgroup *sc;
+ unsigned long flags;
+ unsigned short retval;
ctrl = &swap_cgroup_ctrl[type];
mappage = ctrl->map[idx];
sc = page_address(mappage);
sc += pos;
- if (cmpxchg(&sc->id, old, new) == old)
- return old;
+ spin_lock_irqsave(&ctrl->lock, flags);
+ retval = sc->id;
+ if (retval == old)
+ sc->id = new;
else
- return 0;
+ retval = 0;
+ spin_unlock_irqrestore(&ctrl->lock, flags);
+ return retval;
}
/**
@@ -383,13 +390,17 @@ unsigned short swap_cgroup_record(swp_en
struct page *mappage;
struct swap_cgroup *sc;
unsigned short old;
+ unsigned long flags;
ctrl = &swap_cgroup_ctrl[type];
mappage = ctrl->map[idx];
sc = page_address(mappage);
sc += pos;
- old = xchg(&sc->id, id);
+ spin_lock_irqsave(&ctrl->lock, flags);
+ old = sc->id;
+ sc->id = id;
+ spin_unlock_irqrestore(&ctrl->lock, flags);
return old;
}
@@ -441,6 +452,7 @@ int swap_cgroup_swapon(int type, unsigne
mutex_lock(&swap_cgroup_mutex);
ctrl->length = length;
ctrl->map = array;
+ spin_lock_init(&ctrl->lock);
if (swap_cgroup_prepare(type)) {
/* memory shortage */
ctrl->map = NULL;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: 34-rc1-git3 build failure with CGROUP_MEM_RES_CTLR_SWAP=y
2010-03-14 10:48 34-rc1-git3 build failure with CGROUP_MEM_RES_CTLR_SWAP=y Sachin Sant
2010-03-15 1:02 ` [BUGFIX][PATCH] memcg: avoid use cmpxchg in swap cgroup maintainance (Was " KAMEZAWA Hiroyuki
@ 2010-03-15 1:04 ` Michael Ellerman
1 sibling, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2010-03-15 1:04 UTC (permalink / raw)
To: Sachin Sant
Cc: Linux/PPC Development, nishimura, lizf, linux-kernel,
Balbir Singh
[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]
On Sun, 2010-03-14 at 16:18 +0530, Sachin Sant wrote:
> On a PowerPC box, latest 34-rc1 git(d89b218b8...) fails to build
> with CGROUPS_MEM_RES_CTRL_SWAP=y.
>
> LD init/built-in.o
> LD .tmp_vmlinux1
> mm/built-in.o: In function __xchg:
> arch/powerpc/include/asm/system.h:331: undefined reference to .__xchg_called_with_bad_pointer
> mm/built-in.o: In function __cmpxchg:
> arch/powerpc/include/asm/system.h:474: undefined reference to .__cmpxchg_called_with_bad_pointer
> make: *** [.tmp_vmlinux1] Error 1
>
> The code in question was added via commit 024914477e...
>
> memcg: move charges of anonymous swap
struct swap_cgroup
{
unsigned short id;
};
+unsigned short swap_cgroup_cmpxchg(swp_entry_t ent,
+ unsigned short old, unsigned short new)
+{
...
+ struct swap_cgroup *sc;
...
+ if (cmpxchg(&sc->id, old, new) == old)
On powerpc cmpxchg() currently only handles u32 & u64.
cheers
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [BUGFIX][PATCH] memcg: avoid use cmpxchg in swap cgroup maintainance (Was Re: 34-rc1-git3 build failure with CGROUP_MEM_RES_CTLR_SWAP=y
2010-03-15 1:02 ` [BUGFIX][PATCH] memcg: avoid use cmpxchg in swap cgroup maintainance (Was " KAMEZAWA Hiroyuki
@ 2010-03-15 2:14 ` Balbir Singh
2010-03-15 3:16 ` Daisuke Nishimura
2010-03-15 3:21 ` Benjamin Herrenschmidt
2 siblings, 0 replies; 6+ messages in thread
From: Balbir Singh @ 2010-03-15 2:14 UTC (permalink / raw)
To: KAMEZAWA Hiroyuki
Cc: nishimura, lizf, linux-kernel, Linux/PPC Development,
akpm@linux-foundation.org
* KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> [2010-03-15 10:02:02]:
> On Sun, 14 Mar 2010 16:18:06 +0530
> Sachin Sant <sachinp@in.ibm.com> wrote:
>
> > On a PowerPC box, latest 34-rc1 git(d89b218b8...) fails to build
> > with CGROUPS_MEM_RES_CTRL_SWAP=y.
> >
> > LD init/built-in.o
> > LD .tmp_vmlinux1
> > mm/built-in.o: In function __xchg:
> > arch/powerpc/include/asm/system.h:331: undefined reference to .__xchg_called_with_bad_pointer
> > mm/built-in.o: In function __cmpxchg:
> > arch/powerpc/include/asm/system.h:474: undefined reference to .__cmpxchg_called_with_bad_pointer
> > make: *** [.tmp_vmlinux1] Error 1
> >
> > The code in question was added via commit 024914477e...
> >
> > memcg: move charges of anonymous swap
> >
> Oh..ok, powerpc (and other archs?) can't do 2byte cmpxchg and xchg.
> Then, we should use spinlock rather than that.
>
> How about this ? Nishimura-san, could you consider something better ?
> We need a quick fix.
>
Looks good to me
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
--
Three Cheers,
Balbir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [BUGFIX][PATCH] memcg: avoid use cmpxchg in swap cgroup maintainance (Was Re: 34-rc1-git3 build failure with CGROUP_MEM_RES_CTLR_SWAP=y
2010-03-15 1:02 ` [BUGFIX][PATCH] memcg: avoid use cmpxchg in swap cgroup maintainance (Was " KAMEZAWA Hiroyuki
2010-03-15 2:14 ` Balbir Singh
@ 2010-03-15 3:16 ` Daisuke Nishimura
2010-03-15 3:21 ` Benjamin Herrenschmidt
2 siblings, 0 replies; 6+ messages in thread
From: Daisuke Nishimura @ 2010-03-15 3:16 UTC (permalink / raw)
To: KAMEZAWA Hiroyuki
Cc: d-nishimura, Daisuke Nishimura, lizf, linux-kernel,
Linux/PPC Development, akpm@linux-foundation.org, Balbir Singh
On Mon, 15 Mar 2010 10:02:02 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> On Sun, 14 Mar 2010 16:18:06 +0530
> Sachin Sant <sachinp@in.ibm.com> wrote:
>
> > On a PowerPC box, latest 34-rc1 git(d89b218b8...) fails to build
> > with CGROUPS_MEM_RES_CTRL_SWAP=y.
> >
> > LD init/built-in.o
> > LD .tmp_vmlinux1
> > mm/built-in.o: In function __xchg:
> > arch/powerpc/include/asm/system.h:331: undefined reference to .__xchg_called_with_bad_pointer
> > mm/built-in.o: In function __cmpxchg:
> > arch/powerpc/include/asm/system.h:474: undefined reference to .__cmpxchg_called_with_bad_pointer
> > make: *** [.tmp_vmlinux1] Error 1
> >
> > The code in question was added via commit 024914477e...
> >
> > memcg: move charges of anonymous swap
> >
> Oh..ok, powerpc (and other archs?) can't do 2byte cmpxchg and xchg.
> Then, we should use spinlock rather than that.
>
> How about this ? Nishimura-san, could you consider something better ?
> We need a quick fix.
>
Thank you for fixing this issue.
I think it increases the size of swap_cgroup_ctrl a bit,
but I think it's a good fix.
> ==
> swap_cgroup uses 2bytes data and uses cmpxchg in a new operation.
> 2byte cmpxchg/xchg is not available on some archs. This patch replaces
> cmpxchg/xchg with operations under lock.
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Thanks,
Daisuke Nishimura.
> ---
> mm/page_cgroup.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> Index: mmotm-2.6.34-Mar11/mm/page_cgroup.c
> ===================================================================
> --- mmotm-2.6.34-Mar11.orig/mm/page_cgroup.c
> +++ mmotm-2.6.34-Mar11/mm/page_cgroup.c
> @@ -284,6 +284,7 @@ static DEFINE_MUTEX(swap_cgroup_mutex);
> struct swap_cgroup_ctrl {
> struct page **map;
> unsigned long length;
> + spinlock_t lock;
> };
>
> struct swap_cgroup_ctrl swap_cgroup_ctrl[MAX_SWAPFILES];
> @@ -353,16 +354,22 @@ unsigned short swap_cgroup_cmpxchg(swp_e
> struct swap_cgroup_ctrl *ctrl;
> struct page *mappage;
> struct swap_cgroup *sc;
> + unsigned long flags;
> + unsigned short retval;
>
> ctrl = &swap_cgroup_ctrl[type];
>
> mappage = ctrl->map[idx];
> sc = page_address(mappage);
> sc += pos;
> - if (cmpxchg(&sc->id, old, new) == old)
> - return old;
> + spin_lock_irqsave(&ctrl->lock, flags);
> + retval = sc->id;
> + if (retval == old)
> + sc->id = new;
> else
> - return 0;
> + retval = 0;
> + spin_unlock_irqrestore(&ctrl->lock, flags);
> + return retval;
> }
>
> /**
> @@ -383,13 +390,17 @@ unsigned short swap_cgroup_record(swp_en
> struct page *mappage;
> struct swap_cgroup *sc;
> unsigned short old;
> + unsigned long flags;
>
> ctrl = &swap_cgroup_ctrl[type];
>
> mappage = ctrl->map[idx];
> sc = page_address(mappage);
> sc += pos;
> - old = xchg(&sc->id, id);
> + spin_lock_irqsave(&ctrl->lock, flags);
> + old = sc->id;
> + sc->id = id;
> + spin_unlock_irqrestore(&ctrl->lock, flags);
>
> return old;
> }
> @@ -441,6 +452,7 @@ int swap_cgroup_swapon(int type, unsigne
> mutex_lock(&swap_cgroup_mutex);
> ctrl->length = length;
> ctrl->map = array;
> + spin_lock_init(&ctrl->lock);
> if (swap_cgroup_prepare(type)) {
> /* memory shortage */
> ctrl->map = NULL;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [BUGFIX][PATCH] memcg: avoid use cmpxchg in swap cgroup maintainance (Was Re: 34-rc1-git3 build failure with CGROUP_MEM_RES_CTLR_SWAP=y
2010-03-15 1:02 ` [BUGFIX][PATCH] memcg: avoid use cmpxchg in swap cgroup maintainance (Was " KAMEZAWA Hiroyuki
2010-03-15 2:14 ` Balbir Singh
2010-03-15 3:16 ` Daisuke Nishimura
@ 2010-03-15 3:21 ` Benjamin Herrenschmidt
2 siblings, 0 replies; 6+ messages in thread
From: Benjamin Herrenschmidt @ 2010-03-15 3:21 UTC (permalink / raw)
To: KAMEZAWA Hiroyuki
Cc: nishimura, lizf, linux-kernel, Linux/PPC Development,
akpm@linux-foundation.org, Balbir Singh
> Oh..ok, powerpc (and other archs?) can't do 2byte cmpxchg and xchg.
> Then, we should use spinlock rather than that.
>
> How about this ? Nishimura-san, could you consider something better ?
> We need a quick fix.
sparc64 is the same as powerpc in that regard, maybe others.
Cheers,
Ben.
> ==
> swap_cgroup uses 2bytes data and uses cmpxchg in a new operation.
> 2byte cmpxchg/xchg is not available on some archs. This patch replaces
> cmpxchg/xchg with operations under lock.
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> ---
> mm/page_cgroup.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> Index: mmotm-2.6.34-Mar11/mm/page_cgroup.c
> ===================================================================
> --- mmotm-2.6.34-Mar11.orig/mm/page_cgroup.c
> +++ mmotm-2.6.34-Mar11/mm/page_cgroup.c
> @@ -284,6 +284,7 @@ static DEFINE_MUTEX(swap_cgroup_mutex);
> struct swap_cgroup_ctrl {
> struct page **map;
> unsigned long length;
> + spinlock_t lock;
> };
>
> struct swap_cgroup_ctrl swap_cgroup_ctrl[MAX_SWAPFILES];
> @@ -353,16 +354,22 @@ unsigned short swap_cgroup_cmpxchg(swp_e
> struct swap_cgroup_ctrl *ctrl;
> struct page *mappage;
> struct swap_cgroup *sc;
> + unsigned long flags;
> + unsigned short retval;
>
> ctrl = &swap_cgroup_ctrl[type];
>
> mappage = ctrl->map[idx];
> sc = page_address(mappage);
> sc += pos;
> - if (cmpxchg(&sc->id, old, new) == old)
> - return old;
> + spin_lock_irqsave(&ctrl->lock, flags);
> + retval = sc->id;
> + if (retval == old)
> + sc->id = new;
> else
> - return 0;
> + retval = 0;
> + spin_unlock_irqrestore(&ctrl->lock, flags);
> + return retval;
> }
>
> /**
> @@ -383,13 +390,17 @@ unsigned short swap_cgroup_record(swp_en
> struct page *mappage;
> struct swap_cgroup *sc;
> unsigned short old;
> + unsigned long flags;
>
> ctrl = &swap_cgroup_ctrl[type];
>
> mappage = ctrl->map[idx];
> sc = page_address(mappage);
> sc += pos;
> - old = xchg(&sc->id, id);
> + spin_lock_irqsave(&ctrl->lock, flags);
> + old = sc->id;
> + sc->id = id;
> + spin_unlock_irqrestore(&ctrl->lock, flags);
>
> return old;
> }
> @@ -441,6 +452,7 @@ int swap_cgroup_swapon(int type, unsigne
> mutex_lock(&swap_cgroup_mutex);
> ctrl->length = length;
> ctrl->map = array;
> + spin_lock_init(&ctrl->lock);
> if (swap_cgroup_prepare(type)) {
> /* memory shortage */
> ctrl->map = NULL;
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-03-15 3:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-14 10:48 34-rc1-git3 build failure with CGROUP_MEM_RES_CTLR_SWAP=y Sachin Sant
2010-03-15 1:02 ` [BUGFIX][PATCH] memcg: avoid use cmpxchg in swap cgroup maintainance (Was " KAMEZAWA Hiroyuki
2010-03-15 2:14 ` Balbir Singh
2010-03-15 3:16 ` Daisuke Nishimura
2010-03-15 3:21 ` Benjamin Herrenschmidt
2010-03-15 1:04 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).