From: Vito Caputo Date: Tue, 1 Dec 2020 07:00:34 +0000 (-0800) Subject: mmap-cache: replace stats accessors with log func X-Git-Tag: v248-rc1~579 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a595c597a43864c58aa0c3036be46d520250569;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c index 9882016436e..14e45864a9a 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 28d5ab1a567..43dc67f080b 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 cb1ab88ca57..946f74d5353 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); }