Skip to content

Commit 62cf5a4

Browse files
driver: ring_buf_size is now a module parameter
sysdig-CLA-1.0-signed-off-by: Nicolas Vanheuverzwijn <nicolas.vanheu@gmail.com>
1 parent 36224b5 commit 62cf5a4

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

driver/main.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2628,10 +2628,38 @@ void sysdig_exit(void)
26282628
#endif
26292629
}
26302630

2631+
static int set_ring_buf_size(const char *val, const struct kernel_param *kp)
2632+
{
2633+
int n = 0, ret;
2634+
2635+
ret = kstrtoint(val, 10, &n);
2636+
if (ret != 0)
2637+
return -EINVAL;
2638+
else if (n < 2 * PAGE_SIZE) {
2639+
pr_err("Ring buffer size too small (%ld bytes, must be at least %ld bytes)\n",
2640+
(long)n,
2641+
(long)PAGE_SIZE * 2);
2642+
return -EINVAL;
2643+
}
2644+
else if (n / PAGE_SIZE * PAGE_SIZE != n) {
2645+
pr_err("Ring buffer size is not a multiple of the page size\n");
2646+
return -EINVAL;
2647+
}
2648+
2649+
return param_set_int(val, kp);
2650+
}
2651+
2652+
static const struct kernel_param_ops ring_buf_size_param_ops = {
2653+
.set = set_ring_buf_size,
2654+
.get = param_get_int,
2655+
};
2656+
26312657
module_init(sysdig_init);
26322658
module_exit(sysdig_exit);
26332659
module_param(max_consumers, uint, 0444);
26342660
MODULE_PARM_DESC(max_consumers, "Maximum number of consumers that can simultaneously open the devices");
2661+
module_param_cb(ring_buf_size, &ring_buf_size_param_ops, &ring_buf_size, 0660);
2662+
MODULE_PARM_DESC(ring_buf_size, "Size of the ring buffer containing syscall");
26352663
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
26362664
module_param(verbose, bool, 0444);
26372665
#endif

userspace/libscap/scap.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,15 @@ scap_t* scap_open_live_int(char *error, int32_t *rc,
323323
//
324324
// Allocate the device descriptors.
325325
//
326+
327+
FILE * fp = fopen("/sys/module/" PROBE_NAME "/parameters/ring_buf_size", "r");
328+
if (fp == NULL){
329+
snprintf(error, SCAP_LASTERR_SIZE, "Could not read module parameter ring_buf_size at '/sys/module/" PROBE_NAME "/parameters/ring_buf_size'");
330+
*rc = SCAP_FAILURE;
331+
return NULL;
332+
}
333+
fscanf(fp, "%d", &ring_buf_size);
334+
326335
len = ring_buf_size * 2;
327336

328337
for(j = 0, all_scanned_devs = 0; j < handle->m_ndevs && all_scanned_devs < handle->m_ncpus; ++all_scanned_devs)

0 commit comments

Comments
 (0)