Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6255481rwb; Tue, 22 Nov 2022 10:44:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf4v0ovcWSXKZLYWad8U6z4N3LaSAHXR05PEC9wj0etvDwNKeJxcPsQsPXrFcvwnnItcutcX X-Received: by 2002:a17:907:2169:b0:7b8:d4fb:ca9a with SMTP id rl9-20020a170907216900b007b8d4fbca9amr2671182ejb.471.1669142659284; Tue, 22 Nov 2022 10:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669142659; cv=none; d=google.com; s=arc-20160816; b=Ah4MCsB9VqhvhO2IgLYNKo3kZZ2E9/SZK4XoOLp+7iU90phmjhG2OdyhQnELErDPe2 PAgs/rNihuMBk+j6dFkXXDUoQjBoYIDNXOnzrBOZHcQ3Z6F1ZG5pLX6G6wQpikdklHLQ tW71/nIPavZopNIqQR56NE9+LeatUwWJgoOvUrvk272AezpK5z65a5AOGwhVvcZFAoxE By9zHBIUZJ2kaMv6KNTunJ68//NJ3AdMkeIELZ4DtAZXlN45yEJKavfEKfzfmXvV7SSx XHc1Q2GMWNz8dtULr6kCzPgV/sKRgHW6WjtVULt+Gt4WWcTKk2N502odmshpgU1tbJmF kqMg== 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=WQLDoQzOOOLSeL4BW8P5dyKRJbU6yXunhkxiL7lS7JY=; b=gnW1XHHeUhOv5p9Gv8WbWgX/OG5JyBj6PX9hMiGJz3/+pNPQSN2LRE89+gaFlM5z20 SD1kC+kTlFgI+M6Kut+BUGG+xWzRq2/+ttTKCoDhXq6QxmsFMhFqLi0fsAp2wZ8K6gqZ 8Gf9cex+4OUTgW36iB7Qw79bKGkhdU4Ejp5rcXCiJw6WV1qE55Gm6CaIBDFy3+vvMxud iUCJG9vfHjl2kyb007ek2DGs0xWM6PoQDS+n/a7vXZO22z4DOhuvPJSrJvoglRyv9uMU cf6UGkmlcBXvZNxwxtgK72UY0E+Mfm6dhU6ReOk6UPD/JNqhdooN+PxQoMfDT6+3Ug0H bBrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=CDJdz0q1; 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=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a056402248c00b00459b0141076si11927210eda.465.2022.11.22.10.43.56; Tue, 22 Nov 2022 10:44:19 -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=@google.com header.s=20210112 header.b=CDJdz0q1; 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=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234421AbiKVSYG (ORCPT + 90 others); Tue, 22 Nov 2022 13:24:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232021AbiKVSYD (ORCPT ); Tue, 22 Nov 2022 13:24:03 -0500 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A88A02F3AF for ; Tue, 22 Nov 2022 10:24:00 -0800 (PST) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-3ae8df81a2bso3488197b3.0 for ; Tue, 22 Nov 2022 10:24:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WQLDoQzOOOLSeL4BW8P5dyKRJbU6yXunhkxiL7lS7JY=; b=CDJdz0q15FCrFgZ2RgOE7aoOkCnIE0qqjNfpiyaFukahYrSsxZ4fDxJsk+IKeVDOLo fTIZ884+FEiiSCjX4m/RkJvUVv/DQEsLzT8tR6MQJj/DZLHa5vYBkFxjl3a61gRXpZoj rpC2JE+T9pLyf+7khG2HYb3MmtiSv8Hc+Sqy3T0KWu28zVIJIVLhqo1hgYEx0lvQmB8o hBW6p4z3/wlIQ2VX6+WDew8PHl2O8jidBSbLv71s0dt5scFC2DINgLvjBDp/1D7ww7a/ HrKpH89edAqH8LukVTkAMdhBlxmVVkYaKernLE5kg3YAKjOaPWyPaIo0MEZmOcq1MqXj Jk+g== 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=WQLDoQzOOOLSeL4BW8P5dyKRJbU6yXunhkxiL7lS7JY=; b=is093189fsGYVWQzkrMTehhyKyLLg8tKgNlW96ZvTHBc87KESI/GpKAI9pdcMVjaqt zDUGdQSL/gKr6YycrPux5wVDGAAlcxtnCu3HjbBLWeEqjeCFAcz81H2KCKQIpg3enOYT 8vN7qA/aEedeWGOXhmJKET8KPR/wS3lofH4BjaUT7VNoOev1OrbX0SuvdloYOffijnSz Z+KxMQKUlGsHBP9bxrvS9OCPx4aL5t/2gGYQgCLBZbvL+meXfC5Vo7r6V8HQR1qoMw2K Oh4SjyD5qA5+aAi6J/mwfmxY2vxDuezsxZ0MZsxCC4fl0TYil6tyWbNxbJnduoiPoIv/ HlFQ== X-Gm-Message-State: ANoB5plUQY4AX8+yXPKAHszrlIrY6kEDTXinPRHaxqq7EsvkkfV5w8jP yn3PGNDaK9SeMowr1Wz9J43Mm6sbo4sUxCSpKquF/Q== X-Received: by 2002:a81:7cd6:0:b0:357:6958:372a with SMTP id x205-20020a817cd6000000b003576958372amr5414093ywc.255.1669141439602; Tue, 22 Nov 2022 10:23:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Eric Dumazet Date: Tue, 22 Nov 2022 10:23:48 -0800 Message-ID: Subject: Re: Low TCP throughput due to vmpressure with swap enabled To: Ivan Babrou 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=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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:11 AM Ivan Babrou wrote: > > 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. There are some places (eg tcp_clamp_window) where we have this additional condition : sk_memory_allocated(sk) < sk_prot_mem_limits(sk, 0) So I was suggesting maybe to add a similar condition to tcp_try_rmem_schedule() Then adjust tcp_rmem for your needs. 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. OK, then I will stop commenting I guess :)