All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Andreas Dilger <adilger.kernel@dilger.ca>,
	linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 19/31] ext4: Convert ext4_journalled_zero_new_buffers() to use a folio
Date: Fri, 24 Mar 2023 04:15:17 +0000	[thread overview]
Message-ID: <ZB0j1WZOI/ZvdtEo@casper.infradead.org> (raw)
In-Reply-To: <20230314224619.GF860405@mit.edu>

On Tue, Mar 14, 2023 at 06:46:19PM -0400, Theodore Ts'o wrote:
> On Thu, Jan 26, 2023 at 08:24:03PM +0000, Matthew Wilcox (Oracle) wrote:
> > Remove a call to compound_head().
> 
> Same question as with other commits, plus one more; why is it notable
> that calls to compound_head() are being reduced.  I've looked at the
> implementation, and it doesn't look all _that_ heavyweight....

It gets a lot more heavyweight when you turn on
CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP, which more and more distro
kernels are doing, because it's such a win for VM host kernels.
eg SuSE do it here:
https://github.com/SUSE/kernel-source/blob/master/config/x86_64/default
and UEK does it here:
https://github.com/oracle/linux-uek/blob/uek7/ga/uek-rpm/ol9/config-x86_64
Debian also has it enabled.

It didn't use to be so expensive, but now it's something like 50-60
bytes of text per invocation on x86 [1].  And the compiler doesn't get
to remember the result of calling compound_head() because we might have
changed page->compound_head between invocations.  It doesn't even know
that compound_head() is idempotent.

Anyway, each of these patches can be justified as "This patch shrinks
the kernel by 0.0001%".  Of course my real motivation for doing this
is to reduce the number of callers of the page APIs so we can start to
remove them and lessen the cognitive complexity of having both page &
folio APIs that parallel each other.  And I would like ext4 to support
large folios sometime soon, and it's a step towards that goal too.
But that's a lot to write out in each changelog.

[1] For example, the disassembly of unlock_page() with the UEK
config:

  c0:   f3 0f 1e fa             endbr64
  c4:   e8 00 00 00 00          call   c9 <unlock_page+0x9>
                        c5: R_X86_64_PLT32      __fentry__-0x4
  c9:   55                      push   %rbp
  ca:   48 8b 47 08             mov    0x8(%rdi),%rax
  ce:   48 89 e5                mov    %rsp,%rbp
  d1:   a8 01                   test   $0x1,%al
  d3:   75 2f                   jne    104 <unlock_page+0x44>
  d5:   eb 0b                   jmp    e2 <unlock_page+0x22>
  d7:   e8 00 00 00 00          call   dc <unlock_page+0x1c>
                        d8: R_X86_64_PLT32      folio_unlock-0x4
  dc:   5d                      pop    %rbp
  dd:   e9 00 00 00 00          jmp    e2 <unlock_page+0x22>
                        de: R_X86_64_PLT32      __x86_return_thunk-0x4
  e2:   f7 c7 ff 0f 00 00       test   $0xfff,%edi
  e8:   75 ed                   jne    d7 <unlock_page+0x17>
  ea:   48 8b 07                mov    (%rdi),%rax
  ed:   a9 00 00 01 00          test   $0x10000,%eax
  f2:   74 e3                   je     d7 <unlock_page+0x17>
  f4:   48 8b 47 48             mov    0x48(%rdi),%rax
  f8:   48 8d 50 ff             lea    -0x1(%rax),%rdx
  fc:   a8 01                   test   $0x1,%al
  fe:   48 0f 45 fa             cmovne %rdx,%rdi
 102:   eb d3                   jmp    d7 <unlock_page+0x17>
 104:   48 8d 78 ff             lea    -0x1(%rax),%rdi
 108:   e8 00 00 00 00          call   10d <unlock_page+0x4d>
                        109: R_X86_64_PLT32     folio_unlock-0x4
 10d:   5d                      pop    %rbp
 10e:   e9 00 00 00 00          jmp    113 <unlock_page+0x53>
                        10f: R_X86_64_PLT32     __x86_return_thunk-0x4
 113:   66 66 2e 0f 1f 84 00    data16 cs nopw 0x0(%rax,%rax,1)
 11a:   00 00 00 00
 11e:   66 90                   xchg   %ax,%ax

