Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp248628rwb; Wed, 7 Dec 2022 17:29:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf6TX2e8i9qiLByAK3KXO5LqMQ15NhWouhyAU4KU1RM+k2uoDj6QktbAB+V4ywUXFeErWUk8 X-Received: by 2002:a17:90b:2801:b0:200:2069:7702 with SMTP id qb1-20020a17090b280100b0020020697702mr19873692pjb.239.1670462985391; Wed, 07 Dec 2022 17:29:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670462985; cv=none; d=google.com; s=arc-20160816; b=YbkGDkdp6rtRVyz7cd5JhGhVON77/KenpAYfbYP9mAD0CaPiS553ClYY4P2CVhOYIq UWZqPcmuYJF8C/KVdUE/XguhXf9aXN//h+ic4L86nYojxprLhsRp2w3cccYxqvVh8jQN 3mVvvv0Xynv6DrMcp8aIxexYZyI9HPD2PcKNXAohLXT3DX3y0jmCUKFA/FozsRG70dQ7 ANeSCXqqLmJotaQ4byTWybfcNcQd6FSvXHCzsXdCIhNQy8Q/DREtWa/6Cc/V+25zUIHO lMxBgCmxa3MW/tRBVoezHwGrHwwzxY4p4jPq/RyinDvIfntepzXGDPGYBwowxhhqpcOT XPIg== 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=phKzW+pnWcxpZMlO+OGC3q3KyWa3Ai371n7pkUjY42s=; b=e/I5sR3sV5qD2kuOJj9Hj1DU3DBt7vpVPfqfKpoALa8uuyzXcQIWd0eAPYacXrWgvE lgdW6Wr465L+9eZUYaqH5tgaGQxt18wIVf+JriGJAkPyoDTk4wqxilM1UmV3pIvORZGQ NOjdVNA5Xp7uy4CpS5X3ML+8PytSuLCQa7PXwQxJaQ2o2WBzksnXKUBeMBlHXcd5p98B imXQFnkBJ84kPSWWuIiTLg06s9mg5XauI1mk9TuHCbzxntg809ErKHbuDXezrM7OAj2r fn1oBwel0QFsCH/VIDDoNSMdKpnIH0VmNrjMk7p8DRHg/5DbbuubBelSE4SQJb+GdKQs NYjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=GcvzBKZH; 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 kb14-20020a17090ae7ce00b0020b2101908asi3389970pjb.16.2022.12.07.17.29.36; Wed, 07 Dec 2022 17:29:45 -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=GcvzBKZH; 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 S229717AbiLHAbl (ORCPT + 74 others); Wed, 7 Dec 2022 19:31:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiLHAbk (ORCPT ); Wed, 7 Dec 2022 19:31:40 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5312D8D64D for ; Wed, 7 Dec 2022 16:31:39 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id m2-20020a17090aab0200b002188c801f92so72613pjq.4 for ; Wed, 07 Dec 2022 16:31:39 -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=phKzW+pnWcxpZMlO+OGC3q3KyWa3Ai371n7pkUjY42s=; b=GcvzBKZHxUPcMbsMIVs11wJmblKLng4iReNp1M5ibs/jGlVOlzs8gse33hKi0r80d3 4py+w8LI+3nJYWK8ZHaSqhXB2Uiak2y9NhC7j3lJ6R1R69as73jNKJKxJH9LiwjI8e1d MetDnMkMhXBRBjs9blHiXf9td0dJKWvI6zm9E3odBEh/Q0aEDhi9QSdUDkbSJu0sBLf7 GmD67NVPCz8BOXn9qmTnJmvuIfl7OIhCFLqkKxmDFJOjrSau5U5GhJqzKYp7SqdjHIFp NH630+6SYXOZNb0eEnqgRPAuNnT0GH0bcEZ+5l/9XRUIU/cBltRovIN/r4VTIfO5+EP9 y2Cg== 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=phKzW+pnWcxpZMlO+OGC3q3KyWa3Ai371n7pkUjY42s=; b=CQ2MhzXmSc56+ZdwDi5vnujEUXV5Pj9sUM0zBYkoQ9PfvEKsmN4moZ0BEpdCAxAWaq 0NsiTekYDu/EBjUL6duGxcgo3YGFzH2bpZllyUth/EwseyvcOzbFamTRNa71q3+kvlMI zwZTd0233mRSrfSoW2Benf852M7bCXfEC8AQDVbESnWjWwpk7YmPfAN4/wpoIeIF665J VtCMVVEoxQQSpK8wDyGCqUAjFH7h4S4N/sePSlKRY704Y8sOjyqeT6SNlcK9AtEncwrn QwboCXtVpBaOLGtJi6ZbeJjTe6VX3N2ZDcnjbLFK8HU5ryDHVNVZqykH+zDpZvsvVWdL h+9Q== X-Gm-Message-State: ANoB5pl7akpbYri1KVYO3oVNcOUC9DarrDpu9gItogqmrELnmh1YllBy DlosjA7dN0aCESyZzcFsYc86sShK15eK2A== X-Received: from shakeelb.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:262e]) (user=shakeelb job=sendgmr) by 2002:a17:902:9a8a:b0:189:58a9:14a4 with SMTP id w10-20020a1709029a8a00b0018958a914a4mr65845663plp.18.1670459498810; Wed, 07 Dec 2022 16:31:38 -0800 (PST) Date: Thu, 8 Dec 2022 00:31:36 +0000 In-Reply-To: Mime-Version: 1.0 References: <20221206231049.g35ltbxbk54izrie@google.com> Message-ID: <20221208003136.fxm6msgiswl2xdac@google.com> Subject: Re: Low TCP throughput due to vmpressure with swap enabled From: Shakeel Butt To: Johannes Weiner Cc: Eric Dumazet , Ivan Babrou , Linux MM , Linux Kernel Network Developers , linux-kernel , Michal Hocko , Roman Gushchin , 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="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=ham 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 Wed, Dec 07, 2022 at 01:53:00PM +0100, Johannes Weiner wrote: [...] > > I don't mind doing that if necessary, but looking at the code I don't > see why it would be. > > The socket code sets protocol memory pressure on allocations that run > into limits, and clears pressure on allocations that succeed and > frees. Why shouldn't we do the same thing for memcg? > I think you are right. Let's go with whatever you have for now as this will reduce vmpressure dependency. However I think there are still open issues that needs to be addressed in the future: 1. Unlike TCP memory accounting, memcg has to account/charge user memory, kernel memory and tcp/netmem. So, it might make more sense to enter the pressure state in try_charge_memcg() function. This means charging of user memory or kernel memory can also put the memcg under socket pressure. 2. On RX path, the memcg charge can succeed due to GFP_ATOMIC flag. Should we reset the pressure state in that case? 3. On uncharge path, unlike network stack, should we unconditionally reset the socket pressure state? Shakeel