Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp11731412pxu; Thu, 31 Dec 2020 19:53:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwE7qUm41Itzp6Wm4hNt6t8N6svBppXlraPWtEWgSWeZmsPucae960kMpvbLvIZOA6VBV4+ X-Received: by 2002:a17:906:4bc5:: with SMTP id x5mr55727805ejv.55.1609473219365; Thu, 31 Dec 2020 19:53:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609473219; cv=none; d=google.com; s=arc-20160816; b=WUTs/iUkluObQKQXOec4XyBnlQU7MBBoCfGU+qMKd4Wu5eamCjyZiP5KjtlmtfPEpr DFknxELTf0BiyCZB1jxdWyLqSTOJKNAqTaNZ/2xGdteweVRuf168F6IsdcO84doOgBer 1c9FxHiJSRxIqHmGQiBbFFYeVP4p5iplnBqDdZic87UGKLiaJf0st2zS6vF30h9Vz/tL o4i2FILXApxKC65p8fD3L5DqSKwahEtFJz8l67keSA3gdh831hNp05MiYPxdJqu3Hk9f 7UdjydaRYUAnVrzcEyX1ighj25QR5ICqd/F78PVSbFi6jhinnQwIQFyha+52fUUwmdel ZYxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=YOzSEitDrfjwuEvxboJahZq3pVwHvHmyDvudtqhPDp8=; b=XvCX4WsR2GFgYRC7a6LvtQtujvcSh/Ke3qQ3dwzmll18YtOeKg3Rm+logwkJm0mayp 0Y/uR7bL3XmacHracmUwvGQbmVQZCTQ9A2ySwjZPLLZDh6H26Jp6D24OP5wJD+o1CQc8 DbCe0HnWJZYiU9DeiZV5luby24AwKyP2UJobokrTj7IjoVX8E9d2ULKK8hor4wspBg9x IUKGEsYRmnOS4mCkGOQFP6GLsI6G+mPidwkWpIX55COLBLhq2uXWPpgPh5jIyxQc1deR gk6sxd2hDnTpOncnvB5nWHjegWzQgz7RpMp/+NVJvObrhFkE19E9Xtk1vRiXB6BtuLq/ QEww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ca26si23937305ejb.622.2020.12.31.19.52.56; Thu, 31 Dec 2020 19:53:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbhAADuL (ORCPT + 99 others); Thu, 31 Dec 2020 22:50:11 -0500 Received: from smtp.h3c.com ([60.191.123.50]:17289 "EHLO h3cspam02-ex.h3c.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726583AbhAADuL (ORCPT ); Thu, 31 Dec 2020 22:50:11 -0500 Received: from DAG2EX08-IDC.srv.huawei-3com.com ([10.8.0.71]) by h3cspam02-ex.h3c.com with ESMTP id 1013lxAF085853; Fri, 1 Jan 2021 11:47:59 +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; Fri, 1 Jan 2021 11:48:00 +0800 From: Gao Yan To: , , , , , CC: Gao Yan Subject: [PATCH] [v2]net:ppp: remove disc_data_lock in ppp line discipline Date: Fri, 1 Jan 2021 11:37:18 +0800 Message-ID: <20210101033718.45198-1-gao.yanB@h3c.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.99.212.201] X-ClientProxiedBy: BJSMTP01-EX.srv.huawei-3com.com (10.63.20.132) To DAG2EX08-IDC.srv.huawei-3com.com (10.8.0.71) X-DNSRBL: X-MAIL: h3cspam02-ex.h3c.com 1013lxAF085853 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Gao Yan --- drivers/net/ppp/ppp_async.c | 11 ++--------- drivers/net/ppp/ppp_synctty.c | 12 ++---------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c index 29a0917a8..20b50facd 100644 --- a/drivers/net/ppp/ppp_async.c +++ b/drivers/net/ppp/ppp_async.c @@ -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; diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c index 0f338752c..53fb68e29 100644 --- a/drivers/net/ppp/ppp_synctty.c +++ b/drivers/net/ppp/ppp_synctty.c @@ -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; -- 2.17.1