lkml.org 
[lkml]   [2008]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC v4][PATCH 2/9] General infrastructure for checkpoint restart


MinChan Kim wrote:
> On Tue, Sep 9, 2008 at 4:42 PM, Oren Laadan <orenl@cs.columbia.edu> wrote:

[...]

>> +struct cr_ctx *cr_ctx_alloc(pid_t pid, int fd, unsigned long flags)
>> +{
>> + struct cr_ctx *ctx;
>> +
>> + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
>> + if (!ctx)
>> + return ERR_PTR(-ENOMEM);
>> +
>> + ctx->file = fget(fd);
>> + if (!ctx->file) {
>> + cr_ctx_free(ctx);
>> + return ERR_PTR(-EBADF);
>> + }
>> + get_file(ctx->file);
>
> Why do you need get_file?
> You already called fget.
> Am I missing something ?

This was meant for when we will restart multiple processes, each would
have access to the checkpoint-context, such that the checkpoint-context
may outlives the task that created it and initiated the restart. Thus
the file-pointer will need to stay around longer than that task.

Of course, restart of multiple processes _can_ be coded such that this
first task will always terminate last - either after restart completes
successfully, or after all the other tasks aborted and won't use the
checkpoint-context anymore.

Because that code is not part of the this patch-set, I considered it
safer to grab a reference of the file pointer, making it less likely
that we forget about it later.

>
>> + ctx->hbuf = (void *) __get_free_pages(GFP_KERNEL, CR_HBUF_ORDER);
>> + if (!ctx->hbuf) {
>> + cr_ctx_free(ctx);
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + ctx->pid = pid;
>> + ctx->flags = flags;
>> +
>> + ctx->crid = atomic_inc_return(&cr_ctx_count);
>> +
>> + return ctx;
>> +}

Oren.



\
 
 \ /
  Last update: 2008-09-10 20:43    [W:1.244 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site