OpenVZ Forum - RDF feed
type: channel
items: [PATCH v8 2/5] ipc: add sysctl to specify desired next object id
items: Re: [PATCH v8 2/5] ipc: add sysctl to specify desired next object id

[PATCH v8 2/5] ipc: add sysctl to specify desired next object id
type: item
description: This patch adds 3 new variables and sysctls to tune them (by one "next_id" variable for messages, semaphores and shared memory respectively). This variable can be used to set desired id for next allocated IPC object. By default it's equal to -1 and old behaviour is preserved. If this variable is non-negative, then desired idr will be extracted from it and used as a start value to search for free IDR slot. Notes: 1) this patch doesn't garantee, that new object will have desired id. So it's up to user space how to handle new object with wrong id. 2) After sucessfull id allocation attempt, "next_id" will be set back to -1 (if it was non-negative). Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> --- include/linux/ipc_namespace.h | 1 + ipc/ipc_sysctl.c | 28 ++++++++++++++++++++++++++++ ipc/util.c | 16 ++++++++++++---- ipc/util.h | 1 + 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index 5499c92..8704e40 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h @@ -24,6 +24,7 @@ struct ipc_ids { unsigned short seq_max; struct rw_semaphore rw_mutex; struct idr ipcs_idr; + int next_id; }; struct ipc_namespace { diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c index 00fba2b..d06d77a 100644 --- a/ipc/ipc_sysctl.c +++ b/ipc/ipc_sysctl.c @@ -158,6 +158,7 @@ static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write, static int zero; static int one = 1; +static int int_max = INT_MAX; static struct ctl_table ipc_kern_table[] = { { @@ -227,6 +228,33 @@ static struct ctl_table ipc_kern_table[] = { .extra1 = &zero, .extra2 = &one, }, + { + .procname = "sem_next_id", + .data = &init_ipc_ns.ids[IPC_SEM_IDS].next_id, + .maxlen = sizeof(init_ipc_ns.ids[IPC_SEM_IDS].next_id), + .mode = 0644, + .proc_handler = proc_ipc_dointvec_minmax, + .extra1 = &zero, + .extra2 = &int_max, + }, + { + .procname = "msg_next_id", + .data = &init_ipc_ns.ids[IPC_MSG_IDS].next_id, + .ma…
creator: Stanislav Kinsbursky
date: 2012-10-24T15:35:09-00:00

Re: [PATCH v8 2/5] ipc: add sysctl to specify desired next object id
type: item
description: On Wed, 24 Oct 2012 19:35:09 +0400 Stanislav Kinsbursky <skinsbursky@parallels.com> wrote: > This patch adds 3 new variables and sysctls to tune them (by one "next_id" > variable for messages, semaphores and shared memory respectively). > This variable can be used to set desired id for next allocated IPC object. > By default it's equal to -1 and old behaviour is preserved. > If this variable is non-negative, then desired idr will be extracted from it > and used as a start value to search for free IDR slot. > > Notes: > 1) this patch doesn't garantee, that new object will have desired id. So it's > up to user space how to handle new object with wrong id. > 2) After sucessfull id allocation attempt, "next_id" will be set back to -1 > (if it was non-negative). > > --- a/ipc/ipc_sysctl.c > +++ b/ipc/ipc_sysctl.c > @@ -158,6 +158,7 @@ static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write, > > static int zero; > static int one = 1; > +static int int_max = INT_MAX; > > static struct ctl_table ipc_kern_table[] = { > { > @@ -227,6 +228,33 @@ static struct ctl_table ipc_kern_table[] = { > .extra1 = &zero, > .extra2 = &one, > }, > + { > + .procname = "sem_next_id", > + .data = &init_ipc_ns.ids[IPC_SEM_IDS].next_id, > + .maxlen = sizeof(init_ipc_ns.ids[IPC_SEM_IDS].next_id), > + .mode = 0644, > + .proc_handler = proc_ipc_dointvec_minmax, > + .extra1 = &zero, > + .extra2 = &int_max, > + }, > + { > + .procname = "msg_next_id", > + .data = &init_ipc_ns.ids[IPC_MSG_IDS].next_id, > + .maxlen = sizeof(init_ipc_ns.ids[IPC_MSG_IDS].next_id), > + .mode = 0644, > + .proc_handler = proc_ipc_dointvec_minmax, > + .extra1 = &zero, > + .extra2 = &int_max, > + }, > + { > + .procname = "shm_next_id", > + .data = &init_ipc_ns.ids[IPC_SHM_IDS].next_id, > + .maxlen = sizeof(init_ipc_ns.ids[IPC_SHM_IDS].next_id), > + .mode = 0644, > + .proc_handler = proc_ipc_dointvec_minmax, > + .extra1 = &zero, > + .extra2 = &int_max, > + }, > {} > }; ipc_kern_table[] is (badly) documented in Docume…
creator: akpm
date: 2012-10-24T21:41:23-00:00

Re: [PATCH v8 2/5] ipc: add sysctl to specify desired next object id
type: item
description: 25.10.2012 01:41, Andrew Morton пишет: > On Wed, 24 Oct 2012 19:35:09 +0400 > Stanislav Kinsbursky <skinsbursky@parallels.com> wrote: > >> This patch adds 3 new variables and sysctls to tune them (by one "next_id" >> variable for messages, semaphores and shared memory respectively). >> This variable can be used to set desired id for next allocated IPC object. >> By default it's equal to -1 and old behaviour is preserved. >> If this variable is non-negative, then desired idr will be extracted from it >> and used as a start value to search for free IDR slot. >> >> Notes: >> 1) this patch doesn't garantee, that new object will have desired id. So it's >> up to user space how to handle new object with wrong id. >> 2) After sucessfull id allocation attempt, "next_id" will be set back to -1 >> (if it was non-negative). >> >> --- a/ipc/ipc_sysctl.c >> +++ b/ipc/ipc_sysctl.c >> @@ -158,6 +158,7 @@ static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write, >> >> static int zero; >> static int one = 1; >> +static int int_max = INT_MAX; >> >> static struct ctl_table ipc_kern_table[] = { >> { >> @@ -227,6 +228,33 @@ static struct ctl_table ipc_kern_table[] = { >> .extra1 = &zero, >> .extra2 = &one, >> }, >> + { >> + .procname = "sem_next_id", >> + .data = &init_ipc_ns.ids[IPC_SEM_IDS].next_id, >> + .maxlen = sizeof(init_ipc_ns.ids[IPC_SEM_IDS].next_id), >> + .mode = 0644, >> + .proc_handler = proc_ipc_dointvec_minmax, >> + .extra1 = &zero, >> + .extra2 = &int_max, >> + }, >> + { >> + .procname = "msg_next_id", >> + .data = &init_ipc_ns.ids[IPC_MSG_IDS].next_id, >> + .maxlen = sizeof(init_ipc_ns.ids[IPC_MSG_IDS].next_id), >> + .mode = 0644, >> + .proc_handler = proc_ipc_dointvec_minmax, >> + .extra1 = &zero, >> + .extra2 = &int_max, >> + }, >> + { >> + .procname = "shm_next_id", >> + .data = &init_ipc_ns.ids[IPC_SHM_IDS].next_id, >> + .maxlen = sizeof(init_ipc_ns.ids[IPC_SHM_IDS].next_id), >> + .mode = 0644, >> + .proc_handler = proc_ipc_dointvec_minmax, >> + .extra1 =…
creator: Stanislav Kinsbursky
date: 2012-10-25T07:53:10-00:00