From 3a595c597a43864c58aa0c3036be46d520250569 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 30 Nov 2020 23:00:34 -0800 Subject: [PATCH] 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. --- src/journal/mmap-cache.c | 10 ++-------- src/journal/mmap-cache.h | 3 +-- src/journal/sd-journal.c | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c index 9882016436..14e45864a9 100644 --- a/src/journal/mmap-cache.c +++ b/src/journal/mmap-cache.c @@ -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) { diff --git a/src/journal/mmap-cache.h b/src/journal/mmap-cache.h index 28d5ab1a56..43dc67f080 100644 --- a/src/journal/mmap-cache.h +++ b/src/journal/mmap-cache.h @@ -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); diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index cb1ab88ca5..946f74d535 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -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); }