From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@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: Tue, 2 Dec 2008 22:21:39 -0600 [thread overview]
Message-ID: <20081203042139.GA16762@us.ibm.com> (raw)
In-Reply-To: <20081202185742.CB0FDECC@kernel>
Quoting Dave Hansen (dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org):
>
> 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;
Heh, well I think you'll need to initialize n after the retry: label.
Otherwise, I can see the appeal of this...
> 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;
> }
> _
> _______________________________________________
> Containers mailing list
> Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> https://lists.linux-foundation.org/mailman/listinfo/containers
next prev parent reply other threads:[~2008-12-03 4:21 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 [this message]
2008-12-03 9:48 ` Oren Laadan
[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=20081203042139.GA16762@us.ibm.com \
--to=serue-r/jw6+rmf7hqt0dzr+alfa@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.