]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mmap-cache: replace stats accessors with log func
authorVito Caputo <vcaputo@pengaru.com>
Tue, 1 Dec 2020 07:00:34 +0000 (23:00 -0800)
committerLennart Poettering <lennart@poettering.net>
Fri, 4 Dec 2020 11:09:35 +0000 (12:09 +0100)
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
src/journal/mmap-cache.h
src/journal/sd-journal.c

index 9882016436e803e67d1a4925ece39f0ab66ed046..14e45864a9a56953582f495d50be489a85cf952d 100644 (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) {
index 28d5ab1a5677e265cbb70f070d3d05eb405c5621..43dc67f080bc30a8f0db00a6d281ebf339a5f6d8 100644 (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);
index cb1ab88ca57d1ba38cb3731756dd843a50a54074..946f74d53538648663a35cf1ad18b5d3e951bd90 100644 (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);
         }