# \[PATCH\] FB deffered io: keep pagelist sorted

- From: Yauhen Kharuzhy \<hidden\>
- Date: 2008-07-07 13:09:46 
- List: linux-fbdev
- Page: https://ratatoskr.run/linux-fbdev/2008/07/13458460
- Thread: https://ratatoskr.run/linux-fbdev/2008/07/13458461/t.md

```text
eInk display drivers will do less work if list of
changed pages will be sorted.

Apollo controller has 'Partial Update' feature ---
updating only a part of a image, which can be done in
small time.

Signed-off-by: Yauhen Kharuzhy <redacted>
---
 drivers/video/fb_defio.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
index 24843fd..5517e51 100644
--- a/drivers/video/fb_defio.c
+++ b/drivers/video/fb_defio.c
@@ -74,6 +74,7 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 {
 	struct fb_info *info = vma->vm_private_data;
 	struct fb_deferred_io *fbdefio = info->fbdefio;
+	struct page *cur;
 
 	/* this is a callback we get when userspace first tries to
 	write to the page. we schedule a workqueue. that workqueue
@@ -83,7 +84,11 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
 
 	/* protect against the workqueue changing the page list */
 	mutex_lock(&fbdefio->lock);
-	list_add(&page->lru, &fbdefio->pagelist);
+	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
+		if (cur->index > page->index)
+			break;
+	}
+	list_add(&page->lru, cur->lru.prev);
 	mutex_unlock(&fbdefio->lock);
 
 	/* come back after delay to process the deferred IO */
-- 
1.5.6


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
```
