static int __proc_debug_mb(void *data, int write, loff_t pos, void __user *buffer, int nob) { if (!write) { char tmpstr[32]; int len = snprintf(tmpstr, sizeof(tmpstr), "%d", cfs_trace_get_debug_mb()); if (pos >= len) return 0; return cfs_trace_copyout_string(buffer, nob, tmpstr + pos, "\n"); } return cfs_trace_set_debug_mb_usrstr(buffer, nob); }
static int libcfs_param_debug_mb_set(const char *val, const struct kernel_param *kp) { int rc; unsigned int num; rc = kstrtouint(val, 0, &num); if (rc < 0) return rc; if (!*((unsigned int *)kp->arg)) { *((unsigned int *)kp->arg) = num; return 0; } rc = cfs_trace_set_debug_mb(num); if (!rc) *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb(); return rc; }
int libcfs_debug_init(unsigned long bufsize) { unsigned int max = libcfs_debug_mb; int rc = 0; init_waitqueue_head(&debug_ctlwq); if (libcfs_console_max_delay <= 0 || /* not set by user or */ libcfs_console_min_delay <= 0 || /* set to invalid values */ libcfs_console_min_delay >= libcfs_console_max_delay) { libcfs_console_max_delay = CDEBUG_DEFAULT_MAX_DELAY; libcfs_console_min_delay = CDEBUG_DEFAULT_MIN_DELAY; } if (libcfs_debug_file_path) { strlcpy(libcfs_debug_file_path_arr, libcfs_debug_file_path, 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 (max > cfs_trace_max_debug_mb() || max < num_possible_cpus()) { max = TCD_MAX_PAGES; } else { max = max / num_possible_cpus(); max <<= (20 - PAGE_SHIFT); } rc = cfs_tracefile_init(max); if (!rc) { libcfs_register_panic_notifier(); libcfs_debug_mb = cfs_trace_get_debug_mb(); } return rc; }