Skip to content

Commit

Permalink
Merge pull request #1026 from trapexit/loglock
Browse files Browse the repository at this point in the history
Lock less often during logging
  • Loading branch information
trapexit committed Mar 21, 2022
2 parents 4bf8738 + b95ff8b commit 77e6f40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
13 changes: 6 additions & 7 deletions libfuse/lib/fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -4006,7 +4006,7 @@ metrics_log_nodes_info(struct fuse *f_,
{
char buf[1024];

pthread_mutex_lock(&f_->lock);
lfmp_lock(&f_->node_fmp);
snprintf(buf,sizeof(buf),
"time: %zu\n"
"sizeof(node): %zu\n"
Expand All @@ -4030,12 +4030,12 @@ metrics_log_nodes_info(struct fuse *f_,
f_->name_table.size,
f_->name_table.use,
(f_->name_table.size * sizeof(struct node*)),
lfmp_slab_count(&f_->node_fmp),
lfmp_slab_usage_ratio(&f_->node_fmp),
lfmp_avail_objs(&f_->node_fmp),
lfmp_total_allocated_memory(&f_->node_fmp)
fmp_slab_count(&f_->node_fmp.fmp),
fmp_slab_usage_ratio(&f_->node_fmp.fmp),
fmp_avail_objs(&f_->node_fmp.fmp),
fmp_total_allocated_memory(&f_->node_fmp.fmp)
);
pthread_mutex_unlock(&f_->lock);
lfmp_unlock(&f_->node_fmp);

fputs(buf,file_);
}
Expand Down Expand Up @@ -4075,7 +4075,6 @@ fuse_maintenance_loop(void *fuse_)
int gc;
int loops;
int sleep_time;
double slab_usage_ratio;
struct fuse *f = (struct fuse*)fuse_;

gc = 0;
Expand Down
16 changes: 16 additions & 0 deletions libfuse/lib/lfmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ lfmp_init(lfmp_t *lfmp_,
pthread_mutex_init(&lfmp_->lock,NULL);
}

static
inline
void
lfmp_lock(lfmp_t *lfmp_)
{
pthread_mutex_lock(&lfmp_->lock);
}

static
inline
void
lfmp_unlock(lfmp_t *lfmp_)
{
pthread_mutex_unlock(&lfmp_->lock);
}

static
inline
uint64_t
Expand Down

0 comments on commit 77e6f40

Please sign in to comment.