From patchwork Fri Apr 8 19:45:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mat Martineau X-Patchwork-Id: 12807131 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B53C9C433FE for ; Fri, 8 Apr 2022 19:46:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231958AbiDHTsS (ORCPT ); Fri, 8 Apr 2022 15:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232426AbiDHTsP (ORCPT ); Fri, 8 Apr 2022 15:48:15 -0400 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94DCE26F1 for ; Fri, 8 Apr 2022 12:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649447171; x=1680983171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zdAkC0JYrW2Pdheuu2gZ1bu45Lzie2GfL/O91yGB45o=; b=GLLwRNX0/jfvLVptDdti4FshE0XGxNmdh+R7Lz0QuHPLwYqo7qD6Dr0b x4PogMkQo+AKi5LQdNAB9ICnDeF1kYy1L6vHxpKfwF2g+vKpn73WuSn/d WfgG80HbLihBTz+1/wGGPEsbEcwFGVxgL8IskNV+SjdOusMUxohoxE6jw rsuOiFNjJ5M2ztbAtJXcDQ1D4EW2/JqI5xyM+0NiJVP9MqR2SGEIkEiZT 7bkEWHZM2CcqmAg90wZ/SsVAcDCar7FO+xqbkO3/vEiTJUvEM1Ky/Ldnb CxuxftDxzI73NV+QN/Y7kl0xI6GMhZKd4tEtJx4UsicMnFPT4ZT+ld+lC w==; X-IronPort-AV: E=McAfee;i="6400,9594,10311"; a="322365293" X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="322365293" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 12:46:09 -0700 X-IronPort-AV: E=Sophos;i="5.90,245,1643702400"; d="scan'208";a="659602147" Received: from mjmartin-desk2.amr.corp.intel.com (HELO mjmartin-desk2.intel.com) ([10.134.75.99]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2022 12:46:07 -0700 From: Mat Martineau To: netdev@vger.kernel.org Cc: Paolo Abeni , davem@davemloft.net, kuba@kernel.org, matthieu.baerts@tessares.net, mptcp@lists.linux.dev, Mat Martineau Subject: [PATCH net-next 1/8] mptcp: optimize release_cb for the common case Date: Fri, 8 Apr 2022 12:45:54 -0700 Message-Id: <20220408194601.305969-2-mathew.j.martineau@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220408194601.305969-1-mathew.j.martineau@linux.intel.com> References: <20220408194601.305969-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: Paolo Abeni The mptcp release callback checks several flags in atomic context, but only MPTCP_CLEAN_UNA can be up frequently. Reorganize the code to avoid multiple conditionals in the most common scenarios. Additional clarify a related comment. Signed-off-by: Paolo Abeni Signed-off-by: Mat Martineau --- net/mptcp/protocol.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 0cbea3b6d0a4..2a9335ce5df1 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3092,15 +3092,17 @@ static void mptcp_release_cb(struct sock *sk) spin_lock_bh(&sk->sk_lock.slock); } - /* be sure to set the current sk state before tacking actions - * depending on sk_state - */ - if (__test_and_clear_bit(MPTCP_CONNECTED, &msk->cb_flags)) - __mptcp_set_connected(sk); if (__test_and_clear_bit(MPTCP_CLEAN_UNA, &msk->cb_flags)) __mptcp_clean_una_wakeup(sk); - if (__test_and_clear_bit(MPTCP_ERROR_REPORT, &msk->cb_flags)) - __mptcp_error_report(sk); + if (unlikely(&msk->cb_flags)) { + /* be sure to set the current sk state before tacking actions + * depending on sk_state, that is processing MPTCP_ERROR_REPORT + */ + if (__test_and_clear_bit(MPTCP_CONNECTED, &msk->cb_flags)) + __mptcp_set_connected(sk); + if (__test_and_clear_bit(MPTCP_ERROR_REPORT, &msk->cb_flags)) + __mptcp_error_report(sk); + } __mptcp_update_rmem(sk); }