Archive-only list for patches
 help / color / mirror / Atom feed
From: Kundan Kumar <kundan.kumar@samsung.com>
To: mcgrof@kernel.org
Cc: patches@lists.linux.dev, Kundan Kumar <kundan.kumar@samsung.com>
Subject: [PATCH v2 00/15] Test patch Parallelizing filesystem writeback
Date: Thu,  7 Aug 2025 10:26:51 +0530	[thread overview]
Message-ID: <20250807045706.2848-1-kundan.kumar@samsung.com> (raw)
In-Reply-To: CGME20250807045740epcas5p4cdec49f07b86acf2eea832890393d256@epcas5p4.samsung.com

** Test patch do not review **

Currently, pagecache writeback is performed by a single thread. Inodes
are added to a dirty list, and delayed writeback is triggered. The single
writeback thread then iterates through the dirty inode list, and executes
the writeback.

This series parallelizes the writeback by allowing multiple writeback
contexts per backing device (bdi). These writebacks contexts are executed
as separate, independent threads, improving overall parallelism.

Design Overview
================
Following Jan Kara's suggestion [1], we have introduced a new bdi
writeback context within the backing_dev_info structure. Specifically,
we have created a new structure, bdi_writeback_context, which contains
its own set of members for each writeback context.

struct bdi_writeback_ctx {
        struct bdi_writeback wb;
        struct list_head wb_list; /* list of all wbs */
        struct radix_tree_root cgwb_tree;
        struct rw_semaphore wb_switch_rwsem;
        wait_queue_head_t wb_waitq;
};

There can be multiple writeback contexts in a bdi, which helps in
achieving writeback parallelism.

struct backing_dev_info {
...
        int nr_wb_ctx;
        struct bdi_writeback_ctx **wb_ctx;
...
};

FS geometry and filesystem fragmentation
========================================
The community was concerned that parallelizing writeback would impact
delayed allocation and increase filesystem fragmentation.
Our analysis of XFS delayed allocation behavior showed that merging of
extents occurs within a specific inode. Earlier experiments with multiple
writeback contexts [2] resulted in increased fragmentation due to the
same inode being processed by different threads.

To address this, we now affine an inode to a specific writeback context
ensuring that delayed allocation works effectively.

Number of writeback contexts
============================
As suggested by Christoph we have provided a sysfs interface to change
the number of writebacks. Also we plan to keep the number as 1 for
spinning disk.

IOPS and throughput
===================
We see significant improvement in IOPS across several filesystem on both
PMEM and NVMe devices.

Performance gains:
  - On PMEM:
        Base XFS                : 544 MiB/s
        Parallel Writeback XFS  : 1015 MiB/s  (+86%)
        Base EXT4               : 536 MiB/s
        Parallel Writeback EXT4 : 1047 MiB/s  (+95%)

  - On NVMe:
        Base XFS                : 651 MiB/s
        Parallel Writeback XFS  : 808 MiB/s  (+24%)
        Base EXT4               : 494 MiB/s
        Parallel Writeback EXT4 : 797 MiB/s  (+61%)

We also see that there is no increase in filesystem fragmentation
# of extents:
  - On XFS (on PMEM):
        Base XFS                : 1964
        Parallel Writeback XFS  : 1384

  - On EXT4 (on PMEM):
        Base EXT4               : 21
        Parallel Writeback EXT4 : 11

We also plan to see the impact on other filesystems.

