From: Joern Engel <joern@logfs.org>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Jens Axboe <axboe@kernel.dk>, Borislav Petkov <bp@alien8.de>,
Takashi Iwai <tiwai@suse.de>, Joern Engel <joern@logfs.org>
Subject: [PATCH 06/14] bcon: add a release work struct
Date: Thu, 9 May 2013 16:43:04 -0400 [thread overview]
Message-ID: <1368132193-25817-9-git-send-email-joern@logfs.org> (raw)
In-Reply-To: <1368132193-25817-1-git-send-email-joern@logfs.org>
The final bcon_put() can be called from atomic context, by way of
bio_endio(). In that case we would sleep in invalidate_mapping_pages(),
with the usual unhappy results.
In nearly a year of production use, I have only seen a matching
backtrace once. There was a second known issue that could be reproduced
by "yes h > /proc/sysrq-trigger" and concurrently pulling and replugging
the blockconsole device. It took be somewhere around 30 pulls and sore
thumbs to reproduce and I never found the time to get to the bottom of
it. Quite likely the two issues are identical.
Signed-off-by: Joern Engel <joern@logfs.org>
---
drivers/block/blockconsole.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/block/blockconsole.c b/drivers/block/blockconsole.c
index 32f6c62..b4730f8 100644
--- a/drivers/block/blockconsole.c
+++ b/drivers/block/blockconsole.c
@@ -65,6 +65,7 @@ struct blockconsole {
struct block_device *bdev;
struct console console;
struct work_struct unregister_work;
+ struct work_struct release_work;
struct task_struct *writeback_thread;
struct notifier_block panic_block;
};
@@ -74,9 +75,10 @@ static void bcon_get(struct blockconsole *bc)
kref_get(&bc->kref);
}
-static void bcon_release(struct kref *kref)
+static void __bcon_release(struct work_struct *work)
{
- struct blockconsole *bc = container_of(kref, struct blockconsole, kref);
+ struct blockconsole *bc = container_of(work, struct blockconsole,
+ release_work);
__free_pages(bc->zero_page, 0);
__free_pages(bc->pages, 8);
@@ -85,6 +87,14 @@ static void bcon_release(struct kref *kref)
kfree(bc);
}
+static void bcon_release(struct kref *kref)
+{
+ struct blockconsole *bc = container_of(kref, struct blockconsole, kref);
+
+ /* bcon_release can be called from atomic context */
+ schedule_work(&bc->release_work);
+}
+
static void bcon_put(struct blockconsole *bc)
{
kref_put(&bc->kref, bcon_release);
@@ -512,6 +522,7 @@ static int bcon_create(const char *devname)
if (IS_ERR(bc->writeback_thread))
goto out2;
INIT_WORK(&bc->unregister_work, bcon_unregister);
+ INIT_WORK(&bc->release_work, __bcon_release);
register_console(&bc->console);
bc->panic_block.notifier_call = blockconsole_panic;
bc->panic_block.priority = INT_MAX;
--
1.7.10.4
next prev parent reply other threads:[~2013-05-09 22:13 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-09 20:42 [PATCH 00/14] Add blockconsole version 1.1 (try 3) Joern Engel
2013-05-09 20:42 ` [PATCH 01/14] do_mounts: constify name_to_dev_t parameter Joern Engel
2013-05-22 20:48 ` Andrew Morton
2013-05-22 19:58 ` Jörn Engel
2013-05-09 20:42 ` [PATCH] mpt2sas/mpt3sas: prevent double free on error path Joern Engel
2013-05-09 20:45 ` Jörn Engel
2013-05-22 20:48 ` Andrew Morton
2013-05-22 19:52 ` Jörn Engel
2013-05-09 20:42 ` [PATCH] mpt2sas: " Joern Engel
2013-05-09 20:43 ` [PATCH 02/14] add blockconsole version 1.1 Joern Engel
2013-05-22 20:48 ` Andrew Morton
2013-05-22 21:04 ` Jörn Engel
2013-05-22 22:43 ` Andrew Morton
2013-05-22 21:34 ` Jörn Engel
2013-05-09 20:43 ` [PATCH 03/14] printk: add CON_ALLDATA console flag Joern Engel
2013-05-09 20:43 ` [PATCH 04/14] netconsole: use CON_ALLDATA Joern Engel
2013-05-09 20:43 ` [PATCH 05/14] blockconsole: " Joern Engel
2013-05-09 20:43 ` Joern Engel [this message]
2013-05-22 20:48 ` [PATCH 06/14] bcon: add a release work struct Andrew Morton
2013-05-09 20:43 ` [PATCH 07/14] bcon: check for hdparm in bcon_tail Joern Engel
2013-05-22 20:48 ` Andrew Morton
2013-05-09 20:43 ` [PATCH 08/14] blockconsole: Allow to pass a device file path to bcon_tail Joern Engel
2013-05-09 20:43 ` [PATCH 09/14] bcon: remove version 1.0 support Joern Engel
2013-05-22 20:48 ` Andrew Morton
2013-05-22 19:51 ` Jörn Engel
2013-05-22 21:25 ` Andrew Morton
2013-05-22 20:00 ` Jörn Engel
2013-05-09 20:43 ` [PATCH 10/14] blockconsole: Fix undefined MAX_RT_PRIO Joern Engel
2013-05-09 20:43 ` [PATCH 11/14] blockconsole: Rename device_lock with bc_device_lock Joern Engel
2013-05-09 20:43 ` [PATCH 12/14] blockconsole: Mark a local work struct static Joern Engel
2013-05-09 20:43 ` [PATCH 13/14] bcon: Fix wrap-around behaviour Joern Engel
2013-05-09 20:43 ` [PATCH 14/14] netconsole: s/syslogd/cancd/ in documentation Joern Engel
2013-05-09 20:43 ` [PATCH 0/9] Add blockconsole version 1.1 (try 2) Joern Engel
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=1368132193-25817-9-git-send-email-joern@logfs.org \
--to=joern@logfs.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tiwai@suse.de \
/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
all inboxes | Powered by JetHome®