[CRIU] [RFC] Check page size at run time
Pavel Emelyanov
xemul at parallels.com
Mon Oct 5 05:33:51 PDT 2015
On 10/05/2015 02:57 PM, Christopher Covington wrote:
> On 10/05/2015 06:22 AM, Pavel Emelyanov wrote:
>> On 10/03/2015 03:47 PM, Christopher Covington wrote:
>>> CRIU can be built to support different PAGE_SIZE values. Move the
>>> page size check from build time to run time.
>>>
>>> Signed-off-by: Christopher Covington <cov at codeaurora.org>
>>> ---
>>> crtools.c | 2 --
>>> include/image.h | 5 -----
>>> kerndat.c | 13 +++++++++++++
>>> 3 files changed, 13 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/crtools.c b/crtools.c
>>> index ea8b889..52d148b 100644
>>> --- a/crtools.c
>>> +++ b/crtools.c
>>> @@ -255,8 +255,6 @@ int main(int argc, char *argv[], char *envp[])
>>> { },
>>> };
>>>
>>> - BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
>>> -
>>> cr_pb_init();
>>> if (restrict_uid(getuid(), getgid()))
>>> return 1;
>>> diff --git a/include/image.h b/include/image.h
>>> index 305febf..a1e5544 100644
>>> --- a/include/image.h
>>> +++ b/include/image.h
>>> @@ -11,11 +11,6 @@
>>> #include "bfd.h"
>>> #include "bug.h"
>>>
>>> -#ifdef _ARCH_PPC64
>>> -#define PAGE_IMAGE_SIZE 65536
>>> -#else
>>> -#define PAGE_IMAGE_SIZE 4096
>>> -#endif /* _ARCH_PPC64 */
>>> #define PAGE_RSS 1
>>> #define PAGE_ANON 2
>>>
>>> diff --git a/kerndat.c b/kerndat.c
>>> index e57c6fd..4e10e63 100644
>>> --- a/kerndat.c
>>> +++ b/kerndat.c
>>> @@ -296,6 +296,17 @@ static int get_task_size(void)
>>> return 0;
>>> }
>>>
>>> +static int check_page_size(void)
>>> +{
>>> + if (PAGE_SIZE != page_size()) {
>>> + pr_err("Page size mismatch.\n");
>>> + pr_err("Built for: %ld running with: %ld.\n", (unsigned long)PAGE_SIZE,
>>> + page_size());
>>> + return -1;
>>> + }
>>> + return 0;
>>> +}
>>> +
>>> int kerndat_fdinfo_has_lock()
>>> {
>>> int fd, pfd = -1, exit_code = -1, len;
>>> @@ -348,6 +359,8 @@ int kerndat_init(void)
>>
>> The kerndat_init() is only called on dump, restore calls kerndat_init_rst(). Do
>> we want to check page-size on restore as well?
>
> Yes.
OK. Would you update the patch, please?
> Also, these checks are whether the CRIU binary was built to support the page
> size of the current system. Ideally we'll eventually have a single CRIU binary
> that can support all page sizes.
>
> Something that I'm not yet checking is whether the page size of the dumped
> process matches that of the current system. I think I need to add a field to
> the image files for this. If you have any suggestions about where specifically
> to put it (I was thinking maybe near the AArch64 CPU fields), please let me know
This thing seem to fit into cpuinf dump/check images (cpuinfo.proto).
-- Pavel
More information about the CRIU
mailing list