[CRIU] Re: [PATCH 1/2] ipc: add new flag for preset shmem id on creation

Stanislav Kinsbursky skinsbursky at parallels.com
Fri Feb 3 11:54:01 EST 2012


03.02.2012 20:06, Cyrill Gorcunov пишет:
> On Thu, Feb 02, 2012 at 05:07:49PM +0400, Stanislav Kinsbursky wrote:
>> This patch is required for checkpoint/restore of IPC shared memory segments.
>>
> ...
>> diff --git a/ipc/util.c b/ipc/util.c
>> index 75261a3..9078560 100644
>> --- a/ipc/util.c
>> +++ b/ipc/util.c
>> @@ -264,7 +264,7 @@ int ipc_addid(struct ipc_ids* ids, struct kern_ipc_perm* new, int size)
>>   	rcu_read_lock();
>>   	spin_lock(&new->lock);
>>
>> -	err = idr_get_new(&ids->ipcs_idr, new,&id);
>> +	err = idr_get_new_above(&ids->ipcs_idr, new, ipcid_to_idx(new->id),&id);
>
> Stas, I somehow don't understand this change. Why idr_get_new_above is called
> now and does it mean we choose _not_ first free id but some new one greater
> than some minimum?
>
> 	Cyrill

Yes, exactly. This was done to have an ability to specify id for new segment to 
install on (have a look in the series at how does new->id is initialized, when 
sys_shmget() was called with IPC_PRESET flag).
Generally, we can't guarantee, that new allocated segment will have desired id 
(I forgot to check this in restore code - thanks for the catch). But we are 
going to migrate the whole IPC namespace and thus can assume, that new ID will 
be exactly the one we need.

-- 
Best regards,
Stanislav Kinsbursky



More information about the CRIU mailing list