Static tunable semvmx and semaem
Quoted 1 line · William Lee Irwin III
I think the __setup()'s should be moved to
ipc/sem.c;
It is always better if all the initializations related to IPC V semaphores are in ipc/sem.c file. Thanks for the suggestion. Below is the updated patch with __setup()calls in ipc/sem.c.
Thanks,
ArvindP.S. I've changed my mail client to evaluation and cross checked whether the patches works. Please get back to me in case there are any issues while patching.
include/linux/sysctl.h +2 -0
@@ -130,6 +130,8 @@KERN_PIDMAX =55 ,/* int: PID # limit */ KERN_CORE_PATTERN =56 ,/* string: pattern for core-file names */ KERN_PANIC_ON_OOPS =57 ,/* int: whether we will panic on an oops */ +KERN_SEMVMX =58 ,/* int: maximum limit on semval */ + KERN_SEMAEM=59, /* int: maximun limit on semaem */ };
ipc/sem.c +32 -6
@@ -102,6 +102,9 @@#define sc_semopm (sem_ctls[2])#define sc_semmni (sem_ctls[3]) +unsigned int semvmx=32767 ; +int semaem=16384 ; +static int used_sems;void __init sem_init (void )
@@ -280,7 +283,7 @@/* * Exceeding the undo range is an error. */ -if (undo < (-SEMAEM -1 ) || undo >SEMAEM ) +if (undo < (-semaem -1 ) || undo > semaem) {/* Don't undo the undo */ sop->sem_flg &= ~SEM_UNDO ;
@@ -290,7 +293,7 @@ }if (curr->semval <0 ) goto would_block; -if (curr->semval >SEMVMX ) +if (curr->semval > semvmx) goto out_of_range; }
@@ -482,7 +485,7 @@ seminfo.semmns = sc_semmns; seminfo.semmsl = sc_semmsl; seminfo.semopm = sc_semopm; - seminfo.semvmx =SEMVMX ; + seminfo.semvmx = semvmx; seminfo.semmnu =SEMMNU ; seminfo.semmap =SEMMAP ; seminfo.semume =SEMUME ;
@@ -492,7 +495,7 @@ seminfo.semaem = used_sems; }else { seminfo.semusz =SEMUSZ ; - seminfo.semaem =SEMAEM ; + seminfo.semaem = semaem; } max_id = sem_ids.max_id;up (&sem_ids.sem);
@@ -613,7 +616,7 @@ }for (i =0 ; i < nsems; i++) { -if (sem_io[i] >SEMVMX ) { +if (sem_io[i] > semvmx) { err = -ERANGE ; goto out_free; }
@@ -672,7 +675,7 @@int val = arg.val;struct sem_undo *un; err = -ERANGE ; -if (val >SEMVMX || val <0 ) +if (val > semvmx || val <0 ) goto out_unlock;for (un = sma->undo; un; un = un->id_next)
@@ -1295,6 +1298,29 @@unlock_kernel (); } +static int __init _semvmx (char *str) +{ +get_option (&str, &semvmx); +if (semvmx>65535 || semvmx <=0 ) + { + semvmx=32767 ; + } +return 1 ; +} +__setup ("semvmx=" , _semvmx); + +static int __init _semaem (char *str) +{ +get_option (&str, &semaem); +if (semaem>32767 || semaem <=0 ) + { + semaem=16384 ; + } +return 1 ; +} +__setup ("semaem=" , _semaem); + +#ifdef CONFIG_PROC_FS static int sysvipc_sem_read_proc (char *buffer,char **start,off_t offset,int length,int *eof,void *data) {
kernel/sysctl.c +6 -0
@@ -79,6 +79,8 @@extern int msg_ctlmnb;extern int msg_ctlmni;extern int sem_ctls[]; +extern unsigned int semvmx; +extern int semaem;#endif #ifdef __sparc__
@@ -237,6 +239,10 @@ 0644, NULL, &proc_dointvec}, {KERN_SEM, "sem", &sem_ctls, 4*sizeof (int), 0644, NULL, &proc_dointvec}, + {KERN_SEMVMX, "semvmx", &semvmx, sizeof (int), + 0444, NULL, &proc_dointvec}, + {KERN_SEMAEM, "semaem", &semaem, sizeof (int), + 0444, NULL, &proc_dointvec}, #endif #ifdef CONFIG_MAGIC_SYSRQ {KERN_SYSRQ, "sysrq", &sysrq_enabled, sizeof (int),