From mboxrd@z Thu Jan 1 00:00:00 1970 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 8221FC4332F for ; Thu, 20 Jan 2022 17:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbiATRag (ORCPT ); Thu, 20 Jan 2022 12:30:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230382AbiATRaF (ORCPT ); Thu, 20 Jan 2022 12:30:05 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C1E4C06173F for ; Thu, 20 Jan 2022 09:30:04 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id t18so5709304plg.9 for ; Thu, 20 Jan 2022 09:30:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nWuQlNh1+FFK77BDf2dM2joOBNRuxhXU9eZ1lL6RJ9U=; b=Vt1BML/8C1w1Q+B4uH6TEBe5Bp0XbsvPs4rQ6vDbh4AQAMJsx6vpR/THGjnP986NTs 4d1TEV4riAkWtTWI+l1jErkyQaKUeVe8WtypsjRoeZgbZXQIZ+pX7nRZnQ7iTfTU9B2y BtUyTG8OcdTCpFbU/VnEt3Wh9cjUEYvkCPXzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nWuQlNh1+FFK77BDf2dM2joOBNRuxhXU9eZ1lL6RJ9U=; b=1/SQEJOLacF+MRty2uujzKfncgJmiB2ogwYfS38EdWopVw6NUCWzCBiiArXntGUZR6 UxirJ5Ba+Y6C6v96oe+gdUf/3krY2JIui2/0PHekyqKsIei4uPWTjFfZRS27xkj9cu3Z YpCrIKlrAMcWo2oPi0FL4uhPZ0BN9rgx1GYaDbXRT/kZJcLG7BTxZjKrk4n6uxGFBlmB w9OSgAZ/litNmCyvpl3ScCoGz30Q76PBNWiqEuypVopxFd17jvGMntsWr14R405l4dlN 82crtE3IHZLf5pdIlmi2oRu7jz3ivcy0TwtbphXbBQ03DxmtRUWQ881v/17Ow/dy9i7t 4Nsg== X-Gm-Message-State: AOAM531PJyRiSK58DneTTaNAnHJKX3ys217v8ZY5oS4Yqt61AUuJMlgK N33H5sCZ0OBOc2XeMoSHJoqOXA8LEkmcJvzTgeXYbw== X-Google-Smtp-Source: ABdhPJycFKl02Oq1wNGDCLiXjMub65SO5ZLEVDaIoyisqTvtciMEWjY7xyrtl1oNS1NiH4FU0GVEpBm3W0Z0Wb9yuws= X-Received: by 2002:a17:902:8208:b0:14a:c442:8ca2 with SMTP id x8-20020a170902820800b0014ac4428ca2mr27948pln.12.1642699803642; Thu, 20 Jan 2022 09:30:03 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Daniel Dao Date: Thu, 20 Jan 2022 17:29:52 +0000 Message-ID: Subject: Re: Expensive tcp_collapse with high tcp_rmem limit To: Eric Dumazet Cc: netdev , kernel-team , linux-kernel , David Miller , Jakub Kicinski , Hideaki YOSHIFUJI , Marek Majkowski Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 6, 2022 at 6:55 PM Eric Dumazet wrote: > > On Thu, Jan 6, 2022 at 10:52 AM Eric Dumazet wrote: > > > I think that you should first look if you are under some kind of attack [1] > > > > Eventually you would still have to make room, involving expensive copies. > > > > 12% of 16MB is still a lot of memory to copy. > > > > [1] Detecting an attack signature could allow you to zap the socket > > and save ~16MB of memory per flow. Sorry for the late reply, we spent more time over the past weeks to gather more data. > tid 0: rmem_alloc=16780416 sk_rcvbuf=16777216 rcv_ssthresh=2920 > tid 0: advmss=1460 wclamp=4194304 rcv_wnd=450560 > tid 0: len=3316 truesize=15808 > tid 0: len=4106 truesize=16640 > tid 0: len=3967 truesize=16512 > tid 0: len=2988 truesize=15488 > > I think that you should first look if you are under some kind of attack [1] This and indeed the majority of similar occurrences come from a websocket origin that can emit a large flow of tiny packets. As the tcp_collapse hiccups occur in a proxy node, we think that a combination of slow / unresponsive clients and the websocket traffic can trigger this. We made a workaround to clamp the websocket's rcvbuf to a smaller value and it reduces the peak latency of tcp_collapse as we no longer need to collapse up to 16MB. > What kind of NIC driver is used on your host ? We are running mlx5 > Except that you would still have to parse the linear list. Most of the time when we see a high value of tcp_collapse, the bloated skb is almost always at the top of the list. I guess the client is already unresponsive so the flow is full of bloated skbs. I would rather not having to spend too much time collapsing these skbs.