Skip to contentSkip to conversation

add an iterator index in struct pagevec

PATCH In review Chen, Kenneth W 2 participants 3 messages Dec 5, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add an iterator index in struct pagevec

pagevec is never expected to be more than PAGEVEC_SIZE, I think a unsigned char is enough to count them. This patch makes nr, cold to be unsigned char and also adds an iterator index. With that, the size can be even bumped up by 1 to 15.

include/linux/pagevec.h +5 -4
diff -Nurp linux-2.6.19/include/linux/pagevec.h linux-2.6.19.ken/include/linux/pagevec.h
@@ -8,15 +8,16 @@
 #ifndef _LINUX_PAGEVEC_H
 #define _LINUX_PAGEVEC_H
 
-/* 14 pointers + two long's align the pagevec structure to a power of two */
-#define PAGEVEC_SIZE	14
+/* 15 pointers + 3 char's align the pagevec structure to a power of two */
+#define PAGEVEC_SIZE	15
 
 struct page;
 struct address_space;
 
 struct pagevec {
-	unsigned long nr;
-	unsigned long cold;
+	unsigned char nr;
+	unsigned char cold;
+	unsigned char idx;
 	struct page *pages[PAGEVEC_SIZE];
 };
 
#1 lore raw
Quoted 3 lines · Kenneth W

pagevec is never expected to be more than PAGEVEC_SIZE, I think a unsigned char is enough to count them. This patch makes nr, cold to be unsigned char

Is that on the right side of the speed/space tradeoff?

Quoted 20 lines

and also adds an iterator index. With that,
the size can be even bumped up by 1 to 15.

diff -Nurp linux-2.6.19/include/linux/pagevec.h linux-2.6.19.ken/include/linux/pagevec.h

include/linux/pagevec.h +2 -2
@@ -8,15 +8,16 @@
 #ifndef _LINUX_PAGEVEC_H
 #define _LINUX_PAGEVEC_H
 
-/* 14 pointers + two long's align the pagevec structure to a power of two */
-#define PAGEVEC_SIZE	14
+/* 15 pointers + 3 char's align the pagevec structure to a power of two */
+#define PAGEVEC_SIZE	15
 
 struct page;
 struct address_space;

include/linux/pagevec.h line 23

Quoted 10 lines
include/linux/pagevec.h +3 -2
 
 struct pagevec {
-	unsigned long nr;
-	unsigned long cold;
+	unsigned char nr;
+	unsigned char cold;
+	unsigned char idx;
 	struct page *pages[PAGEVEC_SIZE];
 };
 

I'd have thought that pagevec_init() would want to be involved in this, no?

I must say I'm a bit skeptical about the need for this. But I haven't looked closely at the blockdev-specific dio code yet.

#2 lore raw

Andrew Morton wrote on Monday, December 04, 2006 9:45 PM

Quoted 8 lines
Quoted 3 lines · Kenneth W

pagevec is never expected to be more than PAGEVEC_SIZE, I think a unsigned char is enough to count them. This patch makes nr, cold to be unsigned char

Is that on the right side of the speed/space tradeoff?

I haven't measured speed. Size wise, making them char shrinks vmlinux text size by 112 bytes on x86_64 (using default config option).

Quoted 2 lines

I must say I'm a bit skeptical about the need for this. But I haven't looked closely at the blockdev-specific dio code yet.

It was suggested to declare another struct that embeds pagevec to perform iteration. But I prefer to have pagevec having the capability, it is more compact this way.

It would be nice if you can review blockdev-specific dio code. I would appreciate it very much.

- Ken