* [PATCH] libceph: Avoid unsequenced accesses to jiffies in dump_linger_request()
@ 2026-11-15 21:39 Nathan Chancellor
0 siblings, 0 replies; only message in thread
From: Nathan Chancellor @ 2026-11-15 21:39 UTC (permalink / raw)
To: Ilya Dryomov, Alex Markuze, Xiubo Li
Cc: Viacheslav Dubeyko, ceph-devel, linux-kernel, llvm, Nathan Chancellor
After a recent improvement in clang to warn on unsequenced accesses to
volatile variables [1], an instance appear in dump_linger_request(),
which can break the build with CONFIG_WERROR=y / W=e:
net/ceph/debugfs.c:269:42: error: unsequenced accesses to volatile qualified 'jiffies' [-Werror,-Wunsequenced]
267 | req ? jiffies_to_msecs(jiffies - req->r_start_stamp) : 0,
| ~~~~~~~
268 | lreq->is_watch && lreq->committed && !lreq->last_error ?
269 | jiffies_to_msecs(jiffies - lreq->watch_valid_thru) : 0,
| ^
Per C11 5.1.2.3.2, accessing a volatile object is a side effect. Per C11
6.5.2, unsequenced side effects on the same scalar object are undefined
behavior. Per C11 6.5.2.2.10/12, the evaluation of arguments in a
function call is indeterminately sequenced, meaning any side effects in
the arguments are unsequenced.
Add a local variable to hold the value of jiffies before the function
call so that there are no unsequenced side effects, clearing up the
warning.
Fixes: a407f9961902 ("libceph: include current latency in debugfs osdc dump")
Closes: https://github.com/ClangBuiltLinux/linux/issues/2200
Link: https://github.com/llvm/llvm-project/commit/955715460eaf9188c241c74750637fc82dfcc423 [1]
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
net/ceph/debugfs.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c
index b068e25f2acc..82270f0e4d7e 100644
--- a/net/ceph/debugfs.c
+++ b/net/ceph/debugfs.c
@@ -259,14 +259,15 @@ static void dump_linger_request(struct seq_file *s,
struct ceph_osd_request *req =
list_first_entry_or_null(&lreq->osd_reqs, struct ceph_osd_request,
r_private_item);
+ unsigned long j = jiffies;
seq_printf(s, "%llu\t", lreq->linger_id);
dump_target(s, &lreq->t);
seq_printf(s, "\t%u\t%u\t%u\t%s%s/%d\n", lreq->register_gen,
- req ? jiffies_to_msecs(jiffies - req->r_start_stamp) : 0,
+ req ? jiffies_to_msecs(j - req->r_start_stamp) : 0,
lreq->is_watch && lreq->committed && !lreq->last_error ?
- jiffies_to_msecs(jiffies - lreq->watch_valid_thru) : 0,
+ jiffies_to_msecs(j - lreq->watch_valid_thru) : 0,
lreq->is_watch ? "W" : "N", lreq->committed ? "C" : "",
lreq->last_error);
}
---
base-commit: a407f99619029b76548774af1006319f810bb345
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
change-id: 20261115-ceph-wunsequenced-44a2019df3ff
Best regards,
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-15 21:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-15 21:39 [PATCH] libceph: Avoid unsequenced accesses to jiffies in dump_linger_request() Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®