Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6338506rwb; Tue, 22 Nov 2022 11:55:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf6zzIyISp96jiD/Ye60Lb/BWAqy8qn+GeNE2Lc6sTWEcnzEaMgoThil2bJbrenOD3+hEBWW X-Received: by 2002:a17:902:7e88:b0:179:ee39:e300 with SMTP id z8-20020a1709027e8800b00179ee39e300mr5159534pla.58.1669146954300; Tue, 22 Nov 2022 11:55:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669146954; cv=none; d=google.com; s=arc-20160816; b=RKqIXSjoBlphDUbDmSnkgMUxueX4hzEjSzZ4Id9H51uE21e4BgmWDu2kxY3aEFvsec TSZ3yc2ee1oIM/eAu8cUjpY8f1lyX07EU/qI7ZvyZu1koS9E5pOqbSGMEyXDfgM4mWKT myQk7vCe6q9kip1gDNcTA7EfGscCNCsR/jI/bqb8eL3csTr3N7rl/WZsywtafKEXrF7Q 0wQ4YTfJtWartFrrME5BXDJcWhT5l+r3r69qqgoRmEZLAaYFNUzIXLpEPhziMWAq7SWq SrT8/JyRGXxY2fza/Su+Yuz2gShZAkSeFtBpJI0ETs7F35dB/hP5gcROa51vCpY1YcmB yvuw== 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=iJupukkEoGhIVTPDQgfM6MLu0R+8+aVVrcwFrJK3N0c=; b=MB6TteSuf8Y6JJU+mB/rmaX7eNROgGTAx0UZI4JW6+U0oGS0KXaRc79oBfO3mQr/TI URyTVDdlLtsR6stpZxfQPy+y+o7BlSDyKg9kUoYEq0Jh7XSlG7OTUYh3V3v4k/lSIvwK 7IaWxw9OS0UZ/oWT8k8grh636SDiQturnEa+B4+z9eA62EiK5ZYIEF0ZOR+BYfqY7Lju dOddxSuGPhsegKplNOsPJknsC3tucpIsTBYR2zIrXKtS64o42wCN3Eh4XxkVnrhCH7JE AenWAH/7XRFk6k/KP78rmhdtvwG/bFBQ3GDijQdNrA6t7Wpk1SWT/paKzv2Nhb8TEKN4 BJww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=M80awYn8; 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 v186-20020a6389c3000000b0047767ddcdcesi7185082pgd.566.2022.11.22.11.55.42; Tue, 22 Nov 2022 11:55:54 -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=M80awYn8; 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 S232341AbiKVTrD (ORCPT + 90 others); Tue, 22 Nov 2022 14:47:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232565AbiKVTqz (ORCPT ); Tue, 22 Nov 2022 14:46:55 -0500 Received: from mail-vs1-xe2a.google.com (mail-vs1-xe2a.google.com [IPv6:2607:f8b0:4864:20::e2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DD677C681 for ; Tue, 22 Nov 2022 11:46:53 -0800 (PST) Received: by mail-vs1-xe2a.google.com with SMTP id c184so9786646vsc.3 for ; Tue, 22 Nov 2022 11:46:53 -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=iJupukkEoGhIVTPDQgfM6MLu0R+8+aVVrcwFrJK3N0c=; b=M80awYn8ZIf5OKkEY2DksCS/pgDp0Vlt4QAZaq4A5dWXtc7g9jtLqRw15V+r5kecxR /g6Lj8CXkZVy7zj5+J/Cc/xEv8SWpgJ35wU15k/o0m8ZFMXBIER7TqbblSrplcRN65sR VxwfriTfukZdxbDBMuTOJFjHE2A+ElzVavRiL7FmEX7KHHkpvs3SqIsFOBqGCVKehTta ScsClvj3jyvRwzH4fXxNxd6i7CCG1ApRWrtTG2AOuJJGcKg+wVEXDN7llD2pWGD89ZY5 uSk/LGsGE/YLh9rkKe4Wi/REyuTnDjbG4DfUktJJroFAofiZ6N9GbZ/mt7hhKHw+jX0V aPsg== 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=iJupukkEoGhIVTPDQgfM6MLu0R+8+aVVrcwFrJK3N0c=; b=oyr7GXFn7brCnj+kDIAueAes8mUZasASR7TxIK7J/H0Sxa2qS0SNzjB1wjxTFsKFRY PNh2X1ZUIOTWY2MqBK/M4VzwMyYqTqIZEdr6S7HEip4WgmUsvxGkfszoUAb8WDvh3s6X 0zRgU3Gk6LkvzE9M1V/0uZ4hxa+24h6gUH+ZohJc44i1ywl9PeLuqwxjnIfnV8iqIZvY xCK5Y85SfcrknN/r1fd0zAPDGmlI/ML6kpiUZ8esUjcDb2AlJICB7BjLl1V7Gzgy5vnR qE3QBgEb+bmeJaj/WbXc8JkWlmWhtNdrWR9DvNhWzUn0udE8APK+CeRZ+ZYP7RYDRzUq RpOw== X-Gm-Message-State: ANoB5pkq1zX3eqhOnwEzfN80xeRkl+qbagLpkiRh/jIQXp+zBEJn99iM MVzICGmix+A9U5ethKy+vvBqV++MKCy4/iGTAiKNew== X-Received: by 2002:a67:c906:0:b0:3aa:f64:fbfd with SMTP id w6-20020a67c906000000b003aa0f64fbfdmr5403462vsk.15.1669146412036; Tue, 22 Nov 2022 11:46:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Yu Zhao Date: Tue, 22 Nov 2022 12:46:15 -0700 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 , Eric Dumazet , "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 Mon, Nov 21, 2022 at 5: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 am able to reproduce this issue in a VM locally on v6.1-rc6 with 8 > GiB of RAM with zram enabled. > > The setup is fairly simple: > > 1. Run the following go proxy in one cgroup (it has some memory > ballast to simulate useful memory usage): > > * https://gist.github.com/bobrik/2c1a8a19b921fefe22caac21fda1be82 > > sudo systemd-run --scope -p MemoryLimit=6G go run main.go > > 2. Run the following fio config in another cgroup to simulate mmapped > page cache usage: > > [global] > size=8g > bs=256k > iodepth=256 > direct=0 > ioengine=mmap > group_reporting > time_based > runtime=86400 > numjobs=8 > name=randread > rw=randread Is it practical for your workload to apply some madvise/fadvise hint? For the above repro, it would be fadvise_hint=1 which is mapped into MADV_RANDOM automatically. The kernel also supports MADV_SEQUENTIAL, but not POSIX_FADV_NOREUSE at the moment. We actually have similar issues but unfortunately I haven't been able to come up with any solution beyond recommending the above flags. The problem is that harvesting the accessed bit from mmapped memory is costly, and when random accesses happen fast enough, the cost of doing that prevents LRU from collecting more information to make better decisions. In a nutshell, LRU can't tell whether there is genuine memory locality with your test case. It's a very difficult problem to solve from LRU's POV. I'd like to hear more about your workloads and see whether there are workarounds other than tackling the problem head-on, if applying hints is not practical or preferrable.