[lustre-devel] [PATCH 15/25] lustre: osc: Improve osc_queue_sync_pages

James Simmons jsimmons at infradead.org
Mon Aug 2 12:50:35 PDT 2021

From: Patrick Farrell <farr0186 at gmail.com>

This patch was split and partially done in:

So the text below refers to the combination of this patch
and that one.  This patch now just improves a looped atomic
add by replacing with a single one.  The rest of the grant
calcuation change is in

(I am retaining the text below to show the performance
osc_queue_sync_pages now has a grant calculation component,
this has a pretty painful impact on the new faster DIO
performance.  Specifically, per page ktime_get() and the
per-page atomic_add cost close to 10% of total CPU time in
the DIO path.

We can make this per batch of pages rather than for each
page, which reduces this cost from 10% of CPU to almost

This improves write performance by about 10% (but has no
effect on reads, since they don't use grant).

This patch reduces i/o time in ms/GiB by:
Write: 10 ms/GiB
Read: 0 ms/GiB

Write: 158 ms/GiB
Read: 161 ms/GiB

mpirun -np 1 $IOR -w -t 1G -b 64G -o $FILE --posix.odirect

Before patch:
write     6071

After patch:
write     6470

(Read is similar.)

This also fixes a mistake in d23d4cb67c / LU-13419 where it
removed the shrink interval update entirely from the direct
i/o path.

Fixes: d23d4cb67c ("lustre: osc: Move shrink update to per-write")
WC-bug-id: https://jira.whamcloud.com/browse/LU-13419
Lustre-commit: 87c4535f7a5d239a ("LU-13799 osc: Improve osc_queue_sync_pages")
Signed-off-by: Patrick Farrell <farr0186 at gmail.com>
Reviewed-on: https://review.whamcloud.com/39482
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Wang Shilong <wshilong at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
 fs/lustre/osc/osc_cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/osc/osc_cache.c b/fs/lustre/osc/osc_cache.c
index 50f6477..69cf9ba 100644
--- a/fs/lustre/osc/osc_cache.c
+++ b/fs/lustre/osc/osc_cache.c
@@ -2715,8 +2715,8 @@ int osc_queue_sync_pages(const struct lu_env *env, struct cl_io *io,
 			list_for_each_entry(oap, list, oap_pending_item) {
-				atomic_long_inc(&obd_dirty_pages);
+			atomic_long_add(page_count, &obd_dirty_pages);
 			osc_unreserve_grant_nolock(cli, grants, 0);
 			ext->oe_grants = grants;
 		} else {
@@ -2730,6 +2730,7 @@ int osc_queue_sync_pages(const struct lu_env *env, struct cl_io *io,
 			"not enough grant available, switching to sync for this i/o\n");
+		osc_update_next_shrink(cli);
 	ext->oe_is_rdma_only = !!(brw_flags & OBD_BRW_RDMA_ONLY);

More information about the lustre-devel mailing list