public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* unexpected sync delays in dpkg for small pre-allocated files on ext4
@ 2016-05-24 17:07 Gernot Hillier
  2016-05-24 23:13 ` Theodore Ts'o
  2016-05-26  2:20 ` Dave Chinner
  0 siblings, 2 replies; 12+ messages in thread
From: Gernot Hillier @ 2016-05-24 17:07 UTC (permalink / raw)
  To: linux-ext4

Hi there!

We experience strange delays with kernel 4.1.18 during dpkg package
installation on an ext4 filesystem after switching from Ubuntu 14.04 to
16.04. We can reproduce the issue with kernel 4.6. Installation of the
same package takes 2s with ext3 and 31s with ext4 on the same partition.

Hardware is an Intel-based server with Supermicro X8DTH board and
Seagate ST973451SS disks connected to an LSI SAS2008 controller (PCI
0x1000:0x0072, mpt2sas driver).

We could track this down to the introduction of fallocate() in recent
dpkg versions and derived the following synthetic test case. First
sync_file_range() call takes ~5ms, 2nd call ~15ms.

	fd = open("test1.txt", 0xc1);
	ret = fallocate(fd, 0, 0, 20);
	ret = write(fd, "hallo", 6);
	ret = sync_file_range(fd, 0, 0, 2);
	ret = close(fd);

	fd = open("test2.txt", 0xc1);
	ret = fallocate(fd, 0, 0, 20);
	ret = write(fd, "hallo", 6);
	ret = sync_file_range(fd, 0, 0, 2);
	ret = close(fd);

The delay is caused by sb_issue_zeroout() in ext4_ext_zeroout(), called
by ext4_ext_convert_to_initialized().

Ftrace function_graph snippet with important events (recorded with
kernel 4.6):

  7)          |      ext4_ext_map_blocks() {
[...]
  7)          |        /* ext4_ext_handle_unwritten_extents: ... */
  7)          |        /* ext4_ext_convert_to_initialized_enter: ... */
  7)          |        ext4_ext_zeroout() {
  7)          |          ext4_issue_zeroout() {

[... CPU switches to kworker, then to <idle> ...]
[... 14 ms later, we continue...]

  3)          |  /* irq_handler_entry: irq=25 name=mpt2sas0-msix0 */
  3)          |  /* irq_handler_exit: irq=25 ret=handled */
  7)          |  /* softirq_raise: vec=4 [action=BLOCK] */
  7)          |  /* softirq_entry: vec=4 [action=BLOCK] */
  7)          |  /* block_rq_complete: 8,16 W () 114969912 + 8 [0] */
[...]
  7) * 14 ms  |          } /* ext4_issue_zeroout */

ANY of the following changes reduce the sync_file_range() runtime to <<
1 ms:

 * do not use fallocate()
 * fallocate() for more than extent_max_zeroout_kb, e.g. 40 kB
 * echo 0 > /sys/fs/ext4/sdb2/extent_max_zeroout_kb
 * use ext3 instead of ext4
 * mount ext4 with -o dioread_nolock

To me, the problem looks comparable to
https://bugzilla.kernel.org/show_bug.cgi?id=56821 (even if we don't see
a full hang and there's no RAID involved for us), so a closer look on
the SCSI layer or driver might be the next step?

Any suggestions how to continue analysis are greatly appreciated!

-- 
Gernot Hillier, Siemens AG
Corporate Technology, Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: unexpected sync delays in dpkg for small pre-allocated files on ext4
@ 2016-05-30 19:04 Jun He
  0 siblings, 0 replies; 12+ messages in thread
From: Jun He @ 2016-05-30 19:04 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso

> On Tue, May 24, 2016 at 07:07:41PM +0200, Gernot Hillier wrote:
> > 
> > To me, the problem looks comparable to
> > https://bugzilla.kernel.org/show_bug.cgi?id=56821 (even if we don't see
> > a full hang and there's no RAID involved for us), so a closer look on
> > the SCSI layer or driver might be the next step?
> 
> What I would suggest is to create a small test case which compares the
> time it takes to allocate 1 megabyte of memory, zero it, and then
> write one megabytes of zeros using the write(2) system call.  Then try
> writing one megabytes of zero using the BLKZEROOUT ioctl.
> 
> I'm pretty sure you'll see same issue with BLKZEROOUT ioctl, but at
> this point, we'll be able to send bug reports to the SCSI and block
> layer developers with something that makes this very clear that it has
> nothing to do with ext4.
> 
> This way we can also do some differential diagnosis; given that I'm
> not seeing this complaint from most people, I suspect it will be a
> matter of adding some specific devices to a blacklist (so that even
> though the SCSI device claims to support WRITE SAME, we need to
> disable it because it has a really lousy implementation of the SCSI
> WRITE SAME command).
> 
> Cheers,
> 
> - Ted

I just want to add that I once experienced a similar problem: huge delay
with fallocate() and a SSD. It turns out block layer zeroouts extents by 
discarding them (blkdev_issue_zeroout()), and the Intel SSD is VERY slow
at discarding.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-07-13 13:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-24 17:07 unexpected sync delays in dpkg for small pre-allocated files on ext4 Gernot Hillier
2016-05-24 23:13 ` Theodore Ts'o
2016-05-30  8:27   ` Gernot Hillier
2016-05-31  0:21     ` Dave Chinner
2016-06-01  9:44       ` Gernot Hillier
2016-06-01 13:17         ` Gernot Hillier
2016-06-01 14:12           ` Theodore Ts'o
2016-06-02 16:23             ` Gernot Hillier
2016-07-13 13:57             ` Gernot Hillier
2016-05-26  2:20 ` Dave Chinner
2016-05-26  7:02   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2016-05-30 19:04 Jun He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox