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>
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());
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);
-}
{
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()) {
}
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;
}
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)