linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* RFC: Bouncebuffer fixes
@ 2001-04-28 21:06 Arjan van de Ven
  2001-04-29  0:07 ` Andrea Arcangeli
  0 siblings, 1 reply; 9+ messages in thread
From: Arjan van de Ven @ 2001-04-28 21:06 UTC (permalink / raw)
  To: linux-mm; +Cc: alan

Hi,

The following patch changes the emergency-bouncebuffer pool as present in
2.4.3-ac to be 1) bigger and 2) half reserved for threads with PF_MEMALLOC.
2) is needed to make sure that the vm kernelthreads actually can allocate 
bouncebuffers if they need to free memory. The original code gave out
all emergency bouncebuffers to anyone, even to reads from "random" user
threads.


--- linux/mm/highmem.c.org	Fri Apr 27 21:40:49 2001
+++ linux/mm/highmem.c	Fri Apr 27 21:43:41 2001
@@ -160,7 +160,7 @@
 	spin_unlock(&kmap_lock);
 }
 
-#define POOL_SIZE 32
+#define POOL_SIZE 64
 
 /*
  * This lock gets no contention at all, normally.
@@ -294,7 +294,7 @@
 	 */
 	tmp = &emergency_pages;
 	spin_lock_irq(&emergency_lock);
-	if (!list_empty(tmp)) {
+	if (!list_empty(tmp) && ((current->flags&PF_MEMALLOC)||(nr_emergency_pages>POOL_SIZE/2))) {
 		page = list_entry(tmp->next, struct page, list);
 		list_del(tmp->next);
 		nr_emergency_pages--;
@@ -337,7 +337,7 @@
 	 */
 	tmp = &emergency_bhs;
 	spin_lock_irq(&emergency_lock);
-	if (!list_empty(tmp)) {
+	if (!list_empty(tmp) && ((current->flags&PF_MEMALLOC)||(nr_emergency_bhs>POOL_SIZE/2))) {
 		bh = list_entry(tmp->next, struct buffer_head, b_inode_buffers);
 		list_del(tmp->next);
 		nr_emergency_bhs--;


The following patch, incremental to the previous one, removes
flush_dirty_buffers() from alloc_bounce_buffers to prevent the following
recursion:
bdflsh->flush_dirty_buffers->ll_rw_block->submit_bh->generic_make_request->
__make_request->create_bounce->alloc_bounce_page->flush_dirty_buffers

It also makes sure the tq_disk queue is run everytime an emergency
bouncebuffer is used, instead of only in the event we are out of
emergency buffers. If we are using emergency bounce-buffers, we should
start any pending physical IO asap.

--- linux/mm/highmem.c.org	Sat Apr 28 18:40:52 2001
+++ linux/mm/highmem.c	Sat Apr 28 19:02:54 2001
@@ -285,9 +285,9 @@
 	 * No luck. First, try to flush some low memory buffers.
 	 * This will throttle highmem writes when low memory gets full.
 	 */
-	flush_dirty_buffers(0, 1);
 
 	wakeup_bdflush(0);
+	run_task_queue(&tq_disk);
 
 	/*
 	 * Try to allocate from the emergency pool.
@@ -306,7 +306,6 @@
 	if (!buffer_warned++)
 		printk(KERN_WARNING "mm: critical shortage of bounce buffers.\n");
 
-	run_task_queue(&tq_disk);
 
 	current->policy |= SCHED_YIELD;
 	__set_current_state(TASK_RUNNING);
@@ -328,9 +327,9 @@
 	 * No luck. First, try to flush some low memory buffers.
 	 * This will throttle highmem writes when low memory gets full.
 	 */
-	flush_dirty_buffers(0, 1);
 	
 	wakeup_bdflush(0);
+	run_task_queue(&tq_disk);
 
 	/*
 	 * Try to allocate from the emergency pool.
@@ -349,7 +348,6 @@
 	if (!bh_warned++)
 		printk(KERN_WARNING "mm: critical shortage of bounce bh's.\n");
 
-	run_task_queue(&tq_disk);
 
 	current->policy |= SCHED_YIELD;
 	__set_current_state(TASK_RUNNING);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-05-01  8:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-28 21:06 RFC: Bouncebuffer fixes Arjan van de Ven
2001-04-29  0:07 ` Andrea Arcangeli
2001-04-29  7:56   ` Arjan van de Ven
2001-04-29 13:17     ` Andrea Arcangeli
2001-04-29 13:41       ` Arjan van de Ven
2001-04-29 14:10         ` Andrea Arcangeli
2001-04-30 13:53           ` anti-deadlock logic (was Re: RFC: Bouncebuffer fixes) Szabolcs Szakacsits
2001-04-29 13:42       ` RFC: Bouncebuffer fixes Andrea Arcangeli
2001-05-01  8:14         ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox