diff mbox series

net: remove disc_data_lock in ppp line discipline

Message ID 20201215150054.570-1-gao.yanB@h3c.com
State Superseded
Headers show
Series net: remove disc_data_lock in ppp line discipline | expand

Commit Message

Gao Yan Dec. 15, 2020, 3 p.m. UTC
tty layer provide tty->ldisc_sem lock to protect tty->disc_data;
For examlpe, when cpu A is running ppp_synctty_ioctl that
hold the tty->ldisc_sem, so if cpu B calls ppp_synctty_close,
it will wait until cpu A release tty->ldisc_sem. So I think it is
unnecessary to have the disc_data_lock;

cpu A                           cpu B
tty_ioctl                       tty_reopen
 ->hold tty->ldisc_sem            ->hold tty->ldisc_sem(write), failed
 ->ld->ops->ioctl                 ->wait...
 ->release tty->ldisc_sem         ->wait...OK,hold tty->ldisc_sem
                                    ->tty_ldisc_reinit
                                      ->tty_ldisc_close
                                        ->ld->ops->close

Signed-off-by: Gao Yan <gao.yanB@h3c.com>
---
 drivers/net/ppp/ppp_async.c   | 5 -----
 drivers/net/ppp/ppp_synctty.c | 5 -----
 2 files changed, 10 deletions(-)

Comments

Jakub Kicinski Dec. 17, 2020, 12:48 a.m. UTC | #1
On Tue, 15 Dec 2020 23:00:54 +0800 Gao Yan wrote:
> tty layer provide tty->ldisc_sem lock to protect tty->disc_data;

> For examlpe, when cpu A is running ppp_synctty_ioctl that

> hold the tty->ldisc_sem, so if cpu B calls ppp_synctty_close,

> it will wait until cpu A release tty->ldisc_sem. So I think it is

> unnecessary to have the disc_data_lock;

> 

> cpu A                           cpu B

> tty_ioctl                       tty_reopen

>  ->hold tty->ldisc_sem            ->hold tty->ldisc_sem(write), failed

>  ->ld->ops->ioctl                 ->wait...

>  ->release tty->ldisc_sem         ->wait...OK,hold tty->ldisc_sem

>                                     ->tty_ldisc_reinit

>                                       ->tty_ldisc_close

>                                         ->ld->ops->close  

> 

> Signed-off-by: Gao Yan <gao.yanB@h3c.com>


# Form letter - net-next is closed

We have already sent the networking pull request for 5.11 and therefore
net-next is closed for new drivers, features, code refactoring and
optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens after 5.11-rc1 is cut.

Look out for the announcement on the mailing list or check:
http://vger.kernel.org/~davem/net-next.html

RFC patches sent for review only are obviously welcome at any time.
diff mbox series

Patch

diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index 29a0917a8..f8cb591d6 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -127,17 +127,14 @@  static const struct ppp_channel_ops async_ops = {
  * FIXME: this is no longer true. The _close path for the ldisc is
  * now guaranteed to be sane.
  */
-static DEFINE_RWLOCK(disc_data_lock);
 
 static struct asyncppp *ap_get(struct tty_struct *tty)
 {
 	struct asyncppp *ap;
 
-	read_lock(&disc_data_lock);
 	ap = tty->disc_data;
 	if (ap != NULL)
 		refcount_inc(&ap->refcnt);
-	read_unlock(&disc_data_lock);
 	return ap;
 }
 
@@ -216,10 +213,8 @@  ppp_asynctty_close(struct tty_struct *tty)
 {
 	struct asyncppp *ap;
 
-	write_lock_irq(&disc_data_lock);
 	ap = tty->disc_data;
 	tty->disc_data = NULL;
-	write_unlock_irq(&disc_data_lock);
 	if (!ap)
 		return;
 
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index 0f338752c..8cdf7268c 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -129,17 +129,14 @@  ppp_print_buffer (const char *name, const __u8 *buf, int count)
  *
  * FIXME: Fixed in tty_io nowadays.
  */
-static DEFINE_RWLOCK(disc_data_lock);
 
 static struct syncppp *sp_get(struct tty_struct *tty)
 {
 	struct syncppp *ap;
 
-	read_lock(&disc_data_lock);
 	ap = tty->disc_data;
 	if (ap != NULL)
 		refcount_inc(&ap->refcnt);
-	read_unlock(&disc_data_lock);
 	return ap;
 }
 
@@ -215,10 +212,8 @@  ppp_sync_close(struct tty_struct *tty)
 {
 	struct syncppp *ap;
 
-	write_lock_irq(&disc_data_lock);
 	ap = tty->disc_data;
 	tty->disc_data = NULL;
-	write_unlock_irq(&disc_data_lock);
 	if (!ap)
 		return;