Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3924488pxj; Mon, 21 Jun 2021 09:29:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5er40iTdWfrVfiDNeX/zQF6ZclaSSvsn6zTf6kcSic5ugmCtjqNeiG59xW6esx36aLfTe X-Received: by 2002:aa7:c256:: with SMTP id y22mr22716342edo.177.1624292956418; Mon, 21 Jun 2021 09:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292956; cv=none; d=google.com; s=arc-20160816; b=qzlfavFSQM3Drf7yQTsK/yRzOmBIfcVmKLZkMBbCP+0dLbscHvl9CbjhcWiKv9/d4U onKTzRZHHep1QIlHMD/q8HrWwmlUCXam10EubAm+FL0TDtMkSh87obgYvRY2JEUneYt9 4X1OxhqSF6jsUsDQoPOWNMe20CigJ/p2QU+A6ctag0rPQcrQNoh6maoqyrj8fDEpIzgI cpuZcCoJ877Wqe0I+NeBhEEOaOFAzKP2hgHsHFap5D6fnWQNGRXCjlmPiDm5+T3XW6fl CU6DAtZ3nVnifOMUQlC8Ysb3RMvnLIXaSoeXXEq0iBfYd3IA4ZO1EcU6FY8cBYXHeDiT cwIg== 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=9VBEWv8s3omQcVynLc644Gygu0UnMxu3VKLsAABfpGE=; b=VaTmNMatwaO8JlyxtfbUXpn2+3jXuzvi4H9YzAjtnYdmQavavDb3IUbimkZl497irv NX1vO25xMY28RB0Q3xv+7wFkraN+3fXR4v5kOVIDBKeNAY997XwS5F+p9zLON49+9hid 5ohuh1Oy1HZIozDQzDMbg9YIpgGK7e190pOW80g4OUL0qFmuCrz/0hYkqP6YcY+9fwHd gdjHqWbbFyThRcXYN2xzhsuyqOsACbrj46mSZGR8NMk8vxO3IZ16BuMmOgVg5rnmqWyz dOVmdwKbMcizTr+19lYrXtD5IoyHVFvJ1k1ut8IzLXzefCSY15xJm2kZIonf9bQyWlSW zcaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ADcQgLIF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs7si8603626ejc.659.2021.06.21.09.28.53; Mon, 21 Jun 2021 09:29:16 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ADcQgLIF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230229AbhFUQ2K (ORCPT + 99 others); Mon, 21 Jun 2021 12:28:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:48572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232008AbhFUQ0X (ORCPT ); Mon, 21 Jun 2021 12:26:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8188561357; Mon, 21 Jun 2021 16:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292543; bh=3EUyf5iGHMyyqA/WDr7DCvI9bKPXhhjzCmrM2pstGMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ADcQgLIFV4mowQzIrou6z8lo5NyKyQ4iQryEnWmPH8MV/RRLo+Ymi2TEOIEnvnuyC VZ0uquILtwx9AT3t8wxZI8jt2vGGAQwULt3hofnwuYSwn/CWeHGmv9DASWR2fyFQ3f r9O4E5eNFAJ5cEcrG83JwAqgCboG3ESEqHrNb+Mg= 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.10 037/146] mptcp: try harder to borrow memory from subflow under pressure Date: Mon, 21 Jun 2021 18:14:27 +0200 Message-Id: <20210621154912.558647068@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paolo Abeni [ Upstream commit 72f961320d5d15bfcb26dbe3edaa3f7d25fd2c8a ] If the host is under sever memory pressure, and RX forward memory allocation for the msk fails, we try to borrow the required memory from the ingress subflow. The current attempt is a bit flaky: if skb->truesize is less than SK_MEM_QUANTUM, the ssk will not release any memory, and the next schedule will fail again. Instead, directly move the required amount of pages from the ssk to the msk, if available Fixes: 9c3f94e1681b ("mptcp: add missing memory scheduling in the rx path") 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 7832b20baac2..3ca8b359e399 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -276,11 +276,13 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk, /* try to fetch required memory from subflow */ if (!sk_rmem_schedule(sk, skb, skb->truesize)) { - if (ssk->sk_forward_alloc < skb->truesize) - goto drop; - __sk_mem_reclaim(ssk, skb->truesize); - if (!sk_rmem_schedule(sk, skb, skb->truesize)) + int amount = sk_mem_pages(skb->truesize) << SK_MEM_QUANTUM_SHIFT; + + if (ssk->sk_forward_alloc < amount) goto drop; + + ssk->sk_forward_alloc -= amount; + sk->sk_forward_alloc += amount; } /* the skb map_seq accounts for the skb offset: -- 2.30.2