[CRIU] [PATCH 3/4] ipc/sysctl: c/r kernel.{msg_next_id, sem_next_id, shm_next_id}

Pavel Emelyanov xemul at virtuozzo.com
Thu Jul 14 05:08:38 PDT 2016


On 07/14/2016 02:17 PM, Pavel Tikhomirov wrote:
> 
> 
> On 07/14/2016 01:54 PM, Pavel Emelyanov wrote:
>> On 07/13/2016 04:06 PM, Pavel Tikhomirov wrote:
>>>
>>>
>>> On 07/13/2016 03:53 PM, Pavel Emelyanov wrote:
>>>> On 07/04/2016 10:47 AM, Pavel Tikhomirov wrote:
>>>>> These are only three left in ipc_kern_table which we haven't
>>>>> checkpointed yet, I'm not sure if somebody really uses them
>>>>> except criu, but to be consistent, beter not to change them
>>>>> while c/r.
>>>>>
>>>>> *We have these sysctls writable in VZ7 CT.
>>>>> https://jira.sw.ru/browse/PSBM-48397
>>>>>
>>>>> Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
>>>>> ---
>>>>>  criu/ipc_ns.c        | 33 ++++++++++++++++++++++++++++++++-
>>>>>  images/ipc-var.proto |  3 +++
>>>>>  2 files changed, 35 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/criu/ipc_ns.c b/criu/ipc_ns.c
>>>>> index 02fb9a0..c75cfb5 100644
>>>>> --- a/criu/ipc_ns.c
>>>>> +++ b/criu/ipc_ns.c
>>>>> @@ -313,6 +313,12 @@ static int ipc_sysctl_req(IpcVarEntry *e, int op)
>>>>>  		{ "fs/mqueue/msgsize_default",	&e->mq_msgsize_default,	CTL_U32 },
>>>>>  	};
>>>>>
>>>>> +	struct sysctl_req req_next[] = {
>>>>> +		{ "kernel/msg_next_id", &e->msg_next_id, CTL_U32 },
>>>>> +		{ "kernel/sem_next_id", &e->sem_next_id, CTL_U32 },
>>>>> +		{ "kernel/shm_next_id", &e->shm_next_id, CTL_U32 },
>>>>> +	};
>>>>> +
>>>>>  	int ret;
>>>>>
>>>>>  	ret = sysctl_op(req, ARRAY_SIZE(req), op, CLONE_NEWIPC);
>>>>> @@ -324,8 +330,19 @@ static int ipc_sysctl_req(IpcVarEntry *e, int op)
>>>>>  		return 0;
>>>>>  	}
>>>>>
>>>>> -	return sysctl_op(req_mq, ARRAY_SIZE(req_mq) - (e->has_mq_msg_default ? 0 : 2),
>>>>> +	ret = sysctl_op(req_mq, ARRAY_SIZE(req_mq) - (e->has_mq_msg_default ? 0 : 2),
>>>>>  	                 op, CLONE_NEWIPC);
>>>>> +	if (ret)
>>>>> +		return ret;
>>>>> +
>>>>> +	/* Skip xxx_next_id which were -1 or haven't existed on dump */
>>>>> +	if (e->has_msg_next_id && (ret = sysctl_op(&req_next[0], 1, op, CLONE_NEWIPC)))
>>>>> +		return ret;
>>>>> +	if (e->has_sem_next_id && (ret = sysctl_op(&req_next[1], 1, op, CLONE_NEWIPC)))
>>>>> +		return ret;
>>>>> +	if (e->has_shm_next_id && (ret = sysctl_op(&req_next[2], 1, op, CLONE_NEWIPC)))
>>>>
>>>> Can we do it in one call to sysctl_op?
>>>
>>> We will have to create proper req array for all possible combinations of
>>> has_xxx_next_id, for (1,0,1) that don't look good from my POV.
>>
>> Just declare the op-s array big enough and
>>
>> if (e->has_foo_next)
>> 	ops[i++] = { "kernel/foo_next", &e->foo_next, CTL_U32 };
>>
>> or smth like this.
> 
> We can do something like this only in declaration AFAIK, we will need to 
> set each structure value one by one or copy from req_next to some 
> secondary req.

That's OK, do whatever is appropriate :) Calling sysctl_op many times is
not good, this routine is quite ... slow internally, so less calls to it
is better.

-- Pavel



More information about the CRIU mailing list