Skip to contentSkip to conversation

2.5.38-mm2 pdflush_list

DISCUSSION William Lee Irwin III 2 participants 4 messages Sep 25, 2002 Memory management

lore
Share & tools
lore
#0 lore raw

Program received signal SIGSEGV, Segmentation fault. pdflush_operation (fn=0xc0142428 <background_writeout>, arg0=0)

    at /mnt/b/2.5.38/linux-2.5/include/linux/list.h:130
130     /mnt/b/2.5.38/linux-2.5/include/linux/list.h: No such file or directory.
        in /mnt/b/2.5.38/linux-2.5/include/linux/list.h
(gdb) bt
#0  pdflush_operation (fn=0xc0142428 <background_writeout>, arg0=0)
    at /mnt/b/2.5.38/linux-2.5/include/linux/list.h:130
#1  0xc01423cf in balance_dirty_pages (mapping=0xd749383c)
    at page-writeback.c:127
#2  0xc014241f in balance_dirty_pages_ratelimited (mapping=0xd749383c)
    at page-writeback.c:160
#3  0xc013300f in generic_file_write_nolock (file=0xd7c67bc0, iov=0xc6aa9f70, 
    nr_segs=1, ppos=0xd7c67be0) at filemap.c:1643
#4  0xc013313f in generic_file_write (file=0xd7c67bc0, 
    buf=0x804bda0 '\001' <repeats 200 times>..., count=65487, ppos=0xd7c67be0)
    at filemap.c:1675
#5  0xc014640c in vfs_write (file=0xd7c67bc0, 
    buf=0x804bda0 '\001' <repeats 200 times>..., count=65487, pos=0xd7c67be0)
    at read_write.c:214
#6  0xc01464ee in sys_write (fd=7, 
    buf=0x804bda0 '\001' <repeats 200 times>..., count=65487)
    at read_write.c:244

#7 0xc010746f in syscall_call () at process.c:685

There's a NULL in this circular list:

(gdb) p &pdflush_list
$15 = (struct list_head *) 0xc02b5bdc
(gdb) p pdflush_list
$16 = {next = 0xdbf23fe0, prev = 0xe0125fe0}
(gdb) p *(pdflush_list.next)
$17 = {next = 0x0, prev = 0xc02b5bdc}
(gdb) p *(pdflush_list.prev)
$18 = {next = 0xc02b5bdc, prev = 0xdbf23fe0}
(gdb) p *((pdflush_list.prev)->prev)
$19 = {next = 0x0, prev = 0xc02b5bdc}
(gdb) p *(((pdflush_list.prev)->prev)->prev)
$20 = {next = 0xdbf23fe0, prev = 0xe0125fe0}
(gdb) p *pdf
$21 = {who = 0x0, fn = 0, arg0 = 0, list = {next = 0x0, prev = 0xc02b5bdc},
when_i_went_to_sleep = 0}

Cheers,
Bill
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/

#1 lore raw
Quoted 4 lines · William Lee Irwin III

...
There's a NULL in this circular list:

The only way I can see this happen is if someone sprayed out a bogus wakeup. Are you using preempt (or software suspend??) --
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/

#2 lore raw
Quoted 1 line · William Lee Irwin III
Quoted 1 line

There's a NULL in this circular list:

Quoted 2 lines · Andrew Morton

The only way I can see this happen is if someone sprayed out a bogus wakeup. Are you using preempt (or software suspend??)

Nope. Just SMP. Happened on the NUMA-Q's. I couldn't figure out what was going on from this. It's still up for postmortem, though.

Cheers,
Bill
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/

#3 lore raw
Quoted 11 lines · William Lee Irwin III
Quoted 1 line · William Lee Irwin III
Quoted 1 line

There's a NULL in this circular list:

Quoted 2 lines · Andrew Morton

The only way I can see this happen is if someone sprayed out a bogus wakeup. Are you using preempt (or software suspend??)

Nope. Just SMP. Happened on the NUMA-Q's. I couldn't figure out what was going on from this. It's still up for postmortem, though.

