From: "Alan D. Brunelle" <alan.brunelle@hp.com>
To: linux-btrace@vger.kernel.org
Subject: [BTT PATCH] More malloc reduction - remove excessive bilink allocations...
Date: Tue, 10 Apr 2007 12:53:08 +0000 [thread overview]
Message-ID: <461B88B4.9030504@hp.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: fix-bilink-allocs --]
[-- Type: text/plain, Size: 3107 bytes --]
From: Alan D. Brunelle <Alan.Brunelle@hp.com>
Reduce amount of allocations done for bilinks.
Used to do 1-for-1 allocations of bilinks for traces processed, we now
have reduced this to the largest tree size left (thousands instead of
millions of allocs for a moderately sized file).
This data set used to result in :
malloc/free: 11,241,958 allocs, 11,241,958 frees, 440,381,362 bytes allocated.
It is now:
malloc/free: 41,076 allocs, 41,076 frees, 9,272,450 bytes allocated.
Signed-off-by: Alan D. Brunelle <Alan.Brunelle@hp.com>
---
btt/bt_timeline.c | 2 ++
btt/globals.h | 3 ++-
btt/inlines.h | 25 ++++++++++++++++++++++---
3 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/btt/bt_timeline.c b/btt/bt_timeline.c
index 32c900e..d998e99 100644
--- a/btt/bt_timeline.c
+++ b/btt/bt_timeline.c
@@ -39,6 +39,7 @@ time_t genesis, last_vtrace;
LIST_HEAD(all_devs);
LIST_HEAD(all_procs);
LIST_HEAD(free_ios);
+LIST_HEAD(free_bilinks);
LIST_HEAD(rmhd);
LIST_HEAD(retries);
__u64 q_histo[N_HIST_BKTS], d_histo[N_HIST_BKTS];
@@ -89,6 +90,7 @@ int main(int argc, char *argv[])
dip_exit();
pip_exit();
io_free_all();
+ bilink_free_all();
region_exit(&all_regions);
free(input_name);
diff --git a/btt/globals.h b/btt/globals.h
index 1b54cb0..912bb7c 100644
--- a/btt/globals.h
+++ b/btt/globals.h
@@ -190,6 +190,7 @@ struct bilink {
struct list_head down_head, up_head;
struct io *diop, *uiop;
};
+#define bilink_free_head down_head
/* bt_timeline.c */
@@ -205,7 +206,7 @@ extern struct list_head all_devs, all_procs, retries, rmhd;
extern struct avgs_info all_avgs;
extern __u64 last_q, next_retry_check;
extern struct region_info all_regions;
-extern struct list_head free_ios;
+extern struct list_head free_ios, free_bilinks;
extern __u64 iostat_interval, iostat_last_stamp;
extern time_t genesis, last_vtrace;
extern double t_astart, t_aend;
diff --git a/btt/inlines.h b/btt/inlines.h
index edb2182..25e5b21 100644
--- a/btt/inlines.h
+++ b/btt/inlines.h
@@ -127,7 +127,7 @@ static inline struct io *io_alloc(void)
struct io *iop;
if (!list_empty(&free_ios)) {
- iop = list_entry(free_ios.next, struct io, f_head);
+ iop = list_entry(free_ios.prev, struct io, f_head);
LIST_DEL(&iop->f_head);
# if defined(COUNT_IOS)
@@ -406,12 +406,31 @@ static inline int type2c(enum iop_type type)
static inline void bilink_free(struct bilink *blp)
{
- free(blp);
+ list_add_tail(&blp->bilink_free_head, &free_bilinks);
+}
+
+static inline void bilink_free_all(void)
+{
+ struct bilink *blp;
+ struct list_head *p, *q;
+
+ list_for_each_safe(p, q, &free_bilinks) {
+ blp = list_entry(p, struct bilink, bilink_free_head);
+ free(blp);
+ }
}
static inline struct bilink *bilink_alloc(struct io *diop, struct io *uiop)
{
- struct bilink *blp = malloc(sizeof(*blp));
+ struct bilink *blp;
+
+ if (!list_empty(&free_bilinks)) {
+ blp = list_entry(free_bilinks.prev, struct bilink,
+ bilink_free_head);
+ LIST_DEL(&blp->bilink_free_head);
+ }
+ else
+ blp = malloc(sizeof(*blp));
blp->diop = diop;
blp->uiop = uiop;
reply other threads:[~2007-04-10 12:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=461B88B4.9030504@hp.com \
--to=alan.brunelle@hp.com \
--cc=linux-btrace@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.