diff mbox series

[net,2/3] mptcp: remove unneeded lock when listing scheds

Message ID 20241021-net-mptcp-sched-lock-v1-2-637759cf061c@kernel.org (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series mptcp: sched: fix some lock issues | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-23--12-00 (tests: 777)

Commit Message

Matthieu Baerts Oct. 21, 2024, 10:25 a.m. UTC
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")
Cc: stable@vger.kernel.org
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/sched.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Simon Horman Oct. 23, 2024, 12:21 p.m. UTC | #1
On Mon, Oct 21, 2024 at 12:25:27PM +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")
> Cc: stable@vger.kernel.org
> Suggested-by: Paolo Abeni <pabeni@redhat.com>
> Reviewed-by: Geliang Tang <geliang@kernel.org>
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

I do wonder if it would be more appropriate to route this via net-next
(without a fixes tag) rather than via net. But either way this looks good
to me.

Reviewed-by: Simon Horman <horms@kernel.org>

...
Matthieu Baerts Oct. 23, 2024, 2:13 p.m. UTC | #2
Hi Simon,

Thank you for the reviews!

On 23/10/2024 14:21, Simon Horman wrote:
> On Mon, Oct 21, 2024 at 12:25:27PM +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")
>> Cc: stable@vger.kernel.org
>> Suggested-by: Paolo Abeni <pabeni@redhat.com>
>> Reviewed-by: Geliang Tang <geliang@kernel.org>
>> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> 
> I do wonder if it would be more appropriate to route this via net-next
> (without a fixes tag) rather than via net. But either way this looks good
> to me.
Good point. On one hand, I marked it as a fix, because when working on
the patch 1/3, we noticed these spin_(un)lock() were not supposed to be
there in the first place. On the other hand, even it's fixing a small
performance issue, it is not fixing a regression.

I think it is easier to route this via -net, but I'm fine if it is
applied in net-next.

Cheers,
Matt
Simon Horman Oct. 25, 2024, 10 a.m. UTC | #3
On Wed, Oct 23, 2024 at 04:13:36PM +0200, Matthieu Baerts wrote:
> Hi Simon,
> 
> Thank you for the reviews!
> 
> On 23/10/2024 14:21, Simon Horman wrote:
> > On Mon, Oct 21, 2024 at 12:25:27PM +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")
> >> Cc: stable@vger.kernel.org
> >> Suggested-by: Paolo Abeni <pabeni@redhat.com>
> >> Reviewed-by: Geliang Tang <geliang@kernel.org>
> >> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> > 
> > I do wonder if it would be more appropriate to route this via net-next
> > (without a fixes tag) rather than via net. But either way this looks good
> > to me.
> Good point. On one hand, I marked it as a fix, because when working on
> the patch 1/3, we noticed these spin_(un)lock() were not supposed to be
> there in the first place. On the other hand, even it's fixing a small
> performance issue, it is not fixing a regression.
> 
> I think it is easier to route this via -net, but I'm fine if it is
> applied in net-next.

Understood. FTR, I don't feel strongly about this either way.
Jakub Kicinski Oct. 28, 2024, 10:53 p.m. UTC | #4
On Wed, 23 Oct 2024 16:13:36 +0200 Matthieu Baerts wrote:
> On 23/10/2024 14:21, Simon Horman wrote:
> > On Mon, Oct 21, 2024 at 12:25:27PM +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")
> >> Cc: stable@vger.kernel.org
> >> Suggested-by: Paolo Abeni <pabeni@redhat.com>
> >> Reviewed-by: Geliang Tang <geliang@kernel.org>
> >> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>  
> > 
> > I do wonder if it would be more appropriate to route this via net-next
> > (without a fixes tag) rather than via net. But either way this looks good
> > to me.  
> Good point. On one hand, I marked it as a fix, because when working on
> the patch 1/3, we noticed these spin_(un)lock() were not supposed to be
> there in the first place. On the other hand, even it's fixing a small
> performance issue, it is not fixing a regression.
> 
> I think it is easier to route this via -net, but I'm fine if it is
> applied in net-next.

I agree with Simon's initial response. Let's not blur the lines.
Please re-queue for net-next, I'll apply the rest.

BTW thanks a lot for proactively fixing the CONFIG_PROVE_RCU_LIST
splats!
diff mbox series

Patch

diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
index 78ed508ebc1b8dd9f0e020cca1bdd86f24f0afeb..df7dbcfa3b71370cc4d7e4e4f16cc1e41a50dddf 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();
 }