summaryrefslogtreecommitdiff
path: root/btt/inlines.h
diff options
context:
space:
mode:
authorAlan D. Brunelle <Alan.Brunelle@hp.com>2007-04-14 08:05:06 +0200
committerJens Axboe <jens.axboe@oracle.com>2007-04-14 08:05:06 +0200
commit6904079488cd3063d171021c8954f955f4236849 (patch)
tree161035c6d78fba22a6acc21cb59d5d019022d5ae /btt/inlines.h
parentc8b0b334cc1028ad8aa5407667233747af96a942 (diff)
downloadblktrace-6904079488cd3063d171021c8954f955f4236849.tar.gz
blktrace-6904079488cd3063d171021c8954f955f4236849.tar.bz2
Combine all outstanding patches into one /big patch/
o Added seek absolute option -- allows one to specify whether they want seek distances to be calculated based upon nearness to previous IO or from start to start. o Added block number dumping o Updated btt documentation for above. o Significant clean up of memory used and files opened. All allocated memory and opened files are cleaned up prior to normal program exit. o Fixed problem where Q & M traces were not being freed properly. o Fixed problem where bilink structures were not being freed properly. o Fixed omission -- output combined seeks in addition to read and write seeks. Signed-off-by: Alan D. Brunelle <Alan.Brunelle@hp.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'btt/inlines.h')
-rw-r--r--btt/inlines.h100
1 files changed, 68 insertions, 32 deletions
diff --git a/btt/inlines.h b/btt/inlines.h
index 38ac5ef..25e5b21 100644
--- a/btt/inlines.h
+++ b/btt/inlines.h
@@ -19,46 +19,58 @@
*
*/
-static inline struct range_info *new_cur(__u64 time)
+static inline void region_init(struct region_info *reg)
{
- struct range_info *cur = malloc(sizeof(struct range_info));
-
- INIT_LIST_HEAD(&cur->head);
- cur->start = time;
- return cur;
+ INIT_LIST_HEAD(&reg->qranges);
+ INIT_LIST_HEAD(&reg->cranges);
}
-static inline void update_range(struct list_head *head_p,
- struct range_info **cur_p, __u64 time)
+static inline void __region_exit(struct list_head *range_head)
{
- if (*cur_p == NULL)
- *cur_p = new_cur(time);
- else {
- __u64 my_delta = (time > (*cur_p)->end) ? time - (*cur_p)->end : 1;
- if (BIT_TIME(my_delta) >= range_delta) {
- list_add_tail(&(*cur_p)->head, head_p);
- *cur_p = new_cur(time);
- }
+ struct list_head *p, *q;
+ struct range_info *rip;
+
+ list_for_each_safe(p, q, range_head) {
+ rip = list_entry(p, struct range_info, head);
+ free(rip);
}
+}
- (*cur_p)->end = time;
+static inline void region_exit(struct region_info *reg)
+{
+ __region_exit(&reg->qranges);
+ __region_exit(&reg->cranges);
}
-static inline void init_region(struct region_info *reg)
+static inline void update_range(struct list_head *head_p, __u64 time)
{
- INIT_LIST_HEAD(&reg->qranges);
- INIT_LIST_HEAD(&reg->cranges);
- reg->qr_cur = reg->cr_cur = NULL;
+ struct range_info *rip;
+
+ if (!list_empty(head_p)) {
+ rip = list_entry(head_p->prev, struct range_info, head);
+
+ if (time < rip->end)
+ return;
+
+ if (BIT_TIME(time - rip->end) < range_delta) {
+ rip->end = time;
+ return;
+ }
+ }
+
+ rip = malloc(sizeof(*rip));
+ rip->start = rip->end = time;
+ list_add_tail(&rip->head, head_p);
}
static inline void update_qregion(struct region_info *reg, __u64 time)
{
- update_range(&reg->qranges, &reg->qr_cur, time);
+ update_range(&reg->qranges, time);
}
static inline void update_cregion(struct region_info *reg, __u64 time)
{
- update_range(&reg->cranges, &reg->cr_cur, time);
+ update_range(&reg->cranges, time);
}
static inline void avg_update(struct avg_info *ap, __u64 t)
@@ -115,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)
@@ -161,6 +173,17 @@ static inline void io_free(struct io *iop)
list_add_tail(&iop->f_head, &free_ios);
}
+static inline void io_free_all(void)
+{
+ struct io *iop;
+ struct list_head *p, *q;
+
+ list_for_each_safe(p, q, &free_ios) {
+ iop = list_entry(p, struct io, f_head);
+ free(iop);
+ }
+}
+
static inline int io_setup(struct io *iop, enum iop_type type)
{
iop->type = type;
@@ -282,12 +305,6 @@ static inline struct rb_root *__get_root(struct d_info *dip, enum iop_type type)
return &roots[type];
}
-static inline void *dip_rb_mkhds(void)
-{
- size_t len = N_IOP_TYPES * sizeof(struct rb_root);
- return memset(malloc(len), 0, len);
-}
-
static inline int dip_rb_ins(struct d_info *dip, struct io *iop)
{
return rb_insert(__get_root(dip, iop->type), iop);
@@ -389,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;