From: Jens Axboe <jens.axboe@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, knikanth@novell.com
Subject: Re: [PATCH 1/6] ioprio: move io priority from task_struct to io_context
Date: Thu, 24 Jan 2008 08:30:13 +0100 [thread overview]
Message-ID: <20080124073012.GM6258@kernel.dk> (raw)
In-Reply-To: <20080123140747.39bb13d8.akpm@linux-foundation.org>
On Wed, Jan 23 2008, Andrew Morton wrote:
> > On Tue, 22 Jan 2008 10:49:16 +0100 Jens Axboe <jens.axboe@oracle.com> wrote:
> > This is where it belongs and then it doesn't take up space for a
> > process that doesn't do IO.
> >
> > ...
> >
> > struct io_context *get_io_context(gfp_t gfp_flags, int node)
> > {
> > - struct io_context *ret;
> > - ret = current_io_context(gfp_flags, node);
> > - if (likely(ret))
> > - atomic_inc(&ret->refcount);
> > + struct io_context *ret = NULL;
> > +
> > + do {
> > + ret = current_io_context(gfp_flags, node);
> > + if (unlikely(!ret))
> > + break;
> > + } while (!atomic_inc_not_zero(&ret->refcount));
>
> Looks weird. Could do with a comment. Or unweirding ;)
>
> What's going on here?
In the unlikely event that we find a task that is on its way to exiting.
This hunk should actually be a part of the cfq lockless stuff...
> > return ret;
> > }
> > EXPORT_SYMBOL(get_io_context);
> > diff --git a/fs/ioprio.c b/fs/ioprio.c
> > index e4e01bc..a760040 100644
> > --- a/fs/ioprio.c
> > +++ b/fs/ioprio.c
> > @@ -41,18 +41,29 @@ static int set_task_ioprio(struct task_struct *task, int ioprio)
> > return err;
> >
> > task_lock(task);
> > + do {
> > + ioc = task->io_context;
> > + /* see wmb() in current_io_context() */
> > + smp_read_barrier_depends();
> > + if (ioc)
> > + break;
> >
> > - task->ioprio = ioprio;
> > -
> > - ioc = task->io_context;
> > - /* see wmb() in current_io_context() */
> > - smp_read_barrier_depends();
> > + ioc = alloc_io_context(GFP_ATOMIC, -1);
> > + if (!ioc) {
> > + err = -ENOMEM;
> > + break;
> > + }
> > + task->io_context = ioc;
> > + ioc->task = task;
> > + } while (1);
>
> argh. Can't sit there in a loop retrying GFP_ATOMIC!
It's not, read the loop again!
> > - if (ioc)
> > + if (!err) {
> > + ioc->ioprio = ioprio;
> > ioc->ioprio_changed = 1;
> > + }
> >
> > task_unlock(task);
> > - return 0;
> > + return err;
> > }
> >
> > asmlinkage long sys_ioprio_set(int which, int who, int ioprio)
> >
> > ...
> >
> > void put_io_context(struct io_context *ioc);
> > void exit_io_context(void);
> > struct io_context *get_io_context(gfp_t gfp_flags, int node);
> > +struct io_context *alloc_io_context(gfp_t, int);
> > void copy_io_context(struct io_context **pdst, struct io_context **psrc);
> > void swap_io_context(struct io_context **ioc1, struct io_context **ioc2);
>
> The rest of the declarations around here nicely name their args.
A clear sign I didn't put those declarations there, but the inconsistent
style is surely not a good thing. Will fix that up.
> > +static int copy_io(struct task_struct *tsk)
> > +{
> > + struct io_context *ioc = current->io_context;
> > +
> > + if (!ioc)
> > + return 0;
> > +
> > + if (ioprio_valid(ioc->ioprio)) {
> > + tsk->io_context = alloc_io_context(GFP_KERNEL, -1);
> > + if (unlikely(!tsk->io_context))
> > + return -ENOMEM;
> > +
> > + tsk->io_context->task = tsk;
> > + tsk->io_context->ioprio = ioc->ioprio;
> > + }
> > +
> > + return 0;
> > +}
>
> Should this depend on CONFIG_BLOCK?
Good questions, checks... Looks like it would break, I'll do a
!CONFIG_BLOCK fixup round.
--
Jens Axboe
next prev parent reply other threads:[~2008-01-24 7:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-22 9:49 [PATCH 0/6] IO context sharing Jens Axboe
2008-01-22 9:49 ` [PATCH 1/6] ioprio: move io priority from task_struct to io_context Jens Axboe
2008-01-23 22:07 ` Andrew Morton
2008-01-24 7:30 ` Jens Axboe [this message]
2008-01-22 9:49 ` [PATCH 2/6] io context sharing: preliminary support Jens Axboe
2008-01-23 22:08 ` Andrew Morton
2008-01-24 7:36 ` Jens Axboe
2008-01-22 9:49 ` [PATCH 3/6] io_context sharing - cfq changes Jens Axboe
2008-01-22 9:49 ` [PATCH 4/6] block: cfq: make the io contect sharing lockless Jens Axboe
2008-01-23 22:08 ` Andrew Morton
2008-01-24 7:36 ` Jens Axboe
2008-01-24 16:42 ` Paul E. McKenney
2008-01-22 9:49 ` [PATCH 5/6] io_context sharing - anticipatory changes Jens Axboe
2008-01-22 9:49 ` [PATCH 6/6] kernel: add CLONE_IO to specifically request sharing of IO contexts Jens Axboe
2008-01-22 14:49 ` [PATCH 0/6] IO context sharing Peter Zijlstra
2008-01-22 18:21 ` Jens Axboe
2008-01-23 3:50 ` David Chinner
2008-01-23 8:44 ` Andi Kleen
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=20080124073012.GM6258@kernel.dk \
--to=jens.axboe@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=knikanth@novell.com \
--cc=linux-kernel@vger.kernel.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