Skip to contentSkip to conversation

fbdev: defio pagelist to pagemap

RFC In review Jaya Kumar 2 participants 2 messages Jan 26, 2009 – Jan 30, 2009 Framebuffer layer

lore
Share & tools
lore

Jaya Kumar

author
#0 lore raw

RFC 1/1 fbdev: defio pagelist to pagemap

Hi Magnus, fbdev friends,

As discussed previously, this is version 2 of converting pagelist use in defio over to pagemap. Thanks to Magnus for ideas and discussion. The primary change is the use of bitmap ops rather than manual setting of bits. If everyone is okay with the idea, then we will also need to convert xen-pvfb, sh and any other drivers using defio. Let me know your thoughts.

Thanks,
jaya

The defio implementation was using a list structure in order to track which pages had been written to. Basically, that was a poor choice and this had been correctly raised as an issue by Tony a while back and Magnus more recently. This patch is an attempt to rectify the issue. These changes aren't tested yet, just compiles.

---
 drivers/video/broadsheetfb.c |   24 ++++++++-------
 drivers/video/fb_defio.c     |   69 +++++++++++++++++-------------------------
 drivers/video/hecubafb.c     |    3 +-
 drivers/video/metronomefb.c  |   21 +++++++------
 include/linux/fb.h           |    7 ++--
 5 files changed, 57 insertions(+), 67 deletions(-)
drivers/video/broadsheetfb.c +13 -11
index 83fa537..c698935 100644
@@ -381,17 +381,16 @@ finish:
 
 
 /* this is called back from the deferred io workqueue */
