From: Oren Laadan <orenl@cs.columbia.edu>
To: Mike Waychison <mikew@google.com>
Cc: jeremy@goop.org, arnd@arndb.de, linux-api@vger.kernel.org,
containers@lists.linux-foundation.org,
linux-kernel@vger.kernel.org,
Dave Hansen <dave@linux.vnet.ibm.com>,
linux-mm@kvack.org, Linux Torvalds <torvalds@osdl.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [RFC v11][PATCH 04/13] x86 support for checkpoint/restart
Date: Wed, 17 Dec 2008 10:23:36 -0500 [thread overview]
Message-ID: <49491978.20609@cs.columbia.edu> (raw)
In-Reply-To: <494861CA.8000403@google.com>
Mike Waychison wrote:
> Oren Laadan wrote:
>> Add logic to save and restore architecture specific state, including
>> thread-specific state, CPU registers and FPU state.
>>
>> In addition, architecture capabilities are saved in an architecure
>> specific extension of the header (cr_hdr_head_arch); Currently this
>> includes only FPU capabilities.
>>
>> Currently only x86-32 is supported. Compiling on x86-64 will trigger
>> an explicit error.
>>
[...]
>> +
>> + hh->gdt_entry_tls_entries = GDT_ENTRY_TLS_ENTRIES;
>> + hh->sizeof_tls_array = sizeof(thread->tls_array);
>> + hh->ntls = ntls;
>> +
>> + ret = cr_write_obj(ctx, &h, hh);
>> + cr_hbuf_put(ctx, sizeof(*hh));
>> + if (ret < 0)
>> + return ret;
>> +
>> + cr_debug("ntls %d\n", ntls);
>> + if (ntls == 0)
>> + return 0;
>> +
>> + /* for simplicity dump the entire array, cherry-pick upon restart */
>> + ret = cr_kwrite(ctx, thread->tls_array, sizeof(thread->tls_array));
>
> Again, the the TLS descriptors in the GDT should be called out an not
> tied to the in-kernel representation.
True. I'll add a 'FIXME' comment.
However, I'm yet to see a case where this breaks among x86_32, and I'm no
expert in that area to tell whether it could. (Moving from x86_32 to x86_64
is another story, and will require some compatibility layer anyway).
>
>> +
>> + /* IGNORE RESTART BLOCKS FOR NOW ... */
[...]
>> +static int cr_write_cpu_fpu(struct cr_ctx *ctx, struct task_struct *t)
>> +{
>> + void *xstate_buf = cr_hbuf_get(ctx, xstate_size);
>> +
>> + /* i387 + MMU + SSE logic */
>> + preempt_disable(); /* needed it (t == current) */
>> +
>> + /*
>> + * normally, no need to unlazy_fpu(), since TS_USEDFPU flag
>> + * have been cleared when task was context-switched out...
>> + * except if we are in process context, in which case we do
>> + */
>> + if (t == current && (task_thread_info(t)->status & TS_USEDFPU))
>> + unlazy_fpu(current);
>> +
>> + memcpy(xstate_buf, t->thread.xstate, xstate_size);
>
> This is probably better off being very deliberate about what registers
> we are dumping from a traceability and compatibility point of view?
Same here.
>
>> + preempt_enable(); /* needed it (t == current) */
>> +
>> + return cr_kwrite(ctx, xstate_buf, xstate_size);
>
> Missed cr_huf_put()
Ooops ... will fix.
>
>> +}
>> +
>> +#endif /* CONFIG_X86_64 */
[...]
>> + /*
>> + * restore TLS by hand: why convert to struct user_desc if
>> + * sys_set_thread_entry() will convert it back ?
>> + */
>> +
>> + size = sizeof(*desc) * GDT_ENTRY_TLS_ENTRIES;
>> + desc = kmalloc(size, GFP_KERNEL);
>> + if (!desc)
>
> cr_hbuf_put() here.
Will fix.
>
>> + return -ENOMEM;
>> +
>> + ret = cr_kread(ctx, desc, size);
>> + if (ret >= 0) {
>
> if (ret == 0)
Right.
>
>> + /*
>> + * FIX: add sanity checks (eg. that values makes
>> + * sense, that we don't overwrite old values, etc
>> + */
>> + cpu = get_cpu();
>> + memcpy(thread->tls_array, desc, size);
>> + load_TLS(thread, cpu);
>> + put_cpu();
>> + }
>> + kfree(desc);
>> + }
>> +
>> + ret = 0;
>> + out:
>> + cr_hbuf_put(ctx, sizeof(*hh));
>> + return ret;
>> +}
[...]
Thanks for the review !
Oren.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2008-12-17 15:22 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-05 17:31 [RFC v11][PATCH 00/13] Kernel based checkpoint/restart Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 01/13] Create syscalls: sys_checkpoint, sys_restart Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 02/13] Checkpoint/restart: initial documentation Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 03/13] General infrastructure for checkpoint restart Oren Laadan
2008-12-06 7:26 ` Joe Perches
2008-12-16 19:04 ` Mike Waychison
2008-12-16 19:28 ` Linus Torvalds
2008-12-16 21:54 ` Mike Waychison
2008-12-16 22:14 ` Dave Hansen
2008-12-16 22:43 ` Mike Waychison
2008-12-17 0:13 ` Dave Hansen
2008-12-16 23:42 ` Oren Laadan
2008-12-17 0:42 ` Mike Waychison
2008-12-17 2:08 ` Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 04/13] x86 support for checkpoint/restart Oren Laadan
2008-12-17 2:19 ` Mike Waychison
2008-12-17 15:23 ` Oren Laadan [this message]
2008-12-05 17:31 ` [RFC v11][PATCH 05/13] Dump memory address space Oren Laadan
2008-12-18 2:26 ` Mike Waychison
2008-12-18 11:10 ` Oren Laadan
2008-12-18 15:05 ` Dave Hansen
2008-12-18 15:54 ` Dave Hansen
2008-12-18 20:00 ` Oren Laadan
2008-12-18 18:15 ` Mike Waychison
2008-12-18 18:21 ` Dave Hansen
2008-12-18 20:11 ` Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 06/13] Restore " Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 07/13] Infrastructure for shared objects Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 08/13] Dump open file descriptors Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 09/13] Restore open file descriprtors Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 10/13] External checkpoint of a task other than ourself Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 11/13] Track in-kernel when we expect checkpoint/restart to work Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 12/13] Checkpoint multiple processes Oren Laadan
2008-12-05 17:31 ` [RFC v11][PATCH 13/13] Restart " Oren Laadan
2008-12-06 0:19 ` [RFC v11][PATCH 00/13] Kernel based checkpoint/restart Serge E. Hallyn
2008-12-09 19:42 ` Serge E. Hallyn
2008-12-16 18:43 ` Dave Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49491978.20609@cs.columbia.edu \
--to=orenl@cs.columbia.edu \
--cc=arnd@arndb.de \
--cc=containers@lists.linux-foundation.org \
--cc=dave@linux.vnet.ibm.com \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mikew@google.com \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=torvalds@osdl.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox