Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6228948rwb; Tue, 22 Nov 2022 10:22:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7+M10xYYLRQPdSM8Q63XK5uoAvgOunxwvp6dJlf9oS7FfKrqBEHlP2/Mzk/XYrQ0ic6WCi X-Received: by 2002:a17:90a:fe4:b0:218:721e:3e17 with SMTP id 91-20020a17090a0fe400b00218721e3e17mr27043459pjz.245.1669141334410; Tue, 22 Nov 2022 10:22:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669141334; cv=none; d=google.com; s=arc-20160816; b=szB8/wBJ5Jr4Mn5Q8B7dizX/jlFl7zvH37O0pBF8P9aRlf8TQiADRgiX/KRGKU5uGV Wb8RjL4/iVUpm5UfsogTJ2+WP8Vu77bFN/8w7n3jeHTFd8wyKfyt1e9t3m/9KBu8mn3O oAsnMXD7gsUyyHgfanv03ZDuQ+OmAplMlOHNZpRcvap5yGcfq5xuuPX/71jiMQYLgEng gol4bATgQibOUcUttud4SSjFEq6BgJNGiYMUKuesRASCdU5VoZtJPreySCXKxDX6ud6f mr/1hexflPPImMNvZGjlRmL9prkEf1aEPdgsJEcJ2PoMasncRo1lrcsGHa6eh6vq3Nz/ dniw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=uTQ93Z87A52MpnvZoEIsory772cnGzPzKryozV7ZFMk=; b=eQQRlNk8XLPSi19O4wK4LlfIKFVbVifzv/HgT+XldPVeKTzcU+Y8+uJpaxlU99Tuln dvKSciRXE4tTugO+btZbe/6RHN+C8zQW5ZcviwB/eWbH1Jdg25FUaAFMFfU54pd9UEpS PZbH7/qxHJhCJl4OYkopbZms5o+RD/svqthu1UtVSRA0jhCgWtRfx1dNKFRyGTLwhI9D v7PLdrVxPIRXBfaxckEvJsjZCh0sOneLHJt2VATYpC158SYI1MjSJxYRBdFtF23fEFjV 06elryZVu0L835zhqVvIxIOZdGJkAWfy8VF+qqtRFjALbbpA0uWm5czPN9HOaN5JCa7L a57w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=eXRoXvJR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d16-20020a631d50000000b004772ef46b5csi12114547pgm.219.2022.11.22.10.22.00; Tue, 22 Nov 2022 10:22:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=eXRoXvJR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234290AbiKVSMB (ORCPT + 90 others); Tue, 22 Nov 2022 13:12:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234463AbiKVSLx (ORCPT ); Tue, 22 Nov 2022 13:11:53 -0500 Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C62A184328 for ; Tue, 22 Nov 2022 10:11:52 -0800 (PST) Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-39451671bdfso127019777b3.10 for ; Tue, 22 Nov 2022 10:11:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=uTQ93Z87A52MpnvZoEIsory772cnGzPzKryozV7ZFMk=; b=eXRoXvJRiBCc4ufq2quAPTpY36052Qmg9ynJmmqrrDvdULqV2GyhSyyCXRtHLfReA0 UZ4uYA3R18WWgJQym+RjkpAA9QLjlQe9RkctGzZLf2CLo2m5Yjei/K0Gw+4PLUG7YH+C SieK0NVoP0S46kpu/NZHdkdeARBmklooxECdQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uTQ93Z87A52MpnvZoEIsory772cnGzPzKryozV7ZFMk=; b=RDRvdCBn/pH33jY9T9VD8SkbYtzZjw6SlUovb1sgdpTjkNQiulRasXYudQsSFE7BqP qPUYiVZyf9NUC64UD/mc1qEYT8M5mJGYVecXm1qZ6mnqzmxwhIVSqh7TrU3URk/gd2b+ HFYNeovMlncgc3grXyzia5oAl79HmMOYRkEwv8irVFiCtTqDVvd1ms+hckyAMZ/yq7mM V5lU1r389Cpcy8J4BD3sV2x2J5on5vhwRxIe70gCYE38ZyvewbtHbarO12Nr5tuxKnik wx3ia4H+IXjvXDeYY9Rh4GtchBsYIEPwgvoGLqjdalh6o0ep7BMdG/YgwKwCoBrGwVjI I8ew== X-Gm-Message-State: ANoB5pk4IRwzxCVhWAUURbfDVzcmIgklEbeDTzo549DjLNpXGWoJ1zJb +WPPPraHg9AwydcSnNnGIDZx2pJsxQhT2xurMvfXlQ== X-Received: by 2002:a81:9957:0:b0:394:c5de:d29c with SMTP id q84-20020a819957000000b00394c5ded29cmr19799527ywg.224.1669140711955; Tue, 22 Nov 2022 10:11:51 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ivan Babrou Date: Tue, 22 Nov 2022 10:11:41 -0800 Message-ID: Subject: Re: Low TCP throughput due to vmpressure with swap enabled To: Eric Dumazet Cc: Linux MM , Linux Kernel Network Developers , linux-kernel , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Paolo Abeni , cgroups@vger.kernel.org, kernel-team Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE 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 On Tue, Nov 22, 2022 at 10:01 AM Eric Dumazet wrote: > > On Mon, Nov 21, 2022 at 4:53 PM Ivan Babrou wrote: > > > > Hello, > > > > We have observed a negative TCP throughput behavior from the following commit: > > > > * 8e8ae645249b mm: memcontrol: hook up vmpressure to socket pressure > > > > It landed back in 2016 in v4.5, so it's not exactly a new issue. > > > > The crux of the issue is that in some cases with swap present the > > workload can be unfairly throttled in terms of TCP throughput. > > I guess defining 'fairness' in such a scenario is nearly impossible. > > Have you tried changing /proc/sys/net/ipv4/tcp_rmem (and/or tcp_wmem) ? > Defaults are quite conservative. Yes, our max sizes are much higher than the defaults. I don't see how it matters though. The issue is that the kernel clamps rcv_sshtrehsh at 4 x advmss. No matter how much TCP memory you end up using, the kernel will clamp based on responsiveness to memory reclaim, which in turn depends on swap presence. We're seeing it in production with tens of thousands of sockets and high max tcp_rmem and I'm able to replicate the same issue in my vm with the default sysctl values. > If for your workload you want to ensure a minimum amount of memory per > TCP socket, > that might be good enough. That's not my goal at all. We don't have a problem with TCP memory consumption. Our issue is low throughput because vmpressure() thinks that the cgroup is memory constrained when it most definitely is not.