-static void broadsheetfb_dpy_deferred_io(struct fb_info *info,
-				struct list_head *pagelist)
+static void broadsheetfb_dpy_deferred_io(struct fb_info *info)
 {
 	u16 y1 = 0, h = 0;
 	int prev_index = -1;
-	struct page *cur;
 	struct fb_deferred_io *fbdefio = info->fbdefio;
 	int h_inc;
 	u16 yres = info->var.yres;
 	u16 xres = info->var.xres;
 	int ret;
+	int i;
 
 	/* if we have damage data then use it exclusively */
 	ret = broadsheetfb_process_damage(info);
@@ -403,26 +402,29 @@ static void broadsheetfb_dpy_deferred_io(struct fb_info *info,
 	/* height increment is fixed per page */
 	h_inc = DIV_ROUND_UP(PAGE_SIZE , xres);
 
-	/* walk the written page list and swizzle the data */
-	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
+	for (i = find_first_bit(fbdefio->pagemap, fbdefio->pagecount);
+		i < fbdefio->pagecount;
+		i = find_next_bit(fbdefio->pagemap, fbdefio->pagecount, i),
+		i++) {
 		if (prev_index < 0) {
 			/* just starting so assign first page */
-			y1 = (cur->index << PAGE_SHIFT) / xres;
+			y1 = (i << PAGE_SHIFT) / xres;
 			h = h_inc;
-		} else if ((prev_index + 1) == cur->index) {
+		} else if ((prev_index + 1) == i) {
 			/* this page is consecutive so increase our height */
 			h += h_inc;
 		} else {
 			/* page not consecutive, issue previous update first */
-			broadsheetfb_dpy_update_pages(info->par, y1,
-							min(y1 + h, yres));
+			broadsheetfb_dpy_update_pages(info->par,
+					y1, min((u16) (y1 + h), yres));
 			/* start over with our non consecutive page */
-			y1 = (cur->index << PAGE_SHIFT) / xres;
+			y1 = (i << PAGE_SHIFT) / xres;
 			h = h_inc;
 		}
-		prev_index = cur->index;
+		prev_index = i;
 	}
 
+
 	/* if we still have any pages to update we do so now */
 	if (h >= yres) {
 		/* its a full screen update, just do it */
drivers/video/fb_defio.c +28 -41

144 lines not on this page · raw message

drivers/video/hecubafb.c +1 -2
index 0b4bffb..7d2a80b 100644
@@ -116,8 +116,7 @@ static void hecubafb_dpy_update(struct hecubafb_par *par)
 }
 
 /* this is called back from the deferred io workqueue */
-static void hecubafb_dpy_deferred_io(struct fb_info *info,
-				struct list_head *pagelist)
+static void hecubafb_dpy_deferred_io(struct fb_info *info)
 {
 	hecubafb_dpy_update(info->par);
 }
drivers/video/metronomefb.c +11 -10
index 1de2081..cc29711 100644
@@ -30,7 +30,6 @@
 #include <linux/fb.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/list.h>
 #include <linux/firmware.h>
 #include <linux/dma-mapping.h>
 #include <linux/uaccess.h>
@@ -464,20 +463,22 @@ static u16 metronomefb_dpy_update_page(struct metronomefb_par *par, int index)
 }
 
 /* this is called back from the deferred io workqueue */
-static void metronomefb_dpy_deferred_io(struct fb_info *info,
-				struct list_head *pagelist)
+static void metronomefb_dpy_deferred_io(struct fb_info *info)
 {
 	u16 cksum;
-	struct page *cur;
 	struct fb_deferred_io *fbdefio = info->fbdefio;
 	struct metronomefb_par *par = info->par;
+	int i;
+
+	/* walk the written page map and swizzle the data */
+	for (i = find_first_bit(fbdefio->pagemap, fbdefio->pagecount);
+		i < fbdefio->pagecount;
+		i = find_next_bit(fbdefio->pagemap, fbdefio->pagecount, i),
+		i++) {
 
-	/* walk the written page list and swizzle the data */
-	list_for_each_entry(cur, &fbdefio->pagelist, lru) {
-		cksum = metronomefb_dpy_update_page(par,
-					(cur->index << PAGE_SHIFT));
-		par->metromem_img_csum -= par->csum_table[cur->index];
-		par->csum_table[cur->index] = cksum;
+		cksum = metronomefb_dpy_update_page(par, (i << PAGE_SHIFT));
+		par->metromem_img_csum -= par->csum_table[i];
+		par->csum_table[i] = cksum;
 		par->metromem_img_csum += cksum;
 	}
 
include/linux/fb.h +4 -3
index a92ed07..d1e849a 100644
@@ -600,10 +600,11 @@ struct fb_pixmap {
 struct fb_deferred_io {
 	/* delay between mkwrite and deferred handler */
 	unsigned long delay;
-	struct mutex lock; /* mutex that protects the page list */
-	struct list_head pagelist; /* list of touched pages */
+	struct mutex lock; /* mutex that protects the pagemap */
+	int pagecount; /* count of pages */
+	unsigned long *pagemap; /* bitmap of touched pages */
 	/* callback */
-	void (*deferred_io)(struct fb_info *info, struct list_head *pagelist);
+	void (*deferred_io)(struct fb_info *info);
 };
 #endif
 
Signature · 8 lines
1.5.2.3


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
#1 lore raw
Quoted 8 lines · Jaya Kumar

Hi Magnus, fbdev friends,

As discussed previously, this is version 2 of converting pagelist use in defio over to pagemap. Thanks to Magnus for ideas and discussion. The primary change is the use of bitmap ops rather than manual setting of bits. If everyone is okay with the idea, then we will also need to convert xen-pvfb, sh and any other drivers using defio. Let me know your thoughts.

I hope the sh changes will be trivial. Any change that you can include it in your patch?

Quoted 5 lines

The defio implementation was using a list structure in order to track which pages had been written to. Basically, that was a poor choice and this had been correctly raised as an issue by Tony a while back and Magnus more recently. This patch is an attempt to rectify the issue. These changes aren't tested yet, just compiles.

Hm, what are the requirements for this patch? It doesn't apply to 2.6.28 or latest git.

Quoted 6 lines
drivers/video/fb_defio.c +0 -2
@@ -82,37 +82,14 @@ int fb_deferred_io_fsync(struct file *file, struct dentry *dentry, int datasync)
 EXPORT_SYMBOL_GPL(fb_deferred_io_fsync);
 
 /*
- * Adds page to list of dirty pages, keeps it in sorted order and handles
- * checking for duplicates.

drivers/video/fb_defio.c int fb_deferred_io_fsync(struct file *file, struct dentry *dentry, int datasync) · line 91

Quoted 10 lines
drivers/video/fb_defio.c +3 -3
+ * Set page to mark it dirty in our pagemap
 */
-static void fb_defio_pagelist_add(struct fb_deferred_io *fbdefio,
+static void fb_defio_set_pagemap(struct fb_deferred_io *fbdefio,
                                       struct page *page)
 {
-       struct page *cur;
-       /* protect against the workqueue changing the page list */
+       /* protect against the workqueue changing the pagemap */
       mutex_lock(&fbdefio->lock);

I don't think the mutex is needed since you now are using atomic bitops.

Can you please post up-port your patch to a more recent kernel? I'll have a look at your code again late next week.

Cheers,

/ magnus

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword