mbox series

[v10,0/4] block: add larger order folio instead of pages

Message ID 20240911064935.5630-1-kundan.kumar@samsung.com (mailing list archive)
Headers show
Series block: add larger order folio instead of pages | expand

Message

Kundan Kumar Sept. 11, 2024, 6:49 a.m. UTC
Hi Jens,

These patches have got the reviews and tested-by.
Please consider the series for inclusion.

-----
User space memory is mapped in kernel in form of pages array. These pages
are iterated and added to BIO. In process, pages are also checked for
contiguity and merged.

When mTHP is enabled the pages generally belong to larger order folio. This
patch series enables adding large folio to bio. It fetches folio for
page in the page array. The page might start from an offset in the folio
which could be multiples of PAGE_SIZE. Subsequent pages in page array
might belong to same folio. Using the length of folio, folio_offset and
remaining size, determine length in folio which can be added to the bio.
Check if pages are contiguous and belong to same folio. If yes then skip
further processing for the contiguous pages.

This complete scheme reduces the overhead of iterating through pages.

perf diff before and after this change(with mTHP enabled):

Perf diff for write I/O with 128K block size:
4.36%     -2.63%  [kernel.kallsyms]     [k] bio_iov_iter_get_pages
           2.00%  [kernel.kallsyms]     [k] bvec_try_merge_page
Perf diff for read I/O with 128K block size:
4.96%     -3.04%  [kernel.kallsyms]     [k] bio_iov_iter_get_pages
           2.39%  [kernel.kallsyms]     [k] bvec_try_merge_page

Without mTHP also, these patches when tested with Large block sizes(LBS),
provided WAF and alignment benefits[1].
[1] https://lore.kernel.org/linux-block/Zr_7YERr75vHbknA@bombadil.infradead.org/

Patch 1: Adds folio-ized version of bio_add_hw_page()
Patch 2: Adds bigger size from folio to BIO
Patch 3: Adds mm function to release n pages of folio
Patch 4: Unpin user pages belonging to folio at once using the mm
function

Changes since v9:
- changed min_t to min as all arguments of same type
- converted bio_release_page() to unpin_user_folio() at couple of places

Changes since v8:
- moved i+=num_pages to beginning of loop
- reversed the wrapper and made bio_add_hw_folio() a wrapper around
  bio_add_hw_page()
- removed bvec_try_merge_hw_folio() change from this series
- explained removal of BIO_PAGE_PINNED check in commit description
- removed function bio_release_folio() and calling unpin_user_folio()
  function directly
- corrected same_page logic to accept bigger folio offset

Changes since v7:
- changed folio-lise to folio-ize
- corrected order with wrapper definition after the guts
- removed check for BIO_PAGE_PINNED
- separated mm related implementation in different patch
- corrected issue found by kernel robot

Changes since v6:
- folio-lize bvec_try_merge_hw_page() to bvec_try_merge_hw_folio()
- restructured the code as per comments
- typecast with size_t while calculating the offset in folio.

Changes since v5:
- Made offset and len as size_t in function bio_add_hw_folio()
- Avoid unpinning skipped pages at submission, rather unpin all pages at
  once on IO completion

Changes since v4:
- folio-lize bio_add_hw_page() to bio_add_hw_folio()
- make bio_add_hw_page() as a wrapper around bio_add_hw_folio()
- make new functions bio_release_folio() and unpin_user_folio()
- made a helper function to check for contiguous pages of folio
- changed &folio->page to folio_page(folio, 0)
- reworded comments

Changes since v3:
- Added change to see if pages are contiguous and belong to same folio.
  If not then avoid skipping of pages.(Suggested by Matthew Wilcox)

Changes since v2:
- Made separate patches
- Corrected code as per kernel coding style
- Removed size_folio variable

Changes since v1:
- Changed functions bio_iov_add_page() and bio_iov_add_zone_append_page()
  to accept a folio
- Removed branch and calculate folio_offset and len in same fashion for
  both 0 order and larger folios
- Added change in NVMe driver to use nvme_setup_prp_simple() by
  ignoring multiples of PAGE_SIZE in offset
- Added a change to unpin_user_pages which were added as folios. Also
  stopped the unpin of pages one by one from __bio_release_pages()
  (Suggested by Keith)

Kundan Kumar (4):
  block: Added folio-ized version of bio_add_hw_page()
  block: introduce folio awareness and add a bigger size from folio
  mm: release number of pages of a folio
  block: unpin user pages belonging to a folio at once

 block/bio.c        | 112 +++++++++++++++++++++++++++++++++++----------
 block/blk.h        |   4 ++
 include/linux/mm.h |   1 +
 mm/gup.c           |  13 ++++++
 4 files changed, 105 insertions(+), 25 deletions(-)

Comments

Jens Axboe Sept. 11, 2024, 1:28 p.m. UTC | #1
On Wed, 11 Sep 2024 12:19:31 +0530, Kundan Kumar wrote:
> These patches have got the reviews and tested-by.
> Please consider the series for inclusion.
> 
> -----
> User space memory is mapped in kernel in form of pages array. These pages
> are iterated and added to BIO. In process, pages are also checked for
> contiguity and merged.
> 
> [...]

Applied, thanks!

[1/4] block: Added folio-ized version of bio_add_hw_page()
      commit: 7de98954687fe152c5f38afd719b3fdf9f34020a
[2/4] block: introduce folio awareness and add a bigger size from folio
      commit: ed9832bc08db29874600eb066b74918fe6fc2060
[3/4] mm: release number of pages of a folio
      commit: d3bfbfb1248498656cd25c51e41c1e31219bd0dd
[4/4] block: unpin user pages belonging to a folio at once
      commit: eb1d46fcd5d672c9da84925ec38f1aca35d40940

Best regards,