Everything between 0xd3 and 0x104 is "maybe it's a fake head".  That's 41
bytes as a minimum per callsite, and typically it's much more becase we
also need the test for PageTail and the lea for the actual compound_head.

  reply	other threads:[~2023-03-24  4:15 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26 20:23 [PATCH 00/31] Convert most of ext4 to folios Matthew Wilcox (Oracle)
2023-01-26 20:23 ` [PATCH 01/31] fs: Add FGP_WRITEBEGIN Matthew Wilcox (Oracle)
2023-03-05  8:53   ` Ritesh Harjani
2023-03-14 22:00   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 02/31] fscrypt: Add some folio helper functions Matthew Wilcox (Oracle)
2023-01-27  3:02   ` Eric Biggers
2023-01-27 16:13     ` Matthew Wilcox
2023-01-27 16:21       ` Eric Biggers
2023-01-27 16:37         ` Matthew Wilcox
2023-03-14 22:05       ` Theodore Ts'o
2023-03-14 23:12         ` Eric Biggers
2023-03-15  2:53           ` Theodore Ts'o
2023-03-05  9:06   ` Ritesh Harjani
2023-01-26 20:23 ` [PATCH 03/31] ext4: Convert ext4_bio_write_page() to use a folio Matthew Wilcox (Oracle)
2023-01-28 16:53   ` kernel test robot
2023-01-28 19:07   ` kernel test robot
2023-03-05 11:18   ` Ritesh Harjani
2023-03-14 22:07   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 04/31] ext4: Convert ext4_finish_bio() to use folios Matthew Wilcox (Oracle)
2023-03-06  9:10   ` Ritesh Harjani
2023-03-23  3:26     ` Matthew Wilcox
2023-03-23 14:51       ` Darrick J. Wong
2023-03-23 15:30         ` Matthew Wilcox
2023-03-27  0:58           ` Christoph Hellwig
2023-03-27  0:57         ` Christoph Hellwig
2023-03-14 22:08   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 05/31] ext4: Convert ext4_writepage() to use a folio Matthew Wilcox (Oracle)
2023-03-06 18:45   ` Ritesh Harjani
2023-03-14 22:26     ` Theodore Ts'o
2023-03-23  3:29       ` Matthew Wilcox
2023-01-26 20:23 ` [PATCH 06/31] ext4: Turn mpage_process_page() into mpage_process_folio() Matthew Wilcox (Oracle)
2023-03-14 22:27   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 07/31] ext4: Convert mpage_submit_page() to mpage_submit_folio() Matthew Wilcox (Oracle)
2023-03-14 22:28   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 08/31] ext4: Convert ext4_bio_write_page() to ext4_bio_write_folio() Matthew Wilcox (Oracle)
2023-03-14 22:31   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 09/31] ext4: Convert ext4_readpage_inline() to take a folio Matthew Wilcox (Oracle)
2023-03-14 22:31   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 10/31] ext4: Convert ext4_convert_inline_data_to_extent() to use " Matthew Wilcox (Oracle)
2023-03-14 22:36   ` Theodore Ts'o
2023-03-23 17:14     ` Matthew Wilcox
2023-01-26 20:23 ` [PATCH 11/31] ext4: Convert ext4_try_to_write_inline_data() " Matthew Wilcox (Oracle)
2023-03-14 22:37   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 12/31] ext4: Convert ext4_da_convert_inline_data_to_extent() " Matthew Wilcox (Oracle)
2023-01-26 20:23 ` [PATCH 13/31] ext4: Convert ext4_da_write_inline_data_begin() " Matthew Wilcox (Oracle)
2023-01-26 20:23 ` [PATCH 14/31] ext4: Convert ext4_read_inline_page() to ext4_read_inline_folio() Matthew Wilcox (Oracle)
2023-03-14 22:38   ` Theodore Ts'o
2023-01-26 20:23 ` [PATCH 15/31] ext4: Convert ext4_write_inline_data_end() to use a folio Matthew Wilcox (Oracle)
2023-03-14 22:39   ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 16/31] ext4: Convert ext4_write_begin() " Matthew Wilcox (Oracle)
2023-03-14 22:40   ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 17/31] ext4: Convert ext4_write_end() " Matthew Wilcox (Oracle)
2023-03-14 22:41   ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 18/31] ext4: Use a folio in ext4_journalled_write_end() Matthew Wilcox (Oracle)
2023-03-14 22:41   ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 19/31] ext4: Convert ext4_journalled_zero_new_buffers() to use a folio Matthew Wilcox (Oracle)
2023-03-14 22:46   ` Theodore Ts'o
2023-03-24  4:15     ` Matthew Wilcox [this message]
2023-01-26 20:24 ` [PATCH 20/31] ext4: Convert __ext4_block_zero_page_range() " Matthew Wilcox (Oracle)
2023-03-05 12:26   ` Ritesh Harjani
2023-01-26 20:24 ` [PATCH 21/31] ext4: Convert __ext4_journalled_writepage() to take " Matthew Wilcox (Oracle)
2023-03-14 22:47   ` Theodore Ts'o
2023-03-24  4:55     ` Matthew Wilcox
2023-01-26 20:24 ` [PATCH 22/31] ext4: Convert ext4_page_nomap_can_writeout() " Matthew Wilcox (Oracle)
2023-03-14 22:50   ` Theodore Ts'o
2023-01-26 20:24 ` [PATCH 23/31] ext4: Use a folio in ext4_da_write_begin() Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 24/31] ext4: Convert ext4_mpage_readpages() to work on folios Matthew Wilcox (Oracle)
2023-01-27  4:15   ` Eric Biggers
2023-01-27 16:08     ` Matthew Wilcox
2023-03-05 11:26       ` Ritesh Harjani
2023-01-26 20:24 ` [PATCH 25/31] ext4: Convert ext4_block_write_begin() to take a folio Matthew Wilcox (Oracle)
2023-03-06  6:51   ` Ritesh Harjani
2023-03-06  8:27     ` Matthew Wilcox
2023-03-06 15:21       ` Ritesh Harjani
2023-03-15  4:40         ` Matthew Wilcox
2023-03-15 14:57           ` Ritesh Harjani
2023-01-26 20:24 ` [PATCH 26/31] ext4: Convert ext4_writepage() " Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 27/31] ext4: Use a folio in ext4_page_mkwrite() Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 28/31] ext4: Use a folio iterator in __read_end_io() Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 29/31] ext4: Convert mext_page_mkuptodate() to take a folio Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 30/31] ext4: Convert pagecache_read() to use " Matthew Wilcox (Oracle)
2023-01-26 20:24 ` [PATCH 31/31] ext4: Use a folio in ext4_read_merkle_tree_page Matthew Wilcox (Oracle)
2023-03-15 17:57 ` [PATCH 00/31] Convert most of ext4 to folios Theodore Ts'o

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=ZB0j1WZOI/ZvdtEo@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.