* [PATCH net-next] ppp: convert chan_sem to a mutex
@ 2026-07-27 3:28 Qingfang Deng
2026-07-29 2:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Qingfang Deng @ 2026-07-27 3:28 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Qingfang Deng, Kees Cook, Taegu Ha, linux-ppp,
netdev, linux-kernel
chan_sem's read-side lock is taken under another mutex, so there is no
benefit in keeping it as an rwsem. Replace the rwsem with a mutex.
Signed-off-by: Qingfang Deng <qingfang.deng@linux.dev>
---
drivers/net/ppp/ppp_generic.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index cacc4c3a37d2..08bb89765487 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -39,7 +39,6 @@
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/spinlock.h>
-#include <linux/rwsem.h>
#include <linux/stddef.h>
#include <linux/device.h>
#include <linux/mutex.h>
@@ -176,7 +175,7 @@ struct channel {
struct ppp_file file; /* stuff for read/write/poll */
struct list_head list; /* link in all/new_channels list */
struct ppp_channel *chan; /* public channel data structure */
- struct rw_semaphore chan_sem; /* protects `chan' during chan ioctl */
+ struct mutex chan_sem; /* protects `chan' during chan ioctl */
spinlock_t downl; /* protects `chan', file.xq dequeue */
struct ppp __rcu *ppp; /* ppp unit we're connected to */
struct net *chan_net; /* the net channel belongs to */
@@ -788,12 +787,12 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
break;
default:
- down_read(&pch->chan_sem);
+ mutex_lock(&pch->chan_sem);
chan = pch->chan;
err = -ENOTTY;
if (chan && chan->ops->ioctl)
err = chan->ops->ioctl(chan, cmd, arg);
- up_read(&pch->chan_sem);
+ mutex_unlock(&pch->chan_sem);
}
goto out;
}
@@ -2922,7 +2921,7 @@ int ppp_register_net_channel(struct net *net, struct ppp_channel *chan)
#ifdef CONFIG_PPP_MULTILINK
pch->lastseq = -1;
#endif /* CONFIG_PPP_MULTILINK */
- init_rwsem(&pch->chan_sem);
+ mutex_init(&pch->chan_sem);
spin_lock_init(&pch->downl);
spin_lock_init(&pch->upl);
@@ -3005,11 +3004,11 @@ ppp_unregister_channel(struct ppp_channel *chan)
* the channel's start_xmit or ioctl routine before we proceed.
*/
ppp_disconnect_channel(pch);
- down_write(&pch->chan_sem);
+ mutex_lock(&pch->chan_sem);
spin_lock_bh(&pch->downl);
pch->chan = NULL;
spin_unlock_bh(&pch->downl);
- up_write(&pch->chan_sem);
+ mutex_unlock(&pch->chan_sem);
pn = ppp_pernet(pch->chan_net);
spin_lock_bh(&pn->all_channels_lock);
@@ -3600,6 +3599,7 @@ static void ppp_release_channel(struct channel *pch)
pr_err("ppp: destroying undead channel %p !\n", pch);
return;
}
+ mutex_destroy(&pch->chan_sem);
call_rcu(&pch->rcu, ppp_release_channel_free);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] ppp: convert chan_sem to a mutex
2026-07-27 3:28 [PATCH net-next] ppp: convert chan_sem to a mutex Qingfang Deng
@ 2026-07-29 2:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-29 2:20 UTC (permalink / raw)
To: Qingfang Deng
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, kees, hataegu0826,
linux-ppp, netdev, linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 27 Jul 2026 11:28:00 +0800 you wrote:
> chan_sem's read-side lock is taken under another mutex, so there is no
> benefit in keeping it as an rwsem. Replace the rwsem with a mutex.
>
> Signed-off-by: Qingfang Deng <qingfang.deng@linux.dev>
> ---
> drivers/net/ppp/ppp_generic.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
Here is the summary with links:
- [net-next] ppp: convert chan_sem to a mutex
https://git.kernel.org/netdev/net-next/c/2bb54b49e9d5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-29 2:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 3:28 [PATCH net-next] ppp: convert chan_sem to a mutex Qingfang Deng
2026-07-29 2:20 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.