Whamcloud - gitweb
LU-9859 libcfs: open code cfs_trace_max_debug_mb() into cfs_trace_set_debug_mb() 29/37829/5
authorMr NeilBrown <neilb@suse.de>
Thu, 12 Mar 2020 19:52:56 +0000 (15:52 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 24 Mar 2020 05:21:07 +0000 (05:21 +0000)
This function in used twice.
In libcfs_debug_init() the usage is pointless as
the only place that set libcfs_debug_mb ensures
that it does not exceed the maximum.  So checking
again can never help.

So open-code the small function into the only
other place that it is used - in cfs_trace_set_debug_mb(),
which is used to set libcfs_debug_mb.

HPC machines are being deployed with 24 TiB or more memory.
Change the variables uses to calculate the max_debug_mb
to unsigned long to avoid a potential overflow and change
80 / 100 scaling factors to 4 / 5.

Linux-commit: 5b5df84f3582b0e3a2ff70d49867bc3e03f67502

Change-Id: I497502bb7418e0b3d24b24c507029652bc9a9e55
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/37829
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/debug.c
libcfs/libcfs/linux-tracefile.c
libcfs/libcfs/tracefile.c
libcfs/libcfs/tracefile.h

index e5bff2e..de58fa6 100644 (file)
@@ -443,11 +443,10 @@ int libcfs_debug_init(unsigned long bufsize)
                        sizeof(libcfs_debug_file_path_arr));
        }
 
-       /*
-        * If libcfs_debug_mb is set to an invalid value or uninitialized
-        * then just make the total buffers smp_num_cpus * TCD_MAX_PAGES
+       /* If libcfs_debug_mb is uninitialized then just make the
+        * total buffers smp_num_cpus * TCD_MAX_PAGES
         */
-       if (max > cfs_trace_max_debug_mb() || max < num_possible_cpus()) {
+       if (max < num_possible_cpus()) {
                max = TCD_MAX_PAGES;
        } else {
                max = (max / num_possible_cpus());
index 5e39fc9..5e6b18b 100644 (file)
@@ -259,10 +259,3 @@ void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
        if (mask & D_TTY)
                cfs_tty_write_message(prefix, mask, buf);
 }
-
-int cfs_trace_max_debug_mb(void)
-{
-       int total_mb = (cfs_totalram_pages() >> (20 - PAGE_SHIFT));
-
-       return max(512, (total_mb * 80) / 100);
-}
index 50d21d6..580c315 100644 (file)
@@ -854,8 +854,9 @@ int cfs_trace_set_debug_mb(int mb)
 {
        int i;
        int j;
-       int pages;
-       int limit = cfs_trace_max_debug_mb();
+       unsigned long pages;
+       unsigned long total_mb = (cfs_totalram_pages() >> (20 - PAGE_SHIFT));
+       unsigned long limit = max_t(unsigned long, 512, (total_mb * 4) / 5);
        struct cfs_trace_cpu_data *tcd;
 
        if (mb < num_possible_cpus()) {
@@ -865,7 +866,7 @@ int cfs_trace_set_debug_mb(int mb)
        }
 
        if (mb > limit) {
-               pr_warn("Lustre: %d MB is too large for debug buffer size, setting it to %d MB.\n",
+               pr_warn("Lustre: %d MB is too large for debug buffer size, setting it to %lu MB.\n",
                        mb, limit);
                mb = limit;
        }
index 7638bc0..30c5ae2 100644 (file)
@@ -83,7 +83,6 @@ extern void libcfs_debug_dumplog_internal(void *arg);
 extern void libcfs_register_panic_notifier(void);
 extern void libcfs_unregister_panic_notifier(void);
 extern int  libcfs_panic_in_progress;
-extern int  cfs_trace_max_debug_mb(void);
 
 #define TCD_MAX_PAGES (5 << (20 - PAGE_SHIFT))
 #define TCD_STOCK_PAGES (TCD_MAX_PAGES)