From: Mikael Starvik <mikael.starvik@axis.com>
To: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>
Cc: "Sebastian Sjöberg" <sebastian.sjoberg@axis.com>
Subject: [PATCH 2.4.20] alloc_kiovec performance improvement
Date: Mon, 5 May 2003 18:54:39 +0200 [thread overview]
Message-ID: <3C6BEE8B5E1BAC42905A93F13004E8AB017DEB2E@mailse01.axis.se> (raw)
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);
next reply other threads:[~2003-05-05 16:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-05 16:54 Mikael Starvik [this message]
2003-05-06 10:55 ` [PATCH 2.4.20] alloc_kiovec performance improvement Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3C6BEE8B5E1BAC42905A93F13004E8AB017DEB2E@mailse01.axis.se \
--to=mikael.starvik@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sebastian.sjoberg@axis.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).