* [PATCH 2.4.20] alloc_kiovec performance improvement
@ 2003-05-05 16:54 Mikael Starvik
2003-05-06 10:55 ` Alan Cox
0 siblings, 1 reply; 2+ messages in thread
From: Mikael Starvik @ 2003-05-05 16:54 UTC (permalink / raw)
To: 'linux-kernel@vger.kernel.org'; +Cc: Sebastian Sjöberg
alloc_kiovec always allocates 1024 buffer heads which is a waste
with performance in the cases when the buffers aren't used.
The patch below adds variants that doesn't allocate the buffer heads.
A similar approach would be to introduce a common function with
a flag that indicates if buffer heads should be allocated.
/Mikael
diff -Nurp linux-2.4.20/fs/iobuf.c linux-2.4.20-local/fs/iobuf.c
--- linux-2.4.20/fs/iobuf.c Fri Nov 29 00:53:15 2002
+++ linux-2.4.20-local/fs/iobuf.c Mon May 5 18:35:12 2003
@@ -114,6 +114,29 @@ nomem:
return -ENOMEM;
}
+int alloc_kiovec_nobhs(int nr, struct kiobuf **bufp)
+{
+ int i;
+ struct kiobuf *iobuf;
+
+ for (i = 0; i < nr; i++) {
+ iobuf = kmem_cache_alloc(kiobuf_cachep, GFP_KERNEL);
+ if (unlikely(!iobuf))
+ goto nomem;
+ if (unlikely(kiobuf_init(iobuf)))
+ goto nomem2;
+ bufp[i] = iobuf;
+ }
+
+ return 0;
+
+nomem2:
+ kmem_cache_free(kiobuf_cachep, iobuf);
+nomem:
+ free_kiovec_nobhs(i, bufp);
+ return -ENOMEM;
+}
+
void free_kiovec(int nr, struct kiobuf **bufp)
{
int i;
@@ -128,6 +151,20 @@ void free_kiovec(int nr, struct kiobuf *
kmem_cache_free(kiobuf_cachep, bufp[i]);
}
}
+
+void free_kiovec_nobhs(int nr, struct kiobuf **bufp)
+{
+ int i;
+ struct kiobuf *iobuf;
+
+ for (i = 0; i < nr; i++) {
+ iobuf = bufp[i];
+ if (iobuf->locked)
+ unlock_kiovec(1, &iobuf);
+ kfree(iobuf->maplist);
+ kmem_cache_free(kiobuf_cachep, bufp[i]);
+ }
+}
int expand_kiobuf(struct kiobuf *iobuf, int wanted)
{
diff -Nurp linux-2.4.20/include/linux/iobuf.h linux-2.4.20-local/include/linux/iobuf.h
--- linux-2.4.20/include/linux/iobuf.h Fri Nov 29 00:53:15 2002
+++ linux-2.4.20-local/include/linux/iobuf.h Mon May 5 18:35:51 2003
@@ -64,7 +64,9 @@ void mark_dirty_kiobuf(struct kiobuf *io
void end_kio_request(struct kiobuf *, int);
void simple_wakeup_kiobuf(struct kiobuf *);
int alloc_kiovec(int nr, struct kiobuf **);
+int alloc_kiovec_nobhs(int nr, struct kiobuf **);
void free_kiovec(int nr, struct kiobuf **);
+void free_kiovec_nobhs(int nr, struct kiobuf **);
int expand_kiobuf(struct kiobuf *, int);
void kiobuf_wait_for_io(struct kiobuf *);
extern int alloc_kiobuf_bhs(struct kiobuf *);
diff -Nurp linux-2.4.20/kernel/ksyms.c linux-2.4.20-local/kernel/ksyms.c
--- linux-2.4.20/kernel/ksyms.c Fri Nov 29 00:53:15 2002
+++ linux-2.4.20-local/kernel/ksyms.c Mon May 5 18:36:25 2003
@@ -410,7 +410,9 @@ EXPORT_SYMBOL(__br_write_unlock);
/* Kiobufs */
EXPORT_SYMBOL(alloc_kiovec);
+EXPORT_SYMBOL(alloc_kiovec_nobhs);
EXPORT_SYMBOL(free_kiovec);
+EXPORT_SYMBOL(free_kiovec_nobhs);
EXPORT_SYMBOL(expand_kiobuf);
EXPORT_SYMBOL(map_user_kiobuf);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 2.4.20] alloc_kiovec performance improvement
2003-05-05 16:54 [PATCH 2.4.20] alloc_kiovec performance improvement Mikael Starvik
@ 2003-05-06 10:55 ` Alan Cox
0 siblings, 0 replies; 2+ messages in thread
From: Alan Cox @ 2003-05-06 10:55 UTC (permalink / raw)
To: Mikael Starvik
Cc: 'linux-kernel@vger.kernel.org', Sebastian Sjöberg
On Llu, 2003-05-05 at 17:54, Mikael Starvik wrote:
> alloc_kiovec always allocates 1024 buffer heads which is a waste
> with performance in the cases when the buffers aren't used.
See the patches in -ac that came from tuning Oracle performance.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-05-06 11:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-05 16:54 [PATCH 2.4.20] alloc_kiovec performance improvement Mikael Starvik
2003-05-06 10:55 ` Alan Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).