[SSI] openssi/kernel/cluster/ssi/mosixll balance.c, 1.12, 1.13 freemem.c, 1.9, 1.10 info.c, 1.9, 1.10 kernel.c, 1.9, 1.10 load.c, 1.7, 1.8
Roger Tsang <[email protected]>
| Newsgroups | gmane.linux.cluster.ssic.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/mosixll
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv32011/kernel/cluster/ssi/mosixll
Modified Files:
Tag: OPENSSI-FC
balance.c freemem.c info.c kernel.c load.c
Log Message:
MOSIX:
- Fix acquiring loadinfo_lock without disabling bottom half. Actually in OpenSSI
we don't need to disable bottom half for loadinfo_lock, but we are doing this f
or compatiblity with openMosix code. Eventually we should clean this up for Open
SSI.
- Fix mosix_task->pages_i_bring race.
- Comment unused code.
MOSIX (#ifdef SSI_BALANCE_MEMORY):
- Fix deadlock bug nesting task_lock() in write_lock_irq(&tasklist_lock).
- Remove inappropriate task_lock() for mm_struct->last_memsort, used, swapped.
- New mm_struct->memsort_lock spinlock replaces write_lock_irq(&tasklist_lock);
protects mm_struct->last_memsort, used, swapped.
VPROC:
- New separate spinlock for pvp_comm_de, pvp_comm_mnt deprecates task_lock(). (#
ifdef VPROC_LOCK_PVP_COMM)
Index: kernel.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/mosixll/kernel.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- kernel.c 27 Oct 2009 03:18:29 -0000 1.9
+++ kernel.c 17 Nov 2009 06:09:02 -0000 1.10
@@ -92,12 +92,17 @@
}};
#endif
+#ifdef CONFIG_MOSIX_TOPOLOGY
struct opcost deputy_here[MAX_MOSIX_TOPOLOGY];
+#endif
+#ifndef CONFIG_SSI
struct task_struct *info_proc;
int info_daemon_active = 0;
+#endif
/**************************************************/
+#ifndef CONFIG_SSI
int
balpriority(int w)
{
@@ -122,6 +127,7 @@
}
/*NOTREACHED*/
}
+#endif /* !CONFIG_SSI */
/* Called with spin_lock_irq on whereto_lock */
inline void
@@ -218,6 +224,7 @@
return(1);
}
+#ifndef CONFIG_SSI
int
mosix_go_home_for_reason(int must, int reason)
{
@@ -237,6 +244,7 @@
}
return(ret);
}
+#endif /* !CONFIG_SSI */
int
stay_me_and_my_clones(uint32_t reasons)
@@ -327,6 +335,7 @@
*/
#ifndef CONFIG_SSI
+#if 0
int
remote_need_while_asleep(struct task_struct *p)
{
@@ -611,6 +620,7 @@
return(any);
}
}
+#endif /* 0 */
#endif /* !CONFIG_SSI */
int
@@ -784,6 +794,7 @@
}
#ifndef CONFIG_SSI
+#if 0
void
mosix_very_exit(void)
{
@@ -1093,7 +1104,6 @@
read_unlock(&tasklist_lock);
}
}
-#endif /* !CONFIG_SSI */
void
mosix_exit_mm(struct task_struct *p)
@@ -1134,7 +1144,6 @@
#endif /* !CONFIG_SSI */
}
-#ifndef CONFIG_SSI
int
mosix_pre_clone(void)
{
@@ -1173,6 +1182,7 @@
read_unlock(&tasklist_lock);
}
}
+#endif /* 0 */
#endif /* !CONFIG_SSI */
/* 'run_on' and 'run_off' must be called with the runqueue_lock! */
Index: load.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/mosixll/load.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- load.c 27 Oct 2009 03:18:29 -0000 1.7
+++ load.c 17 Nov 2009 06:09:02 -0000 1.8
@@ -69,8 +69,10 @@
#endif /* !CONFIG_SSI */
int stable_export; /* machine dependent stabilizing factor */
+#ifdef DEBUG
int Tvis;
int Tload;
+#endif
#ifdef CONFIG_SSI
int PE;
@@ -104,7 +106,9 @@
static unsigned long accload = 0; /* accumulated load (*128) */
#endif /* CONFIG_SSI */
unsigned long newload;
+#ifdef DEBUG
static int display_counter = 0;
+#endif
#ifdef CONFIG_MOSIX_RESEARCH
unsigned int new_io_read;
unsigned int new_io_write;
@@ -190,6 +194,7 @@
read_unlock(&tasklist_lock);
#endif
+#ifdef DEBUG
if(Tvis)
#ifdef CONFIG_SSI
printk("\0337\033[22;55HL=%d,E=%d,R=%lu,U=%d \0338",
@@ -206,7 +211,8 @@
printk("%7d\t%10d\t%10d\t%d\n",
(int)accload, (int)upper_load, (int)ladd, (int)ticks);
}
- write_lock(&loadinfo_lock);
+#endif /* DEBUG */
+ write_lock_bh(&loadinfo_lock);
#ifdef CONFIG_SSI
loadinfo[0].mem = latest_free_mem;
#endif
@@ -241,7 +247,7 @@
old_io_write = new_io_write;
#endif /* CONFIG_MOSIX_RESEARCH */
- write_unlock(&loadinfo_lock);
+ write_unlock_bh(&loadinfo_lock);
#ifdef CONFIG_SSI
up(&load_left_lock);
Index: balance.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/mosixll/balance.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- balance.c 27 Oct 2009 03:18:29 -0000 1.12
+++ balance.c 17 Nov 2009 06:09:02 -0000 1.13
@@ -53,15 +53,19 @@
static int load_balancing_counter;
static int memory_balancing_counter;
+#ifdef DEBUG
extern int Tload;
+#endif
-#ifdef CONFIG_SSI
+#ifndef CONFIG_SSI
int mosadmin_mode_stay;
int mosadmin_mode_lstay;
int mosadmin_mode_block;
int mosadmin_mode_quiet;
int mosadmin_mode_nomfs;
int mosadmin_gateways;
+#else
+int mosadmin_mode_quiet;
void ssi_do_decay(struct mosix_task *);
#endif /* CONFIG_SSI */
@@ -549,6 +553,7 @@
continue;
#endif
pri = (priority > 4*MILLION) ? 4*MILLION : priority; /*4 secs*/
+#ifdef DEBUG
if(Tload)
#ifdef CONFIG_SSI
printk("process=%d, load=%lu pri=%u bestpri=%u mload=%lu, bload=%lu \n",
@@ -559,6 +564,7 @@
p->pid, m->load, pri, bestpri, minload,
bestload);
#endif
+#endif /* DEBUG */
#ifdef CONFIG_SSI
ssi_do_decay(m);
#endif
@@ -622,6 +628,7 @@
#endif /* CONFIG_MOSIX_DEBUG */
}
+/* Acquires read_lock_bh(&loadinfo_lock) */
void
load_balance(void)
{
@@ -633,8 +640,10 @@
register struct loadinfo *l;
int doit = 0;
+#ifndef CONFIG_SSI
if(mosadmin_mode_stay)
return;
+#endif
read_lock_bh(&loadinfo_lock);
load = altload(loadinfo[0].load, loadinfo[0].speed, loadinfo[0].ncpus);
@@ -755,6 +764,8 @@
#endif
}
+/* Acquires read_lock_bh(&loadinfo_lock) */
+/* Code path may acquire read_lock(&tasklist_lock) */
void
memory_balance(void)
{
@@ -767,8 +778,7 @@
int doit = 0;
#ifdef SSI_BALANCE_MEMORY
- if(mosadmin_mode_stay || mosadmin_mode_quiet ||
- !memory_badly_required(&need))
+ if (mosadmin_mode_quiet || !memory_badly_required(&need))
return;
#else
if(mosadmin_mode_stay || mosadmin_mode_quiet
@@ -843,10 +853,25 @@
#endif /* CONFIG_MOSIX_FS */
};
-void
#ifdef CONFIG_SSI
+/* Locking: this function may acquire ...
+ * read_lock_bh(&loadinfo_lock)
+ * read_lock(&tasklist_lock)
+ * -> sighand->siglock
+ */
+/* Locking: called functions may acquire...
+ * write_lock_bh(&loadinfo_lock)
+ * -> task_rq_lock()
+ * down(&load_left_lock)
+ * spin_lock_irq(&whereto_lock)
+ * read_lock_bh(&loadinfo_lock)
+ * read_lock(&tasklist_lock)
+ * task_lock()
+ */
+void
consider(int reason, struct sonstats *sons, clusternode_t *node)
#else
+void
consider(int reason, struct sonstats *sons)
#endif
{
@@ -898,10 +923,16 @@
#endif
#endif /* CONFIG_MOSIX_DEBUG */
+#ifdef CONFIG_SSI
+ if ((m->stay & DSTAY) || !PE || mosadmin_mode_quiet)
+ goto out;
+ if (reason && m->stay)
+#else
if((m->stay & DSTAY) || !PE || mosadmin_mode_quiet)
goto out;
if(reason && (m->stay || mosadmin_mode_stay ||
(mosadmin_mode_lstay && !(m->dflags & DREMOTE))))
+#endif /* !CONFIG_SSI */
{
#ifdef CONFIG_MOSIX_DEBUG
if(ds_debug & (DSDEB_CONSIDER|DSDEB_MIG))
@@ -1387,6 +1418,11 @@
#endif /* !CONFIG_SSI */
}
+/* Acquires spin_lock_irq(&whereto_lock) */
+/* Called functions may acquire...
+ * read_lock_bh(&loadinfo_lock)
+ * read_lock(&tasklist_lock)
+ */
void
#ifdef CONFIG_SSI
unchoose_me(struct task_struct *p)
Index: freemem.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/mosixll/freemem.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- freemem.c 27 Oct 2009 03:18:29 -0000 1.9
+++ freemem.c 17 Nov 2009 06:09:02 -0000 1.10
@@ -51,6 +51,7 @@
static inline unsigned long
current_free_mem(void)
{
+ smp_wmb();
return latest_free_mem;
}
#else
@@ -80,10 +81,12 @@
}
#endif
-int
#ifdef SSI_BALANCE_MEMORY
+/* Acquires read_lock(&tasklist_lock), task_lock() */
+int
memory_badly_required(unsigned long *need)
#else
+int
memory_badly_required(void)
#endif
{
@@ -104,19 +107,21 @@
n = pages_to_keep_free - n;
} else
n -= pages_to_keep_free;
+
+ read_lock(&tasklist_lock);
#else
n = current_free_mem() - pages_to_keep_free;
-#endif
write_lock_irq(&tasklist_lock);
-#ifndef SSI_BALANCE_MEMORY
++marker;
-#endif
+#endif /* !SSI_BALANCE_MEMORY */
for_each_process(p)
{
#ifdef CONFIG_SSI
#ifdef SSI_BALANCE_MEMORY
/* SSI: mosix.pages_i_bring is +ve. See release_migrations() */
+ task_lock(p);
b += p->mosix.pages_i_bring;
+ task_unlock(p);
#endif
if (p->mosix.stay)
@@ -134,8 +139,9 @@
task_unlock(p);
#endif /* !SSI_BALANCE_MEMORY */
}
- write_unlock_irq(&tasklist_lock);
#ifdef SSI_BALANCE_MEMORY
+ read_unlock(&tasklist_lock);
+
if (do_need || n < b) { /* add negative pages */
if (do_need)
n += b;
@@ -154,6 +160,7 @@
}
return 0;
#else
+ write_unlock_irq(&tasklist_lock);
if(n < 0 && n > -MIN_EXPECTED_PROC_SIZE)
n = (int)-MIN_EXPECTED_PROC_SIZE;
if(n < 0)
@@ -166,6 +173,7 @@
/* "memory_relief_quality" is called with tasklist_lock read-locked */
#ifdef SSI_BALANCE_MEMORY
+/* Acquires spinlock(&mm->memsort_lock) */
unsigned long
memory_relief_quality(struct task_struct *p, unsigned long need)
#else
@@ -182,35 +190,43 @@
#endif
struct mm_struct *mm;
-#ifndef SSI_BALANCE_MEMORY
+#ifdef SSI_BALANCE_MEMORY
+ mm = get_task_mm(p);
+ if (!mm)
+ return 0;
+
+ spin_lock(&mm->memsort_lock);
+ if (!mm->last_memsort) {
+ spin_unlock(&mm->memsort_lock);
+ mmput(mm);
+ return 0;
+ }
+ used = mm->used;
+ swapped = mm->swapped;
+ spin_unlock(&mm->memsort_lock);
+
+ mmput(mm);
+
+ if (used >= need) {
+ if (used < 2 * need)
+ q = MDP_HIGHEST_QUALITY * (150 - used * 50 / need) / 100;
+ else
+ q = MDP_HIGHEST_QUALITY * need / (1 + used - need);
+ } else
+#else
read_lock(&tasklist_lock);
-#endif
task_lock(p);
if(!(mm = p->mm) || !mm->last_memsort)
{
task_unlock(p);
-#ifndef SSI_BALANCE_MEMORY
read_unlock(&tasklist_lock);
-#endif
return(0);
}
used = mm->used;
-#ifndef SSI_BALANCE_MEMORY
unused = mm->unused;
-#endif
swapped = mm->swapped;
task_unlock(p);
-#ifndef SSI_BALANCE_MEMORY
read_unlock(&tasklist_lock);
-#endif
-#ifdef SSI_BALANCE_MEMORY
- if (used >= need) {
- if (used < 2 * need)
- q = MDP_HIGHEST_QUALITY * (150 - used * 50 / need) / 100;
- else
- q = MDP_HIGHEST_QUALITY * need / (1 + used - need);
- } else
-#else
if (used >= need && used < 2 * need)
q = MDP_HIGHEST_QUALITY * (150 - used * 50 / need) / 100;
else if(used >= need)
@@ -256,6 +272,10 @@
int buffered, kernel, inactive, cached, tasked;
#else
unsigned long count;
+
+ /* Avoid race with move_eligible_processes_off() */
+ if (!atomic_read(&loadlevel_on))
+ return;
#endif
#ifdef CONFIG_SSI
@@ -383,6 +403,14 @@
* sort pages into 3 piles: "used", "unused" and "swapped"
* plus another distinction for unused pages not otherwise accounted for
*/
+/* Acquires...
+ * spin_lock(&mm->page_table_lock)
+#ifdef SSI_BALANCE_MEMORY
+ * spin_lock(&mm->memsort_lock)
+#else
+ * write_lock_irq(&tasklist_lock)
+#endif
+ */
void
sort_and_age_pages(struct mm_struct *mm)
{
@@ -496,7 +524,11 @@
if(need_flush)
flush_tlb_mm(mm);
spin_unlock(&mm->page_table_lock);
+#ifdef SSI_BALANCE_MEMORY
+ spin_lock(&mm->memsort_lock);
+#else
write_lock_irq(&tasklist_lock);
+#endif
mm->used = used;
mm->swapped = swapped;
#ifndef SSI_BALANCE_MEMORY
@@ -504,7 +536,11 @@
mm->private_unused = private_unused;
#endif
mm->last_memsort = jiffies ? : 1;
+#ifdef SSI_BALANCE_MEMORY
+ spin_unlock(&mm->memsort_lock);
+#else
write_unlock_irq(&tasklist_lock);
+#endif
#ifdef CONFIG_MOSIX_DEBUG
if(ds_debug & DSDEB_SUPERMEM)
#ifdef SSI_BALANCE_MEMORY
@@ -567,7 +603,11 @@
if (!PE)
#ifdef CONFIG_SSI
continue;
+#ifdef SSI_BALANCE_MEMORY
+ if (!atomic_read(&loadlevel_on))
+#else
if (!atomic_read(&loadlevel_on) && !latest_free_mem)
+#endif
continue;
#else
wait_for_mosix_configuration(NULL);
@@ -576,33 +616,52 @@
continue;
compute_freemem();
#ifdef CONFIG_SSI
+#ifndef SSI_BALANCE_MEMORY
/* Currently for SSI, we are disabling the
* memory balancing, since it causes EBUSY
* errors during the migrates
*/
-#ifndef SSI_BALANCE_MEMORY
continue;
-#endif
+#endif /* !SSI_BALANCE_MEMORY */
#endif /* CONFIG_SSI */
interval = sort_interval(0);
n = 0;
+#ifdef SSI_BALANCE_MEMORY
+ read_lock(&tasklist_lock);
+ for_each_process(p)
+ if (!(p->mosix.stay & DSTAY_PER_MM)) {
+ mm = get_task_mm(p);
+ if (!mm)
+ continue;
+ if (mm == &init_mm) {
+ mmput(mm);
+ continue;
+ }
+ spin_lock(&mm->memsort_lock);
+ if (!time_before(mm->last_memsort+interval, jiffies)) {
+ spin_unlock(&mm->memsort_lock);
+ mmput(mm);
+ continue;
+ }
+ spin_unlock(&mm->memsort_lock);
+ mms[n++] = mm;
+ if (n == mmno) {
+ need_increase = 1;
+ break;
+ }
+ }
+ read_unlock(&tasklist_lock);
+#else /* !SSI_BALANCE_MEMORY */
write_lock_irq(&tasklist_lock);
-#ifndef SSI_BALANCE_MEMORY
++marker;
-#endif
for_each_process(p)
if(!(p->mosix.stay & DSTAY_PER_MM))
{
task_lock(p);
mm = p->mm;
-#ifdef SSI_BALANCE_MEMORY
- if((mm = p->mm) && mm != &init_mm &&
- time_before(mm->last_memsort + interval, jiffies))
-#else
if((mm = p->mm) && mm != &init_mm && mm->mark != marker
&& time_before(mm->last_memsort + interval,
jiffies))
-#endif
{
if(n >= mmno)
need_increase = 1;
@@ -610,14 +669,13 @@
{
atomic_inc(&mm->mm_users);
mms[n++] = mm;
-#ifndef SSI_BALANCE_MEMORY
mm->mark = marker;
-#endif
}
}
task_unlock(p);
}
write_unlock_irq(&tasklist_lock);
+#endif /* !SSI_BALANCE_MEMORY */
for(i = 0 ; i < n ; i++)
{
mm = mms[i];
Index: info.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/mosixll/info.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- info.c 27 Oct 2009 03:18:29 -0000 1.9
+++ info.c 17 Nov 2009 06:09:02 -0000 1.10
@@ -968,6 +968,18 @@
* but not before we adjust the local and remote loads to discourage
* further migrations.
*/
+/* Locking: will acquire...
+ * write_lock_bh(&loadinfo_lock)
+ * -> task_rq_lock()
+ * down(&load_left_lock)
+ * spin_lock_irq(&whereto_lock)
+ * task_lock()
+ */
+/* Called functions may acquire...
+ * spin_lock_irq(&whereto_lock)
+ * read_lock_bh(&loadinfo_lock)
+ * read_lock(&tasklist_lock)
+ */
void
release_migrations(int whereto)
{
@@ -1048,12 +1060,14 @@
printk("release_migrations: Could not adjust machine #%d (not in list)\n", whereto);
#endif /* CONFIG_MOSIX_DEBUG */
#ifdef SSI_BALANCE_MEMORY
+ task_lock(p);
m->pages_i_bring = pages; /* discourage 'memory_badly_required' */
+ task_unlock(p);
#else
m->pages_i_bring = -pages; /* discourage 'memory_badly_required' */
#endif
#ifdef CONFIG_SSI
- unchoose_me(current);
+ unchoose_me(p);
#else
unchoose_me();
#endif
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july