From: "Darrick J. Wong" <djwong@kernel.org>
To: Kundan Kumar <kundan.kumar@samsung.com>
Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
willy@infradead.org, mcgrof@kernel.org, clm@meta.com,
david@fromorbit.com, amir73il@gmail.com, axboe@kernel.dk,
hch@lst.de, ritesh.list@gmail.com, dave@stgolabs.net,
cem@kernel.org, wangyufei@vivo.com,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-xfs@vger.kernel.org, gost.dev@samsung.com,
anuj20.g@samsung.com, vishak.g@samsung.com, joshi.k@samsung.com
Subject: Re: [PATCH v3 5/6] xfs: add per-AG writeback workqueue infrastructure
Date: Thu, 29 Jan 2026 14:21:01 -0800 [thread overview]
Message-ID: <20260129222101.GD7712@frogsfrogsfrogs> (raw)
In-Reply-To: <20260116100818.7576-6-kundan.kumar@samsung.com>
On Fri, Jan 16, 2026 at 03:38:17PM +0530, Kundan Kumar wrote:
> Introduce per-AG writeback worker infrastructure at mount time.
> This patch adds initialization and teardown only, without changing
> writeback behavior.
>
> Signed-off-by: Kundan Kumar <kundan.kumar@samsung.com>
> Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
> ---
> fs/xfs/xfs_aops.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++
> fs/xfs/xfs_aops.h | 3 ++
> fs/xfs/xfs_mount.c | 2 ++
> fs/xfs/xfs_mount.h | 10 ++++++
> fs/xfs/xfs_super.c | 2 ++
> 5 files changed, 96 insertions(+)
>
> diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
> index a26f79815533..9d5b65922cd2 100644
> --- a/fs/xfs/xfs_aops.c
> +++ b/fs/xfs/xfs_aops.c
> @@ -23,6 +23,23 @@
> #include "xfs_zone_alloc.h"
> #include "xfs_rtgroup.h"
>
> +#define XFS_AG_TASK_POOL_MIN 1024
> +
> +struct xfs_ag_wb_task {
> + struct list_head list;
> + struct xfs_inode *ip;
> + struct writeback_control wbc;
> + xfs_agnumber_t agno;
> +};
> +
> +struct xfs_ag_wb {
> + struct delayed_work ag_work;
> + spinlock_t lock;
> + struct list_head task_list;
> + xfs_agnumber_t agno;
> + struct xfs_mount *mp;
> +};
Help me understand the data structures here ... for each AG there's an
xfs_ag_wb object which can be run as a delayed workqueue item. This
xfs_ag_wb is the head of a list of xfs_ag_wb_task items?
In turn, each xfs_ag_wb_task list item points to an inode and
(redundantly?) the agnumber? So in effect each AG has a kworker that
can say "do all of this file's pagecache writeback for all dirty folios
tagged with the same agnumber"?
<shrug> It's hard to tell with no comments about how these two pieces of
data relate to each other.
--D
> struct xfs_writepage_ctx {
> struct iomap_writepage_ctx ctx;
> unsigned int data_seq;
> @@ -666,6 +683,68 @@ static const struct iomap_writeback_ops xfs_zoned_writeback_ops = {
> .writeback_submit = xfs_zoned_writeback_submit,
> };
>
> +void
> +xfs_init_ag_writeback(struct xfs_mount *mp)
> +{
> + xfs_agnumber_t agno;
> +
> + mp->m_ag_wq = alloc_workqueue("xfs-ag-wb", WQ_UNBOUND | WQ_MEM_RECLAIM,
> + 0);
> + if (!mp->m_ag_wq)
> + return;
> +
> + mp->m_ag_wb = kcalloc(mp->m_sb.sb_agcount,
> + sizeof(struct xfs_ag_wb),
> + GFP_KERNEL);
> +
> + if (!mp->m_ag_wb) {
> + destroy_workqueue(mp->m_ag_wq);
> + mp->m_ag_wq = NULL;
> + return;
> + }
> +
> + for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) {
> + struct xfs_ag_wb *awb = &mp->m_ag_wb[agno];
> +
> + spin_lock_init(&awb->lock);
> + INIT_LIST_HEAD(&awb->task_list);
> + awb->agno = agno;
> + awb->mp = mp;
Can't you stuff this information in struct xfs_perag instead of asking
for a potentially huge allocation?
> + }
> +
> + mp->m_ag_task_cachep = kmem_cache_create("xfs_ag_wb_task",
> + sizeof(struct xfs_ag_wb_task),
> + 0,
> + SLAB_RECLAIM_ACCOUNT,
> + NULL);
> +
> + mp->m_ag_task_pool = mempool_create_slab_pool(XFS_AG_TASK_POOL_MIN,
> + mp->m_ag_task_cachep);
> +
> + if (!mp->m_ag_task_pool) {
> + kmem_cache_destroy(mp->m_ag_task_cachep);
> + mp->m_ag_task_cachep = NULL;
> + }
> +}
> +
> +void
> +xfs_destroy_ag_writeback(struct xfs_mount *mp)
> +{
> + if (mp->m_ag_wq) {
> + flush_workqueue(mp->m_ag_wq);
> + destroy_workqueue(mp->m_ag_wq);
> + mp->m_ag_wq = NULL;
> + }
> + kfree(mp->m_ag_wb);
> + mp->m_ag_wb = NULL;
> +
> + mempool_destroy(mp->m_ag_task_pool);
> + mp->m_ag_task_pool = NULL;
> +
> + kmem_cache_destroy(mp->m_ag_task_cachep);
> + mp->m_ag_task_cachep = NULL;
> +}
> +
> STATIC int
> xfs_vm_writepages(
> struct address_space *mapping,
> diff --git a/fs/xfs/xfs_aops.h b/fs/xfs/xfs_aops.h
> index 5a7a0f1a0b49..e84acb7e8ca8 100644
> --- a/fs/xfs/xfs_aops.h
> +++ b/fs/xfs/xfs_aops.h
> @@ -12,4 +12,7 @@ extern const struct address_space_operations xfs_dax_aops;
> int xfs_setfilesize(struct xfs_inode *ip, xfs_off_t offset, size_t size);
> void xfs_end_bio(struct bio *bio);
>
> +void xfs_init_ag_writeback(struct xfs_mount *mp);
> +void xfs_destroy_ag_writeback(struct xfs_mount *mp);
> +
> #endif /* __XFS_AOPS_H__ */
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 0953f6ae94ab..26224503c4bf 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -1323,6 +1323,8 @@ xfs_unmountfs(
>
> xfs_qm_unmount(mp);
>
> + xfs_destroy_ag_writeback(mp);
> +
> /*
> * Unreserve any blocks we have so that when we unmount we don't account
> * the reserved free space as used. This is really only necessary for
> diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
> index b871dfde372b..c44155de2883 100644
> --- a/fs/xfs/xfs_mount.h
> +++ b/fs/xfs/xfs_mount.h
> @@ -342,6 +342,16 @@ typedef struct xfs_mount {
>
> /* Hook to feed dirent updates to an active online repair. */
> struct xfs_hooks m_dir_update_hooks;
> +
> +
> + /* global XFS AG writeback wq */
> + struct workqueue_struct *m_ag_wq;
> + /* array of [sb_agcount] */
> + struct xfs_ag_wb *m_ag_wb;
> +
> + /* task cache and pool */
> + struct kmem_cache *m_ag_task_cachep;
> + mempool_t *m_ag_task_pool;
> } xfs_mount_t;
>
> #define M_IGEO(mp) (&(mp)->m_ino_geo)
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index bc71aa9dcee8..73f8d2942df4 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1765,6 +1765,8 @@ xfs_fs_fill_super(
> if (error)
> goto out_free_sb;
>
> + xfs_init_ag_writeback(mp);
> +
> /*
> * V4 support is undergoing deprecation.
> *
> --
> 2.25.1
>
>
next prev parent reply other threads:[~2026-01-29 22:21 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20260116101236epcas5p12ba3de776976f4ea6666e16a33ab6ec4@epcas5p1.samsung.com>
2026-01-16 10:08 ` [PATCH v3 0/6] AG aware parallel writeback for XFS Kundan Kumar
2026-01-16 10:08 ` [PATCH v3 1/6] iomap: add write ops hook to attach metadata to folios Kundan Kumar
2026-01-16 10:08 ` [PATCH v3 2/6] xfs: add helpers to pack AG prediction info for per-folio tracking Kundan Kumar
2026-01-29 0:45 ` Darrick J. Wong
2026-02-03 7:15 ` Kundan Kumar
2026-02-05 16:39 ` Darrick J. Wong
2026-02-04 7:37 ` Nirjhar Roy (IBM)
2026-01-16 10:08 ` [PATCH v3 3/6] xfs: add per-inode AG prediction map and dirty-AG bitmap Kundan Kumar
2026-01-29 0:44 ` Darrick J. Wong
2026-02-03 7:20 ` Kundan Kumar
2026-02-05 16:42 ` Darrick J. Wong
2026-02-05 6:44 ` Nirjhar Roy (IBM)
2026-02-05 16:32 ` Darrick J. Wong
2026-02-06 5:41 ` Nirjhar Roy (IBM)
2026-02-05 6:36 ` Nirjhar Roy (IBM)
2026-02-05 16:36 ` Darrick J. Wong
2026-02-06 5:36 ` Nirjhar Roy (IBM)
2026-02-06 5:57 ` Darrick J. Wong
2026-02-06 6:03 ` Nirjhar Roy (IBM)
2026-02-06 7:00 ` Christoph Hellwig
2026-01-16 10:08 ` [PATCH v3 4/6] xfs: tag folios with AG number during buffered write via iomap attach hook Kundan Kumar
2026-01-29 0:47 ` Darrick J. Wong
2026-01-29 22:40 ` Darrick J. Wong
2026-02-03 7:32 ` Kundan Kumar
2026-02-03 7:28 ` Kundan Kumar
2026-02-05 15:56 ` Brian Foster
2026-02-06 6:44 ` Nirjhar Roy (IBM)
2026-01-16 10:08 ` [PATCH v3 5/6] xfs: add per-AG writeback workqueue infrastructure Kundan Kumar
2026-01-29 22:21 ` Darrick J. Wong [this message]
2026-02-03 7:35 ` Kundan Kumar
2026-02-06 6:46 ` Christoph Hellwig
2026-02-10 11:56 ` Nirjhar Roy (IBM)
2026-01-16 10:08 ` [PATCH v3 6/6] xfs: offload writeback by AG using per-inode dirty bitmap and per-AG workers Kundan Kumar
2026-01-29 22:34 ` Darrick J. Wong
2026-02-03 7:40 ` Kundan Kumar
2026-02-11 9:39 ` Nirjhar Roy (IBM)
2026-01-16 16:13 ` [syzbot ci] Re: AG aware parallel writeback for XFS syzbot ci
2026-01-21 19:54 ` [PATCH v3 0/6] " Brian Foster
2026-01-22 16:15 ` Kundan Kumar
2026-01-23 9:36 ` Pankaj Raghav (Samsung)
2026-01-23 13:26 ` Brian Foster
2026-01-28 18:28 ` Kundan Kumar
2026-02-06 6:25 ` Christoph Hellwig
2026-02-06 10:07 ` Kundan Kumar
2026-02-06 17:42 ` Darrick J. Wong
2026-02-09 6:30 ` Christoph Hellwig
2026-02-09 15:54 ` Kundan Kumar
2026-02-10 15:38 ` Christoph Hellwig
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=20260129222101.GD7712@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=amir73il@gmail.com \
--cc=anuj20.g@samsung.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=clm@meta.com \
--cc=dave@stgolabs.net \
--cc=david@fromorbit.com \
--cc=gost.dev@samsung.com \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=joshi.k@samsung.com \
--cc=kundan.kumar@samsung.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=ritesh.list@gmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=vishak.g@samsung.com \
--cc=wangyufei@vivo.com \
--cc=willy@infradead.org \
/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.