mmap-cache: replace stats accessors with log func

In preparation for logging more mmap-cache statistics get rid of this
piecemeal stats accessor api and just have a debug log output function
for producing the stats.

Updates the one call site using these accessors, moving what that site
did into the new log function.  So the output is unchanged for now,
just a trivial refactor.
This commit is contained in:
Vito Caputo 2020-11-30 23:00:34 -08:00 committed by Lennart Poettering
parent ffac398613
commit 3a595c597a
3 changed files with 4 additions and 11 deletions

View File

@ -537,16 +537,10 @@ int mmap_cache_get(
return add_mmap(m, f, prot, context, keep_always, offset, size, st, ret, ret_size);
}
unsigned mmap_cache_get_hit(MMapCache *m) {
void mmap_cache_stats_log_debug(MMapCache *m) {
assert(m);
return m->n_hit;
}
unsigned mmap_cache_get_missed(MMapCache *m) {
assert(m);
return m->n_missed;
log_debug("mmap cache statistics: %u hit, %u miss", m->n_hit, m->n_missed);
}
static void mmap_cache_process_sigbus(MMapCache *m) {

View File

@ -28,7 +28,6 @@ int mmap_cache_get(
MMapFileDescriptor * mmap_cache_add_fd(MMapCache *m, int fd);
void mmap_cache_free_fd(MMapCache *m, MMapFileDescriptor *f);
unsigned mmap_cache_get_hit(MMapCache *m);
unsigned mmap_cache_get_missed(MMapCache *m);
void mmap_cache_stats_log_debug(MMapCache *m);
bool mmap_cache_got_sigbus(MMapCache *m, MMapFileDescriptor *f);

View File

@ -2170,7 +2170,7 @@ _public_ void sd_journal_close(sd_journal *j) {
safe_close(j->inotify_fd);
if (j->mmap) {
log_debug("mmap cache statistics: %u hit, %u miss", mmap_cache_get_hit(j->mmap), mmap_cache_get_missed(j->mmap));
mmap_cache_stats_log_debug(j->mmap);
mmap_cache_unref(j->mmap);
}