Lock less often during logging

This commit is contained in:
Antonio SJ Musumeci 2022-03-20 22:34:55 -04:00
parent 4bf8738e5c
commit b95ff8ba3a
2 changed files with 22 additions and 7 deletions

View File

@ -4006,7 +4006,7 @@ metrics_log_nodes_info(struct fuse *f_,
{ {
char buf[1024]; char buf[1024];
pthread_mutex_lock(&f_->lock); lfmp_lock(&f_->node_fmp);
snprintf(buf,sizeof(buf), snprintf(buf,sizeof(buf),
"time: %zu\n" "time: %zu\n"
"sizeof(node): %zu\n" "sizeof(node): %zu\n"
@ -4030,12 +4030,12 @@ metrics_log_nodes_info(struct fuse *f_,
f_->name_table.size, f_->name_table.size,
f_->name_table.use, f_->name_table.use,
(f_->name_table.size * sizeof(struct node*)), (f_->name_table.size * sizeof(struct node*)),
lfmp_slab_count(&f_->node_fmp), fmp_slab_count(&f_->node_fmp.fmp),
lfmp_slab_usage_ratio(&f_->node_fmp), fmp_slab_usage_ratio(&f_->node_fmp.fmp),
lfmp_avail_objs(&f_->node_fmp), fmp_avail_objs(&f_->node_fmp.fmp),
lfmp_total_allocated_memory(&f_->node_fmp) fmp_total_allocated_memory(&f_->node_fmp.fmp)
); );
pthread_mutex_unlock(&f_->lock); lfmp_unlock(&f_->node_fmp);
fputs(buf,file_); fputs(buf,file_);
} }
@ -4075,7 +4075,6 @@ fuse_maintenance_loop(void *fuse_)
int gc; int gc;
int loops; int loops;
int sleep_time; int sleep_time;
double slab_usage_ratio;
struct fuse *f = (struct fuse*)fuse_; struct fuse *f = (struct fuse*)fuse_;
gc = 0; gc = 0;

View File

@ -42,6 +42,22 @@ lfmp_init(lfmp_t *lfmp_,
pthread_mutex_init(&lfmp_->lock,NULL); 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 static
inline inline
uint64_t uint64_t