Don't know.

I tightened up the locking in there, added some paranoia and a couple of printks for when it happens again.

mm/pdflush.c renamed from mm/pdflush.c~pdflush-tightening +23 -13
@@ -79,9 +79,9 @@ static unsigned long last_empty_jifs;
  */
 struct pdflush_work {
 	struct task_struct *who;	/* The thread */
-	void (*fn)(unsigned long);	/* A callback function for pdflush to work on */
-	unsigned long arg0;		/* An argument to the callback function */
-	struct list_head list;		/* On pdflush_list, when the thread is idle */
+	void (*fn)(unsigned long);	/* A callback function */
+	unsigned long arg0;		/* An argument to the callback */
+	struct list_head list;		/* On pdflush_list, when idle */
 	unsigned long when_i_went_to_sleep;
 };
 
@@ -99,24 +99,35 @@ static int __pdflush(struct pdflush_work
 	current->flags |= PF_FLUSHER;
 	my_work->fn = NULL;
 	my_work->who = current;
+	INIT_LIST_HEAD(&my_work->list);
 
 	spin_lock_irq(&pdflush_lock);
 	nr_pdflush_threads++;
-//	printk("pdflush %d [%d] starts\n", nr_pdflush_threads, current->pid);
 	for ( ; ; ) {
 		struct pdflush_work *pdf;
 
-		list_add(&my_work->list, &pdflush_list);
-		my_work->when_i_went_to_sleep = jiffies;
 		set_current_state(TASK_INTERRUPTIBLE);
+		list_move(&my_work->list, &pdflush_list);
+		my_work->when_i_went_to_sleep = jiffies;
 		spin_unlock_irq(&pdflush_lock);
 
 		if (current->flags & PF_FREEZE)
 			refrigerator(PF_IOTHREAD);
 		schedule();
 
-		if (my_work->fn)
-			(*my_work->fn)(my_work->arg0);
+		spin_lock_irq(&pdflush_lock);
+		if (!list_empty(&my_work->list)) {
+			printk("pdflush: bogus wakeup!\n");
+			my_work->fn = NULL;
+			continue;
+		}
+		if (my_work->fn == NULL) {
+			printk("pdflush: NULL work function\n");
+			continue;
+		}
+		spin_unlock_irq(&pdflush_lock);
+
+		(*my_work->fn)(my_work->arg0);
 
 		/*
 		 * Thread creation: For how long have there been zero
@@ -132,6 +143,7 @@ static int __pdflush(struct pdflush_work
 		}
 
 		spin_lock_irq(&pdflush_lock);
+		my_work->fn = NULL;
 
 		/*
 		 * Thread destruction: For how long has the sleepiest
@@ -143,13 +155,12 @@ static int __pdflush(struct pdflush_work
 			continue;
 		pdf = list_entry(pdflush_list.prev, struct pdflush_work, list);
 		if (jiffies - pdf->when_i_went_to_sleep > 1 * HZ) {
-			pdf->when_i_went_to_sleep = jiffies;	/* Limit exit rate */
+			/* Limit exit rate */
+			pdf->when_i_went_to_sleep = jiffies;
 			break;					/* exeunt */
 		}
-		my_work->fn = NULL;
 	}
 	nr_pdflush_threads--;
-//	printk("pdflush %d [%d] ends\n", nr_pdflush_threads, current->pid);
 	spin_unlock_irq(&pdflush_lock);
 	return 0;
 }
@@ -191,11 +202,10 @@ int pdflush_operation(void (*fn)(unsigne
 		list_del_init(&pdf->list);
 		if (list_empty(&pdflush_list))
 			last_empty_jifs = jiffies;
-		spin_unlock_irqrestore(&pdflush_lock, flags);
 		pdf->fn = fn;
 		pdf->arg0 = arg0;
-		wmb();			/* ? */
 		wake_up_process(pdf->who);
+		spin_unlock_irqrestore(&pdflush_lock, flags);
 	}
 	return ret;
 }

.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/