[CRIU] [PATCH 4/5] kdat: Cache kdat object into /run/criu.kdat (v2)
Pavel Emelyanov
xemul at virtuozzo.com
Thu Apr 27 06:53:50 PDT 2017
On 04/27/2017 09:11 AM, Adrian Reber wrote:
> On Thu, Apr 27, 2017 at 08:37:09AM +0300, Mike Rapoport wrote:
>> On Wed, Apr 26, 2017 at 04:37:34PM +0300, Pavel Emelyanov wrote:
>>> Doing kerndat checks on every criu start is way too slow. We
>>> need some way to speed this checks up on a particular box.
>>>
>>> As suggested by Andre, Dima and Mike let's try to keep the
>>> collected kdat bits into some tmpfs file. Keeping it on
>>> tmpfs would invaludate this cache on every machine reboot.
>>>
>>> There have been many suggestions how to generate this file,
>>> my proposal is to create it once the kdat object is filled
>>> by criu, w/o any explicit command. Optionally we can add
>>> 'criu kdat --save|--drop' actions to manage this file.
>>>
>>> v2:
>>> * don't ignore return code of write() (some glibcs complain)
>>> * unlink tmp file in case rename failed
>>>
>>> Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
>>> ---
>>> criu/include/kerndat.h | 6 ++++
>>> criu/include/magic.h | 7 +++++
>>> criu/kerndat.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++-
>>> 3 files changed, 97 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/criu/include/kerndat.h b/criu/include/kerndat.h
>>> index 6b621c6..b1722eb 100644
>>> --- a/criu/include/kerndat.h
>>> +++ b/criu/include/kerndat.h
>>> @@ -29,6 +29,12 @@ enum loginuid_func {
>>> };
>>>
>>> struct kerndat_s {
>>> + /*
>>> + * XXX: This structure is written AS IS into a tmpfs file,
>>> + * so any changes in it should result in changed KDAT_MAGIC
>>> + * value to avoid loading of bad kdat bits.
>>> + */
>>> + u32 magic;
>>> dev_t shmem_dev;
>>> int last_cap;
>>> u64 zero_page_pfn;
>>> diff --git a/criu/include/magic.h b/criu/include/magic.h
>>> index 059d005..2297930 100644
>>> --- a/criu/include/magic.h
>>> +++ b/criu/include/magic.h
>>> @@ -116,4 +116,11 @@
>>> #define STATS_MAGIC 0x57093306 /* Ostashkov */
>>> #define IRMAP_CACHE_MAGIC 0x57004059 /* Ivanovo */
>>>
>>> +/*
>>> + * Magic for kerndat_s structure. When changing, keep the
>>> + * old magics to avoid magic re-use.
>>> + */
>>> +
>>> +#define KDAT_MAGIC_1 0x57023458 /* Torzhok */
>>> +
>>> #endif /* __CR_MAGIC_H__ */
>>> diff --git a/criu/kerndat.c b/criu/kerndat.c
>>> index 87a7b62..3aca1e4 100644
>>> --- a/criu/kerndat.c
>>> +++ b/criu/kerndat.c
>>> @@ -650,10 +650,93 @@ close:
>>> bclose(&f);
>>> return ret;
>>> }
>>> +
>>> +#define KERNDAT_CACHE_FILE "/run/criu.kdat"
>>> +#define KERNDAT_CACHE_FILE_TMP "/run/.criu.kdat"
>>
>> What about running criu as non-root user?
It, well, doesn't quite work by itself :) But yes, good catch, need to
address that too somehow.
> Could the location be Makefile dependent? For Fedora I would rather put
> the file in /run/criu/criu.kdat
Will do, thanks.
> and create the directory via tmpfiles.d?
I don't know what the tmpfiles.d is :) Would you explain, please?
-- Pavel
More information about the CRIU
mailing list