avoid preemption in memory controller code
Subsystems (3)
PATCH 1/1 avoid preemption in memory controller code
the lru_lock of struct mem_group_per_zone is used to avoid preemption during the __mem_cgroup_stat_add_safe function.
therefore, a raw_spinlock_t should be used.
--- mm/memcontrol.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
@@ -95,9 +95,9 @@ enum mem_cgroup_zstat_index {struct mem_cgroup_per_zone {/* -* spin_lock to protect the per cgroup LRU +* raw_spin_lock to protect the per cgroup LRU */ -spinlock_t lru_lock; +raw_spinlock_t lru_lock;struct list_head active_list;struct list_head inactive_list;unsigned long count[NR_MEM_CGROUP_ZSTAT ];
Signature · 1 line
1.5.6.3
Steven Rostedt
reviewerHi Tim,
Quoted 3 lines · Tim Blechmann
the
lru_lockof structmem_group_per_zoneis used to avoid preemption during the__mem_cgroup_stat_add_safefunction.
therefore, araw_spinlock_tshould be used.
What is the reason that this must avoid preemption? Is there another way to solve this? I rather not just add a raw spinlock if we can help it.
-- Steve
Quoted 27 lines
Signed-off-by Tim Blechmann <[email protected]>--- mm/memcontrol.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)mm/memcontrol.c +2
-2@@ -95,9 +95,9 @@ enum mem_cgroup_zstat_index {struct mem_cgroup_per_zone {/* -* spin_lock to protect the per cgroup LRU +* raw_spin_lock to protect the per cgroup LRU */ -spinlock_t lru_lock; +raw_spinlock_t lru_lock;struct list_head active_list;struct list_head inactive_list;unsigned long count[NR_MEM_CGROUP_ZSTAT ];Signature · 1 line
1.5.6.3
Quoted 5 lines
Quoted 3 lines
the
lru_lockof structmem_group_per_zoneis used to avoid preemption during the__mem_cgroup_stat_add_safefunction.
therefore, araw_spinlock_tshould be used.What is the reason that this must avoid preemption?
it guards a call to smp_processor_id() in __mem_cgroup_stat_add_safe(). see http://article.gmane.org/gmane.linux.rt.user/3690
Quoted 3 lines
Is there another
way to solve this? I rather not just add a raw spinlock if we can help it.
not sure, maybe one can disable preemption for that specific function?
tim
--
[email protected]
http://tim.klingt.org
Art is either a complaint or do something else
John Cage quoting Jasper Johns
Steven Rostedt
reviewerQuoted 8 lines · Tim Blechmann
Quoted 5 lines
Quoted 3 lines
the
lru_lockof structmem_group_per_zoneis used to avoid preemption during the__mem_cgroup_stat_add_safefunction.
therefore, araw_spinlock_tshould be used.What is the reason that this must avoid preemption?
it guards a call to
smp_processor_id()in__mem_cgroup_stat_add_safe(). see http://article.gmane.org/gmane.linux.rt.user/3690
We could simply create a
preempt_disable_rt();
that will only disable preemption when CONFIG_PREEMPT_RT is set. and then we could add
int cpu; preempt_disable_rt(); cpu = smp_processor_id(); stat->cpustat[cpu].count[idx] += val; preempt_enable_rt();
Or something similar.
-- Steve
Quoted 16 lines
Quoted 4 lines
Is there another
way to solve this? I rather not just add a raw spinlock if we can help it.not sure, maybe one can disable preemption for that specific function?
tim
--
[email protected]
http://tim.klingt.orgArt is either a complaint or do something else
John Cage quoting Jasper Johns
PATCH 1/1 preempt_disable_rt for CONFIG_PREEMPT_RT
in some cases, spinlocks are used to avoid preemption. does not work correctly, when CONFIG_PREEMPT_RT is enabled.
therefore two new macros are introduced:
preempt_disable_rt/preempt_disable_rt behave like their equivalents, if CONFIG_PREEMPT_RT is enabled, and as noops otherwise.
--- include/linux/preempt.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
include/linux/preempt.h +10 -0
@@ -93,6 +93,16 @@ do { \#endif +#ifdef CONFIG_PREEMPT_RT +#define preempt_disable_rt preempt_disable +#define preempt_enable_rt preempt_enable +#else +#define +#define preempt_disable_rt do { } while (0) +#define preempt_enable_rt do { } while (0) +#endif + +#ifdef CONFIG_PREEMPT_NOTIFIERS struct preempt_notifier ;
Signature · 1 line
1.5.6.3
Quoted 4 lines · Tim Blechmann
the
lru_lockof structmem_group_per_zoneis used to avoid preemption during the__mem_cgroup_stat_add_safefunction.
therefore, araw_spinlock_tshould be used.
FYI, this lru_lock no longer exists in -mm tree. The following patch removes that lock:
http://marc.info/?l=linux-mm&m=122665814801979&w=2
Quoted 21 lines
Signed-off-by Tim Blechmann <[email protected]>--- mm/memcontrol.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)mm/memcontrol.c +2
-2@@ -95,9 +95,9 @@ enum mem_cgroup_zstat_index {struct mem_cgroup_per_zone {/* -* spin_lock to protect the per cgroup LRU +* raw_spin_lock to protect the per cgroup LRU */ -spinlock_t lru_lock; +raw_spinlock_t lru_lock;struct list_head active_list;struct list_head inactive_list;unsigned long count[NR_MEM_CGROUP_ZSTAT ];
Quoted 25 lines · On Tue, 09 Dec 2008 09:13:12 +0800 Li Zefan <[email protected]> wrote:
CC Balbir Singh <[email protected]>CC KAMEZAWA Hiroyuki <[email protected]>Quoted 4 lines · Tim Blechmann
the
lru_lockof structmem_group_per_zoneis used to avoid preemption during the__mem_cgroup_stat_add_safefunction.
therefore, araw_spinlock_tshould be used.FYI, this
lru_lockno longer exists in -mm tree. The following patch removes that lock:http://marc.info/?l=linux-mm&m=122665814801979&w=2Quoted 11 lines
Signed-off-by Tim Blechmann <[email protected]>--- mm/memcontrol.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)mm/memcontrol.c +0
-0@@ -95,9 +95,9 @@ enum mem_cgroup_zstat_index {
Quoted 10 lines
mm/memcontrol.c enum mem_cgroup_zstat_index { · line 103
Quoted 10 lines
mm/memcontrol.c +2
-2struct mem_cgroup_per_zone {/* -* spin_lock to protect the per cgroup LRU +* raw_spin_lock to protect the per cgroup LRU */ -spinlock_t lru_lock; +raw_spinlock_t lru_lock;struct list_head active_list;struct list_head inactive_list;unsigned long count[NR_MEM_CGROUP_ZSTAT ];
yes..I remvoed that. Please see mmotm and subscribe linux-mm, if you have interests memory resource controller.
Anyway, thanks.
-Kame