Message ID | 20241017-mptcp-sched-avail-lock-v1-1-028ef592c6f4@kernel.org (mailing list archive) |
---|---|
State | Accepted, archived |
Commit | 7c2d2c795bd469ed664144141d3749d5efe61965 |
Delegated to: | Matthieu Baerts |
Headers | show |
Series | mptcp: remove unneeded lock when listing scheds | expand |
Context | Check | Description |
---|---|---|
matttbe/build | success | Build and static analysis OK |
matttbe/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 14 lines checked |
matttbe/shellcheck | success | MPTCP selftests files have not been modified |
matttbe/KVM_Validation__normal | success | Success! ✅ |
matttbe/KVM_Validation__debug | success | Success! ✅ |
matttbe/KVM_Validation__btf-normal__only_bpftest_all_ | success | Success! ✅ |
matttbe/KVM_Validation__btf-debug__only_bpftest_all_ | success | Success! ✅ |
Hi Matt, Thanks for this fix. On Thu, 2024-10-17 at 12:16 +0200, Matthieu Baerts (NGI0) wrote: > mptcp_get_available_schedulers() needs to iterate over the > schedulers' > list only to read the names: it doesn't modify anything there. > > In this case, it is enough to hold the RCU read lock, no need to > combine > this with the associated spin lock. > > Fixes: 73c900aa3660 ("mptcp: add net.mptcp.available_schedulers") > Suggested-by: Paolo Abeni <pabeni@redhat.com> > Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Good catch! Reviewed-by: Geliang Tang <geliang@kernel.org> -Geliang > --- > net/mptcp/sched.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c > index > 5257bc6c8cd6e8ca674c9beccaf7b27c989da76a..6da60e35932ffd8a92ad7a8b128 > e5eaf09219b82 100644 > --- a/net/mptcp/sched.c > +++ b/net/mptcp/sched.c > @@ -60,7 +60,6 @@ void mptcp_get_available_schedulers(char *buf, > size_t maxlen) > size_t offs = 0; > > rcu_read_lock(); > - spin_lock(&mptcp_sched_list_lock); > list_for_each_entry_rcu(sched, &mptcp_sched_list, list) { > offs += snprintf(buf + offs, maxlen - offs, > "%s%s", > @@ -69,7 +68,6 @@ void mptcp_get_available_schedulers(char *buf, > size_t maxlen) > if (WARN_ON_ONCE(offs >= maxlen)) > break; > } > - spin_unlock(&mptcp_sched_list_lock); > rcu_read_unlock(); > } > >
diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index 5257bc6c8cd6e8ca674c9beccaf7b27c989da76a..6da60e35932ffd8a92ad7a8b128e5eaf09219b82 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -60,7 +60,6 @@ void mptcp_get_available_schedulers(char *buf, size_t maxlen) size_t offs = 0; rcu_read_lock(); - spin_lock(&mptcp_sched_list_lock); list_for_each_entry_rcu(sched, &mptcp_sched_list, list) { offs += snprintf(buf + offs, maxlen - offs, "%s%s", @@ -69,7 +68,6 @@ void mptcp_get_available_schedulers(char *buf, size_t maxlen) if (WARN_ON_ONCE(offs >= maxlen)) break; } - spin_unlock(&mptcp_sched_list_lock); rcu_read_unlock(); }
mptcp_get_available_schedulers() needs to iterate over the schedulers' list only to read the names: it doesn't modify anything there. In this case, it is enough to hold the RCU read lock, no need to combine this with the associated spin lock. Fixes: 73c900aa3660 ("mptcp: add net.mptcp.available_schedulers") Suggested-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> --- net/mptcp/sched.c | 2 -- 1 file changed, 2 deletions(-)