From patchwork Tue Nov 3 19:05:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mat Martineau X-Patchwork-Id: 11878861 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=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 3CC01C388F2 for ; Tue, 3 Nov 2020 19:05:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED3DC20870 for ; Tue, 3 Nov 2020 19:05:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729633AbgKCTFl (ORCPT ); Tue, 3 Nov 2020 14:05:41 -0500 Received: from mga12.intel.com ([192.55.52.136]:49621 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727852AbgKCTFZ (ORCPT ); Tue, 3 Nov 2020 14:05:25 -0500 IronPort-SDR: Ob0mYtlqbTNvu0QS0jYsOk1unIQBFBaZnP5Xja7mh6IvVNKlElYaOHiN/TpTpcsfUV7X70tu6+ y30FOLtELA4Q== X-IronPort-AV: E=McAfee;i="6000,8403,9794"; a="148386933" X-IronPort-AV: E=Sophos;i="5.77,448,1596524400"; d="scan'208";a="148386933" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 11:05:15 -0800 IronPort-SDR: q3/HDB26es95u1b66eZ1EV19GvTVsdP6xwg1rUsgfg4IIZmkDYOiVuQJuGy1hM00cBqNpmox+P 5guHPtyECs4A== X-IronPort-AV: E=Sophos;i="5.77,448,1596524400"; d="scan'208";a="352430150" Received: from mjmartin-nuc02.amr.corp.intel.com ([10.251.18.188]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Nov 2020 11:05:14 -0800 From: Mat Martineau To: netdev@vger.kernel.org Cc: Florian Westphal , mptcp@lists.01.org, kuba@kernel.org, davem@davemloft.net, Mat Martineau Subject: [PATCH net-next v2 4/7] mptcp: split mptcp_clean_una function Date: Tue, 3 Nov 2020 11:05:06 -0800 Message-Id: <20201103190509.27416-5-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103190509.27416-1-mathew.j.martineau@linux.intel.com> References: <20201103190509.27416-1-mathew.j.martineau@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Florian Westphal mptcp_clean_una() will wake writers in case memory could be reclaimed. When called from mptcp_sendmsg the wakeup code isn't needed. Move the wakeup to a new helper and then use that from the mptcp worker. Signed-off-by: Florian Westphal Signed-off-by: Mat Martineau --- net/mptcp/protocol.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 25d12183d1ca..b84b84adc9ad 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -853,19 +853,25 @@ static void mptcp_clean_una(struct sock *sk) } out: - if (cleaned) { + if (cleaned) sk_mem_reclaim_partial(sk); +} - /* Only wake up writers if a subflow is ready */ - if (mptcp_is_writeable(msk)) { - set_bit(MPTCP_SEND_SPACE, &mptcp_sk(sk)->flags); - smp_mb__after_atomic(); +static void mptcp_clean_una_wakeup(struct sock *sk) +{ + struct mptcp_sock *msk = mptcp_sk(sk); - /* set SEND_SPACE before sk_stream_write_space clears - * NOSPACE - */ - sk_stream_write_space(sk); - } + mptcp_clean_una(sk); + + /* Only wake up writers if a subflow is ready */ + if (mptcp_is_writeable(msk)) { + set_bit(MPTCP_SEND_SPACE, &msk->flags); + smp_mb__after_atomic(); + + /* set SEND_SPACE before sk_stream_write_space clears + * NOSPACE + */ + sk_stream_write_space(sk); } } @@ -1769,7 +1775,7 @@ static void mptcp_worker(struct work_struct *work) long timeo = 0; lock_sock(sk); - mptcp_clean_una(sk); + mptcp_clean_una_wakeup(sk); mptcp_check_data_fin_ack(sk); __mptcp_flush_join_list(msk); if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))