linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: Chris Mason <clm@fb.com>, Liu Bo <bo.li.liu@oracle.com>,
	linux-btrfs <linux-btrfs@vger.kernel.org>
Cc: miaox@cn.fujitsu.com, "Martin Steigerwald" <Martin@lichtvoll.de>,
	"Marc MERLIN" <marc@merlins.org>, Torbjørn <lists@skagestad.org>
Subject: Re: [PATCH] Btrfs: fix task hang under heavy compressed write
Date: Wed, 13 Aug 2014 08:53:37 +0800	[thread overview]
Message-ID: <53EAB711.5010602@cn.fujitsu.com> (raw)
In-Reply-To: <53EA2B71.6060701@fb.com>


-------- Original Message --------
Subject: Re: [PATCH] Btrfs: fix task hang under heavy compressed write
From: Chris Mason <clm@fb.com>
To: Liu Bo <bo.li.liu@oracle.com>, linux-btrfs <linux-btrfs@vger.kernel.org>
Date: 2014年08月12日 22:57
>
> On 08/12/2014 03:44 AM, Liu Bo wrote:
>> This has been reported and discussed for a long time, and this hang occurs in
>> both 3.15 and 3.16.
>>
>> Btrfs now migrates to use kernel workqueue, but it introduces this hang problem.
>>
>> Btrfs has a kind of work queued as an ordered way, which means that its
>> ordered_func() must be processed in the way of FIFO, so it usually looks like --
> This definitely explains some problems, and I overlooked the part where
> all of our workers use the same normal_work()
Oh, all my faults, it didn't occur to me that it is possible that other 
process can alloc the same address of memory :(
And same normal_work() makes things much worse.
>
> But I think it's actually goes beyond just the ordered work queues.
>
> Process A:
> 	btrfs_bio_wq_end_io() -> kmalloc a end_io_wq struct at address P
> 	submit bio
> 	end bio
> 	btrfs_queue_work(endio_write_workers)
> 	worker thread jumps in
> 	end_workqueue_fn()
> 		-> kfree(end_io_wq)
> 		^^^^^ right here end_io_wq can be reused,
> 		but the worker thread is still processing this work item
>
> Process B:
> 	btrfs_bio_wq_end() -> kmalloc an end_io_wq struct, reuse P
> 	submit bio
> 	end bio ... sometimes this is really fast
> 	btrfs_queue_work(endio_workers) // lets do a read
> 		->process_one_work()
> 		    -> find_worker_executing_work()
> 		    ^^^^^ now we get in trouble.  our struct P is still
> 		    active and so find_worker_executing_work() is going
> 		    to queue up this read completion on the end of the
> 		    scheduled list for this worker in the generic code.
>
> 		    The end result is we can have read IO completions
> 		    queued up behind write IO completions.
>
> This example uses the bio end io code, but we probably have others.  The
> real solution is to have each btrfs workqueue provide its own worker
> function, or each caller to btrfs_queue_work to send a unique worker
> function down to the generic code.
That's true, personally I prefer the first one since it affects less 
callers, but it seems to need more macro
hacks or somthing like it to generate different functions but they all 
do the samething...

Thanks,
Qu
>
> Thanks Liu, great job finding this.
>
> -chris
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2014-08-13  0:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12  7:44 [PATCH] Btrfs: fix task hang under heavy compressed write Liu Bo
2014-08-12 14:35 ` [PATCH v2] " Liu Bo
2014-08-12 14:57 ` [PATCH] " Chris Mason
2014-08-13  0:53   ` Qu Wenruo [this message]
2014-08-13 11:54 ` Martin Steigerwald
2014-08-13 13:27   ` Rich Freeman
2014-08-13 15:20   ` Liu Bo
2014-08-14  9:27     ` Martin Steigerwald
2014-08-15 17:51       ` Martin Steigerwald
2014-08-15 15:36 ` [PATCH v3] " Liu Bo
2014-08-15 16:05   ` Chris Mason
2014-08-16  7:28   ` Miao Xie
2014-08-18  7:32     ` Liu Bo
2014-08-25 14:58   ` Chris Mason
2014-08-25 15:19     ` Liu Bo
2014-08-26 10:20     ` Martin Steigerwald
2014-08-26 10:38       ` Liu Bo
2014-08-26 12:04         ` Martin Steigerwald
2014-08-26 13:02       ` Chris Mason
2014-08-26 13:20         ` Martin Steigerwald
2014-08-31 11:48           ` Martin Steigerwald
2014-08-31 15:40             ` Liu Bo

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=53EAB711.5010602@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=Martin@lichtvoll.de \
    --cc=bo.li.liu@oracle.com \
    --cc=clm@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=lists@skagestad.org \
    --cc=marc@merlins.org \
    --cc=miaox@cn.fujitsu.com \
    /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).