[1] Jan Kara suggestion :
https://lore.kernel.org/all/gamxtewl5yzg4xwu7lpp7obhp44xh344swvvf7tmbiknvbd3ww@jowphz4h4zmb/
[2] Writeback using unaffined N (# of CPUs) threads :
https://lore.kernel.org/all/20250414102824.9901-1-kundan.kumar@samsung.com/

Changes since v1:
 - Added sysfs entry to change the number of writebacks for a bdi
 - Added a filesystem interface to fetch 64 bit inode numbers
 - Made common helpers to contain writeback specific changes, which were
   affecting f2fs, fuse, gfs2 and nfs
 - Changed name from wb_ctx_arr to wb_ctx

Kundan Kumar (15):
  writeback: add infra for parallel writeback
  writeback: add support to initialize and free multiple writeback ctxs
  writeback: link bdi_writeback to its corresponding bdi_writeback_ctx
  writeback: affine inode to a writeback ctx within a bdi
  writeback: modify bdi_writeback search logic to search across all wb
    ctxs
  writeback: invoke all writeback contexts for flusher and dirtytime
    writeback
  writeback: modify sync related functions to iterate over all writeback
    contexts
  writeback: add support to collect stats for all writeback ctxs
  f2fs: add support in f2fs to handle multiple writeback contexts
  fuse: add support for multiple writeback contexts in fuse
  gfs2: add support in gfs2 to handle multiple writeback contexts
  nfs: add support in nfs to handle multiple writeback contexts
  writeback: set the num of writeback contexts to number of online cpus
  writeback: segregated allocation and free of writeback contexts
  writeback: added support to change the number of writebacks using a
    sysfs attribute

 fs/f2fs/node.c                   |   4 +-
 fs/f2fs/segment.h                |   2 +-
 fs/fs-writeback.c                | 148 ++++++++-----
 fs/fuse/file.c                   |   8 +-
 fs/gfs2/super.c                  |   2 +-
 fs/nfs/internal.h                |   2 +-
 fs/nfs/write.c                   |   4 +-
 fs/super.c                       |  23 ++
 fs/xfs/xfs_super.c               |  12 ++
 include/linux/backing-dev-defs.h |  32 +--
 include/linux/backing-dev.h      |  77 +++++--
 include/linux/fs.h               |   3 +-
 mm/backing-dev.c                 | 349 ++++++++++++++++++++++++-------
 mm/page-writeback.c              |  13 +-
 14 files changed, 513 insertions(+), 166 deletions(-)

-- 
2.25.1


       reply	other threads:[~2025-08-07  4:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20250807045740epcas5p4cdec49f07b86acf2eea832890393d256@epcas5p4.samsung.com>
2025-08-07  4:56 ` Kundan Kumar [this message]
2025-08-07  4:56   ` [PATCH v2 01/15] writeback: add infra for parallel writeback Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 02/15] writeback: add support to initialize and free multiple writeback ctxs Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 03/15] writeback: link bdi_writeback to its corresponding bdi_writeback_ctx Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 04/15] writeback: affine inode to a writeback ctx within a bdi Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 05/15] writeback: modify bdi_writeback search logic to search across all wb ctxs Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 06/15] writeback: invoke all writeback contexts for flusher and dirtytime writeback Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 07/15] writeback: modify sync related functions to iterate over all writeback contexts Kundan Kumar
2025-08-07  4:56   ` [PATCH v2 08/15] writeback: add support to collect stats for all writeback ctxs Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 09/15] f2fs: add support in f2fs to handle multiple writeback contexts Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 10/15] fuse: add support for multiple writeback contexts in fuse Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 11/15] gfs2: add support in gfs2 to handle multiple writeback contexts Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 12/15] nfs: add support in nfs " Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 13/15] writeback: set the num of writeback contexts to number of online cpus Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 14/15] writeback: segregated allocation and free of writeback contexts Kundan Kumar
2025-08-07  4:57   ` [PATCH v2 15/15] writeback: added support to change the number of writebacks using a sysfs attribute Kundan Kumar
2025-08-07 18:34   ` [PATCH v2 00/15] Test patch Parallelizing filesystem writeback Luis Chamberlain

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=20250807045706.2848-1-kundan.kumar@samsung.com \
    --to=kundan.kumar@samsung.com \
    --cc=mcgrof@kernel.org \
    --cc=patches@lists.linux.dev \
    /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