From: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
To: Dave Hansen <dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Cc: containers
<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
Subject: Re: [RFC][PATCH 4/4] checkpoint/restart: simplify cr_scan_fds()
Date: Wed, 03 Dec 2008 04:48:18 -0500 [thread overview]
Message-ID: <493655E2.7040304@cs.columbia.edu> (raw)
In-Reply-To: <20081202185742.CB0FDECC@kernel>
(as discussed in the LKML thread) as far as I can see the existing code is
safe, and this code is not more correct (for restart) in terms of races with
changes to the file table ?
Dave Hansen wrote:
> I think having all the allocations in one place, plus the
> reduction in the number of lines speaks for itself. In
> any case, this is last in the series and can be dropped if
> you don't like it.
>
> ---
>
> linux-2.6.git-dave/checkpoint/ckpt_file.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff -puN checkpoint/ckpt_file.c~fix-cr_scan_fds-realloc checkpoint/ckpt_file.c
> --- linux-2.6.git/checkpoint/ckpt_file.c~fix-cr_scan_fds-realloc 2008-12-02 10:26:53.000000000 -0800
> +++ linux-2.6.git-dave/checkpoint/ckpt_file.c 2008-12-02 10:26:53.000000000 -0800
> @@ -38,6 +38,7 @@ int cr_scan_fds(struct files_struct *fil
> int i, n = 0;
> int tot = CR_DEFAULT_FDTABLE;
>
> +retry:
> fds = kmalloc(tot * sizeof(*fds), GFP_KERNEL);
> if (!fds)
> return -ENOMEM;
> @@ -55,18 +56,12 @@ int cr_scan_fds(struct files_struct *fil
> if (!fcheck_files(files, i))
> continue;
> if (n == tot) {
> - /*
> - * fcheck_files() is safe with drop/re-acquire
> - * of the lock, because it tests: fd < max_fds
> - */
> + /* we undershot the size of fds[] */
> spin_unlock(&files->file_lock);
> rcu_read_unlock();
> tot *= 2; /* won't overflow: kmalloc will fail */
> - fds = krealloc(fds, tot * sizeof(*fds), GFP_KERNEL);
> - if (!fds)
> - return -ENOMEM;
> - rcu_read_lock();
> - spin_lock(&files->file_lock);
> + kfree(fds);
> + goto retry;
> }
> fds[n++] = i;
> }
> _
>
next prev parent reply other threads:[~2008-12-03 9:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-02 18:57 [RFC][PATCH 1/4] checkpoint/restart: fix code to handle open symlinks Dave Hansen
2008-12-02 18:57 ` [RFC][PATCH 2/4] checkpoint/restart: fix cr_ctx_checkpoint() locking Dave Hansen
2008-12-02 22:22 ` Oren Laadan
[not found] ` <4935B52D.6050706-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-12-02 22:25 ` Dave Hansen
2008-12-02 18:57 ` [RFC][PATCH 3/4] checkpoint/restart: fix 'struct file' references Dave Hansen
2008-12-02 18:57 ` [RFC][PATCH 4/4] checkpoint/restart: simplify cr_scan_fds() Dave Hansen
2008-12-03 4:21 ` Serge E. Hallyn
2008-12-03 9:48 ` Oren Laadan [this message]
[not found] ` <493655E2.7040304-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2008-12-03 16:23 ` 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=493655E2.7040304@cs.columbia.edu \
--to=orenl-eqauephvms7envbuuze7ea@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
/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