[CRIU] Re: [PATCH cr] [RFC] shmem: rework of dumping shared memory

Andrew Vagin avagin at parallels.com
Mon Mar 19 12:14:57 EDT 2012


> > +		fd = open_image(CR_FD_SHMEM_PAGES, O_WRONLY | O_CREAT, si->shmid);
> > +		if (fd < 0)
> > +			goto err;
> > +
> > +		for (pfn = 0; pfn < nrpages; pfn++) {
> > +			u64 offset = pfn * PAGE_SIZE;
> 
> offset = pfn << PAGE_SHIFT;

Now we have not PAGE_SHIFT, so I do that in a separate patch.

> >  int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
> >  {
> >  	LIST_HEAD(pstree_list);
> > @@ -1440,6 +1551,11 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
> >  		goto err;
> >  	close_cr_fdset(&cr_fdset);
> >  
> > +	nr_shmems = 0;
> > +	shmems = malloc(SHMEMS_SIZE);
> 
> xmalloc
> 
> > +	if (!shmems)
> > +		goto err;
> > +
> >  	list_for_each_entry(item, &pstree_list, list) {
> >  		cr_fdset = cr_dump_fdset_open(item->pid, CR_FD_DESC_NONE, NULL);
> >  		if (!cr_fdset)
> > @@ -1463,8 +1579,9 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
> >  		if (opts->leader_only)
> >  			break;
> >  	}
> > -	ret = 0;
> >  
> > +	ret = cr_dump_shmem(pid);
> > +	free(shmems);
> 
> I'd move the free (well, xfree) into cr_dump_shmem.
I don't like this, because in my code you can fast find place where
it is freed.



More information about the CRIU mailing list