Commit ef966d73 authored by David Howells's avatar David Howells Committed by Christian Brauner

netfs: Record contention stats for writeback lock

Record statistics for contention upon the writeback serialisation lock that
prevents racing writeback calls from causing each other to interleave their
writebacks.  These can be viewed in /proc/fs/netfs/stats on the WbLock line,
with skip=N indicating the number of non-SYNC writebacks skipped and wait=N
indicating the number of SYNC writebacks that waited.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: Steve French <sfrench@samba.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Link: https://lore.kernel.org/r/20240814203850.2240469-5-dhowells@redhat.com/ # v2
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 43ebbf93
...@@ -117,6 +117,8 @@ extern atomic_t netfs_n_wh_upload_failed; ...@@ -117,6 +117,8 @@ extern atomic_t netfs_n_wh_upload_failed;
extern atomic_t netfs_n_wh_write; extern atomic_t netfs_n_wh_write;
extern atomic_t netfs_n_wh_write_done; extern atomic_t netfs_n_wh_write_done;
extern atomic_t netfs_n_wh_write_failed; extern atomic_t netfs_n_wh_write_failed;
extern atomic_t netfs_n_wb_lock_skip;
extern atomic_t netfs_n_wb_lock_wait;
int netfs_stats_show(struct seq_file *m, void *v); int netfs_stats_show(struct seq_file *m, void *v);
......
...@@ -39,6 +39,8 @@ atomic_t netfs_n_wh_upload_failed; ...@@ -39,6 +39,8 @@ atomic_t netfs_n_wh_upload_failed;
atomic_t netfs_n_wh_write; atomic_t netfs_n_wh_write;
atomic_t netfs_n_wh_write_done; atomic_t netfs_n_wh_write_done;
atomic_t netfs_n_wh_write_failed; atomic_t netfs_n_wh_write_failed;
atomic_t netfs_n_wb_lock_skip;
atomic_t netfs_n_wb_lock_wait;
int netfs_stats_show(struct seq_file *m, void *v) int netfs_stats_show(struct seq_file *m, void *v)
{ {
...@@ -78,6 +80,9 @@ int netfs_stats_show(struct seq_file *m, void *v) ...@@ -78,6 +80,9 @@ int netfs_stats_show(struct seq_file *m, void *v)
atomic_read(&netfs_n_rh_rreq), atomic_read(&netfs_n_rh_rreq),
atomic_read(&netfs_n_rh_sreq), atomic_read(&netfs_n_rh_sreq),
atomic_read(&netfs_n_wh_wstream_conflict)); atomic_read(&netfs_n_wh_wstream_conflict));
seq_printf(m, "WbLock : skip=%u wait=%u\n",
atomic_read(&netfs_n_wb_lock_skip),
atomic_read(&netfs_n_wb_lock_wait));
return fscache_stats_show(m); return fscache_stats_show(m);
} }
EXPORT_SYMBOL(netfs_stats_show); EXPORT_SYMBOL(netfs_stats_show);
...@@ -505,10 +505,14 @@ int netfs_writepages(struct address_space *mapping, ...@@ -505,10 +505,14 @@ int netfs_writepages(struct address_space *mapping,
struct folio *folio; struct folio *folio;
int error = 0; int error = 0;
if (wbc->sync_mode == WB_SYNC_ALL) if (!mutex_trylock(&ictx->wb_lock)) {
if (wbc->sync_mode == WB_SYNC_NONE) {
netfs_stat(&netfs_n_wb_lock_skip);
return 0;
}
netfs_stat(&netfs_n_wb_lock_wait);
mutex_lock(&ictx->wb_lock); mutex_lock(&ictx->wb_lock);
else if (!mutex_trylock(&ictx->wb_lock)) }
return 0;
/* Need the first folio to be able to set up the op. */ /* Need the first folio to be able to set up the op. */
folio = writeback_iter(mapping, wbc, NULL, &error); folio = writeback_iter(mapping, wbc, NULL, &error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment