linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-next@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
	linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
	Hugh Dickins <hughd@google.com>,
	x86@kernel.org
Subject: [PATCH block/for-3.3/core] block: an exiting task should be allowed to create io_context
Date: Sat, 24 Dec 2011 17:02:38 -0800	[thread overview]
Message-ID: <20111225010238.GA6013@htj.dyndns.org> (raw)
In-Reply-To: <alpine.LSU.2.00.1112232058550.3225@eggly.anvils>

While fixing io_context creation / task exit race condition,
6e736be7f2 "block: make ioc get/put interface more conventional and
fix race on alloction" also prevented an exiting (%PF_EXITING) task
from creating its own io_context.  This is incorrect as exit path may
issue IOs, e.g. from exit_files(), and if those IOs are the first ones
issued by the task, io_context needs to be created to process the IOs.

Combined with the existing problem of io_context / io_cq creation
failure having the possibility of stalling IO, this problem results in
deterministic full IO lockup with certain workloads.

Fix it by allowing io_context creation regardless of %PF_EXITING for
%current.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Hugh Dickins <hughd@google.com>
---
Thanks a lot for the hint, Hugh.  My testing stuff (fio, dd and some
adhoc rawio testing programs) was issuing IOs before exiting, so I
didn't hit the problem and I suspect the reason why I didn't see the
boot failure Andrew was seeing was because of systemd - boot process
used to be dominated by lots of short-lived programs, many of which
touching/modifying files, and thus it triggered the first IO on exit
paths with Andrew's old userland.  With systemd, most of those are
gone, so...

Thanks.

 block/blk-ioc.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/block/blk-ioc.c b/block/blk-ioc.c
index ce9b35a..33fae7d 100644
--- a/block/blk-ioc.c
+++ b/block/blk-ioc.c
@@ -281,9 +281,16 @@ void create_io_context_slowpath(struct task_struct *task, gfp_t gfp_flags,
 	INIT_HLIST_HEAD(&ioc->icq_list);
 	INIT_WORK(&ioc->release_work, ioc_release_fn);
 
-	/* try to install, somebody might already have beaten us to it */
+	/*
+	 * Try to install.  ioc shouldn't be installed if someone else
+	 * already did or @task, which isn't %current, is exiting.  Note
+	 * that we need to allow ioc creation on exiting %current as exit
+	 * path may issue IOs from e.g. exit_files().  The exit path is
+	 * responsible for not issuing IO after exit_io_context().
+	 */
 	task_lock(task);
-	if (!task->io_context && !(task->flags & PF_EXITING))
+	if (!task->io_context &&
+	    (task == current || !(task->flags & PF_EXITING)))
 		task->io_context = ioc;
 	else
 		kmem_cache_free(iocontext_cachep, ioc);

  reply	other threads:[~2011-12-25  1:02 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20111221174733.9ba0861e762e8d96844b060b@canb.auug.org.au>
2011-12-21 23:15 ` linux-next: Tree for Dec 21 Andrew Morton
2011-12-22 23:08   ` Andrew Morton
2011-12-22 23:20     ` Tejun Heo
2011-12-22 23:24       ` Andrew Morton
2011-12-22 23:38         ` Tejun Heo
2011-12-22 23:44           ` Andrew Morton
2011-12-22 23:46             ` Tejun Heo
2011-12-23  0:42               ` Tejun Heo
2011-12-24  5:13                 ` Hugh Dickins
2011-12-25  1:02                   ` Tejun Heo [this message]
2011-12-25 13:29                     ` [PATCH block/for-3.3/core] block: an exiting task should be allowed to create io_context Jens Axboe
2011-12-27 22:07                       ` Andrew Morton
2011-12-28  8:33                     ` Hugh Dickins
2011-12-28 16:48                       ` Tejun Heo
2011-12-28 17:50                         ` Hugh Dickins
2011-12-28 17:55                           ` Tejun Heo
2011-12-28 21:19                             ` Tejun Heo
2012-01-03 17:35                               ` Tejun Heo
2012-01-03 17:59                                 ` Tejun Heo
2012-01-03 20:09                                   ` Tejun Heo
2012-01-03 20:20                                     ` Jens Axboe
2012-01-03 22:13                                       ` Tejun Heo
2012-01-03 22:35                                         ` Tejun Heo
2012-01-05  1:24                                           ` Tejun Heo
2012-01-05 18:36                                             ` Hugh Dickins
2012-01-05 18:38                                               ` Tejun Heo
2012-01-06  2:17                                                 ` [PATCH block:for-3.3/core] cfq: merged request shouldn't jump to a different cfqq Tejun Heo
2012-01-06  2:36                                                   ` Tejun Heo
2012-01-06  3:14                                                     ` Shaohua Li
2012-01-06  3:04                                                       ` Tejun Heo
2012-01-06  3:30                                                         ` Tejun Heo
2012-01-06  3:52                                                           ` [PATCH block:for-3.3/core] block: disable ELEVATOR_INSERT_SORT_MERGE Tejun Heo
2012-01-06  4:19                                                             ` Shaohua Li
2012-01-06  4:38                                                               ` Tejun Heo
2012-01-06  8:15                                                                 ` Shaohua Li
2012-01-06 15:34                                                                   ` Tejun Heo
2012-01-06  3:34                                                         ` [PATCH block:for-3.3/core] cfq: merged request shouldn't jump to a different cfqq Shaohua Li
2012-01-06  3:22                                                           ` Tejun Heo
2012-01-06  4:15                                                             ` Shaohua Li
2012-01-06  4:40                                                               ` Tejun Heo
2012-01-06  2:47                                                   ` Shaohua Li

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=20111225010238.GA6013@htj.dyndns.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=hughd@google.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=x86@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;
as well as URLs for NNTP newsgroup(s).