Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2146077iof; Tue, 7 Jun 2022 21:17:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv/3ReSPTQ8+KSNKBEembV0LhrwZL+SQxwAWkgi2Cit2WB2qQH1nOFLegNjF7DFM1ZgtI1 X-Received: by 2002:a17:90a:7f8d:b0:1e8:ab67:3e2 with SMTP id m13-20020a17090a7f8d00b001e8ab6703e2mr5874679pjl.214.1654661837273; Tue, 07 Jun 2022 21:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661837; cv=none; d=google.com; s=arc-20160816; b=QU/FRwHNOG0jnGgTm+e44DMrfTEooXkUCGv9mZjNedraF4aS3JsTmvJAzYStm04Nb9 haESb4kJ0Zmc2ga0rYCGFsOfjkhvPh1zk488lQJc5bp5ysokz0j2sUFBs0qJncrY/HKl PWeCTDaCn5/UI+PkSPIqRJIwNkZBDYnGgeDx1pLcve7k7YvzX/KVZbXlOUp78UYeO/Ds cXKUKfPc1LqZby0J2kZdQ9/RKhKFXzbukzw0P29b1fkrcCZDGMA8FgleMRyFo9TlTmBl eYdbCvnMCQb0JW9eOOLe7KtJfrSRHQc2YLFYdYXAHVnbTM22+gL4MwMhS0FIJwg7mOva bZSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QEH+MArj/DZyNaeX6SuS4GuZKo6DeP4gmUNG9JGqt6c=; b=gBnOmrHb5KFkYWxYJaWf4mYVsV4AQyrxWJE7MuTwHoqrfCEXcUrSVDw/Fm9JtvmJ4b f6MwNIHoMgP2uPcjtvuuNqYV8P94Ph4+8aSprqlLFG0nXrDSDXZ22kGmwprXs2tBj7JX kzhfbR3KAsbDa3EUA6gyg+tlP1axRdqGA2rRqt36+EYVW2stPkCiwE+Zc8nL8Gfj1TDy ef+Fw4aD3bBZiHoqddi7kwAu/ixR/mHC9Bsd4Qrj8KrOtGyquVUXGn18y6+OC1WyJIdi VhBjGxDDyGiB685SR28kuMtnQ27DsDZULOoMJkh6IIy4TjrifBmqeztCDQ/H0vMi1PRF pXBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AshWlgGP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id kx14-20020a17090b228e00b001e08418faecsi24213960pjb.23.2022.06.07.21.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:17:17 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AshWlgGP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E26F0230975; Tue, 7 Jun 2022 20:48:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385416AbiFGW1M (ORCPT + 99 others); Tue, 7 Jun 2022 18:27:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381542AbiFGVRv (ORCPT ); Tue, 7 Jun 2022 17:17:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAF8A14CDC4; Tue, 7 Jun 2022 11:59:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B99FD61787; Tue, 7 Jun 2022 18:59:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CADD9C385A2; Tue, 7 Jun 2022 18:59:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628347; bh=zHarHNHf1vwJOO2GNoR2a6HsIMrQOlbPbQSMOyTCg1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AshWlgGPIUa22IAuXDmqaFYeF4v23+JpLsHRnKSpLqX9GBgVRdVavNky7C3+6bOMk M/NnvWlZJdRLnEzM2bKkSzhZuWbWjsQ2ssk5FrxaCFsulOLCa0WT5q7bCGa0ewyNVw suxUayMx3qW4rz4e/tDFiwoJnkOM8r4ubWmG7ZTo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Mat Martineau , "David S. Miller" , Sasha Levin Subject: [PATCH 5.18 297/879] mptcp: optimize release_cb for the common case Date: Tue, 7 Jun 2022 18:56:55 +0200 Message-Id: <20220607165011.467418026@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Abeni [ Upstream commit 65a569b03ca832ebc93ce45a7466137e2bb62254 ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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); } -- 2.35.1