From patchwork Tue Dec 15 15:00:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gaoyan X-Patchwork-Id: 11975169 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7837C4361B for ; Tue, 15 Dec 2020 16:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C6492255F for ; Tue, 15 Dec 2020 16:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730658AbgLOQao (ORCPT ); Tue, 15 Dec 2020 11:30:44 -0500 Received: from smtp.h3c.com ([60.191.123.56]:23020 "EHLO h3cspam01-ex.h3c.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730015AbgLOQao (ORCPT ); Tue, 15 Dec 2020 11:30:44 -0500 X-Greylist: delayed 4628 seconds by postgrey-1.27 at vger.kernel.org; Tue, 15 Dec 2020 11:30:42 EST Received: from h3cspam01-ex.h3c.com (localhost [127.0.0.2] (may be forged)) by h3cspam01-ex.h3c.com with ESMTP id 0BFFDeEv059183 for ; Tue, 15 Dec 2020 23:13:40 +0800 (GMT-8) (envelope-from gao.yanB@h3c.com) Received: from DAG2EX08-IDC.srv.huawei-3com.com ([10.8.0.71]) by h3cspam01-ex.h3c.com with ESMTP id 0BFFBUSo058450; Tue, 15 Dec 2020 23:11:30 +0800 (GMT-8) (envelope-from gao.yanB@h3c.com) Received: from localhost.localdomain (10.99.212.201) by DAG2EX08-IDC.srv.huawei-3com.com (10.8.0.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 15 Dec 2020 23:11:34 +0800 From: Gao Yan To: , , CC: , , Gao Yan Subject: [PATCH] net: remove disc_data_lock in ppp line discipline Date: Tue, 15 Dec 2020 23:00:54 +0800 Message-ID: <20201215150054.570-1-gao.yanB@h3c.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.99.212.201] X-ClientProxiedBy: BJSMTP02-EX.srv.huawei-3com.com (10.63.20.133) To DAG2EX08-IDC.srv.huawei-3com.com (10.8.0.71) X-DNSRBL: X-MAIL: h3cspam01-ex.h3c.com 0BFFBUSo058450 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 --- drivers/net/ppp/ppp_async.c | 5 ----- drivers/net/ppp/ppp_synctty.c | 5 ----- 2 files changed, 10 deletions(-) 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;