net:ppp: remove disc_data_lock in ppp line discipline
Subsystems (2)
PATCH v2 1/1 net:ppp: remove disc_data_lock in ppp line discipline
In tty layer, it provides tty->ldisc_sem to protect all tty_ldisc_ops including ppp_sync_ldisc. So I think tty->ldisc_sem can also protect tty->disc_data, and the disc_data_lock is not necessary.
--- drivers/net/ppp/ppp_async.c | 11 ++--------- drivers/net/ppp/ppp_synctty.c | 12 ++---------- 2 files changed, 4 insertions(+), 19 deletions(-)
drivers/net/ppp/ppp_async.c +2 -9
@@ -127,17 +127,13 @@ 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; +struct asyncppp *ap = tty->disc_data; -read_lock (&disc_data_lock); - ap = tty->disc_data;if (ap !=NULL )refcount_inc (&ap->refcnt); -read_unlock (&disc_data_lock);return ap; }
@@ -214,12 +210,9 @@ ppp_asynctty_open(struct tty_struct *tty)static void ppp_asynctty_close (struct tty_struct *tty) { -struct asyncppp *ap; +struct asyncppp *ap = tty->disc_data; -write_lock_irq (&disc_data_lock); - ap = tty->disc_data; tty->disc_data =NULL ; -write_unlock_irq (&disc_data_lock);if (!ap)return ;
drivers/net/ppp/ppp_synctty.c +2 -10
@@ -129,17 +129,12 @@ 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; +struct syncppp *ap = tty->disc_data; -read_lock (&disc_data_lock); - ap = tty->disc_data;if (ap !=NULL )refcount_inc (&ap->refcnt); -read_unlock (&disc_data_lock);return ap; }
@@ -213,12 +208,9 @@ ppp_sync_open(struct tty_struct *tty)static void ppp_sync_close (struct tty_struct *tty) { -struct syncppp *ap; +struct syncppp *ap = tty->disc_data; -write_lock_irq (&disc_data_lock); - ap = tty->disc_data; tty->disc_data =NULL ; -write_unlock_irq (&disc_data_lock);if (!ap)return ;
Signature · 1 line
2.17.1
Quoted 9 lines · Gao Yan
In tty layer, it provides
tty->ldisc_semto protect alltty_ldisc_opsincludingppp_sync_ldisc. So I thinktty->ldisc_semcan also protecttty->disc_data, and thedisc_data_lockis not necessary.Signed-off-by Gao Yan <[email protected]>--- drivers/net/ppp/ppp_async.c | 11 ++--------- drivers/net/ppp/ppp_synctty.c | 12 ++---------- 2 files changed, 4 insertions(+), 19 deletions(-)
What changed from v1?
And how did you test this? Why remove this lock, is it causing problems somewhere for it to be here?
thanks,
greg k-h
Jakub Kicinski
maintainerQuoted 5 lines · On Fri, 1 Jan 2021 11:37:18 +0800 Gao Yan wrote:
In tty layer, it provides
tty->ldisc_semto protect alltty_ldisc_opsincludingppp_sync_ldisc. So I thinktty->ldisc_semcan also protecttty->disc_data, and thedisc_data_lockis not necessary.Signed-off-by Gao Yan <[email protected]>
Please make sure to CC netdev.