Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6464933rwb; Mon, 5 Dec 2022 12:45:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6VI14HyvuXztagspyxTaBOR1Ed3CqSCPu2JXNlNkgErfhvUCctdyI3W3r3SvK71JqDq1HS X-Received: by 2002:a05:6402:3c9:b0:46a:b56d:92d with SMTP id t9-20020a05640203c900b0046ab56d092dmr44413028edw.336.1670273149114; Mon, 05 Dec 2022 12:45:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670273149; cv=none; d=google.com; s=arc-20160816; b=x1526KMFNLrobzw8rv9dt5v9/xQpPBBx68tSJMNemQ0oZWCyzL2lViMPacsvUs6nLL NiwO8qNnJTPNEVqgXVoYQWxH47eGfxRR7njq8OpMMvkBH9uHcQXnsMieEaX4q6lKmNQr 257W3gb04tQsWjxMR5yfeCwBN58uhwt6DZb+0GnQUgkbKS1BBizeOp7C4jRH7/Cvoul/ rGGEfmBW61hyN7pQAzhGai2DK8o9PllruWSr/vIEk3x0AFz/quERIUWIQ2KsTE02K6VA wHWpOQdoOGQzJ7D06mWQfyqM6mWxVXfXHlRuaktV/XKcvVf9DCovGMiU1uRxDaNfk3Nl vpog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=t2eV37n1EV50KN4L5BF+kL5AM4qRwzFeAkejJliXYvE=; b=x+YWZw87A2qQXOkAM0C/RavIgmhTs6k6OaiqIsr84Ht29U4U8YSp2Y+72ToNEMx0Ci 1ec+UaJcwdFadC8PH9Xy/BgV0CrQwz9Q6y4xkKrHF1QGEEK9MtRJ+TZG3wD9U8LN3yRQ /12JZfuCxKngvI5c2k60D4EllQGnuVMQJKOFIztXolaK9PWZDaywuf2sSrZRQIIpPXMn HpJby31h3Qj8xcDkK7L0ogEjnbvpu/X+39ZyrhaMOC3cPFyjHWgcktG/h8Lw4UMSC2nQ FLvzcbBGolv3iaJdD5QkEYxO2d0LG8Ra+/9fWlqLyhmeQEjMH3L6Tr0ExNJFKL0RofMt 8A1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OXixcqr3; 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 sz15-20020a1709078b0f00b007ae743c61efsi10545549ejc.1002.2022.12.05.12.45.29; Mon, 05 Dec 2022 12:45:49 -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=OXixcqr3; 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 S234277AbiLETdg (ORCPT + 80 others); Mon, 5 Dec 2022 14:33:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234271AbiLETdS (ORCPT ); Mon, 5 Dec 2022 14:33:18 -0500 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBEE827FFB for ; Mon, 5 Dec 2022 11:28:16 -0800 (PST) Received: by mail-pg1-x549.google.com with SMTP id p7-20020a631e47000000b0047691854a86so10587352pgm.16 for ; Mon, 05 Dec 2022 11:28:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=t2eV37n1EV50KN4L5BF+kL5AM4qRwzFeAkejJliXYvE=; b=OXixcqr3xZZ9Hudft/Jy24A4UlcW/Yb6EPf+E30B+Y3SrNhoNoQK+pCDrL/PMBDL82 IKcAOaMUGYH18Gh0odJqUTEELnNAropoi9gMTbXzIRbC6SljHGZd+rT95xqsGFvPic/v sTqJEV88g2wzK30Nz1wYLyY6DgGQm7B8iNTPT1bVcf6ZiPyuFIGsvVEKRmmfY1gdc5xm 9MA2j56JA5130vszUlvLjOLBg1AOC0touX+NmNhzcvJ20NgsWpDoctpN+DZtaHkTWw+x l6O4Rzr7mT+phIJg/gOMUY7jYqiscVkkTUPHYdYGsO2cFfNeKeOJ/nb0kIBvUXlCC+kj Uwuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=t2eV37n1EV50KN4L5BF+kL5AM4qRwzFeAkejJliXYvE=; b=7g2Su1nlPuZHbRy06Vj3YHQXb8KG/HUtpyWU34pesW8rlUgQRQEhNkXDaIRgQZLxzl 38pUxPjqWzPY/6nYz85Xplgk3F/6EsGzPYCKBTOxG02GcQoZw638nXGgZAUZKL7ZtU/8 k2vrMHG1fb2m6cZ+CWrVFooABfNmC0CeWcIqahX+hxyC43UyqXcc2mFGZVX3YgCxIFdX k4FqQcx7wudLTYDPWwD+Ia/Cz/ZTmAENf6Q+KDzcu3lcPjkQiExHd6DJJ6n/935XUkRh qe39GOE99JQgxeNwbzmgB4disQdGn6psJxM1HqI6qvtTbNhk9sCwPiOa4d33WPhDRixL NzRw== X-Gm-Message-State: ANoB5pn26K1NrPa6YTtGLKAgZg+x+ctILBFm4OvDP4qIFHcQZQVlIXdD UGZS//xeAR/k4b2IEC8MLmn2qrset5lHqA== X-Received: from shakeelb.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:262e]) (user=shakeelb job=sendgmr) by 2002:a17:90a:c006:b0:219:158d:b19a with SMTP id p6-20020a17090ac00600b00219158db19amr51964448pjt.152.1670268496206; Mon, 05 Dec 2022 11:28:16 -0800 (PST) Date: Mon, 5 Dec 2022 19:28:14 +0000 In-Reply-To: Mime-Version: 1.0 References: Message-ID: <20221205192814.diiwtktsrgxzccw2@google.com> Subject: Re: Low TCP throughput due to vmpressure with swap enabled From: Shakeel Butt To: Johannes Weiner Cc: Ivan Babrou , Linux MM , Linux Kernel Network Developers , linux-kernel , Michal Hocko , Roman Gushchin , Muchun Song , Andrew Morton , Eric Dumazet , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Paolo Abeni , cgroups@vger.kernel.org, kernel-team Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-9.6 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_PASS,USER_IN_DEF_DKIM_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 Mon, Nov 28, 2022 at 01:07:25PM -0500, Johannes Weiner wrote: > [...] > > With the patch applied I'm capped at ~120MB/s, which is a symptom of a > > clamped window. > > > > I can't find any sockets with memcg->socket_pressure = 1, but at the > > same time I only see the following rcv_ssthresh assigned to sockets: > > Hm, I don't see how socket accounting would alter the network behavior > other than through socket_pressure=1. > I think what is happening is that the tcp stack is calling tcp_under_memory_pressure() and making decisions without going through the memcg charge codepath which set or reset memcg->socket_pressure. Most probably the socket is clamped due to memcg->socket_pressure and then the kernel never tried to grow its buffers because memcg->socket_pressure is still set and thus never tried the memcg charge codepath which would have reset memcg->socket_pressure. (Maybe) That is my guess but network experts CCed can correct me. Anyways, I don't think the pressure mechanism which relies on successful charging will work. I am brainstorming towards memory.high based network throttling. Basically use penalty_jiffies (or something similar) to set memcg->socket_pressure. However I want this to be opt-in as we do have applications which prefer to be killed than be throttled. So, still working on the fine details how this can be done without introducing a rigid API.