From patchwork Tue May 30 11:40:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abel Wu X-Patchwork-Id: 13259792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0FF9C7EE23 for ; Tue, 30 May 2023 11:40:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 33A086B0072; Tue, 30 May 2023 07:40:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2EAA7900002; Tue, 30 May 2023 07:40:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B1316B0075; Tue, 30 May 2023 07:40:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 08E606B0072 for ; Tue, 30 May 2023 07:40:32 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BD25916013D for ; Tue, 30 May 2023 11:40:31 +0000 (UTC) X-FDA: 80846728662.13.6AFE00E Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 3BCA9140007 for ; Tue, 30 May 2023 11:40:28 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=WsDOY9jQ; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf09.hostedemail.com: domain of wuyun.abel@bytedance.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=wuyun.abel@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685446829; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=JO+xdar3MejOJZdKmBkA9ihZEhu1lJTvdVxsMRKinbc=; b=tEhrdnLB6vYnOWPafT/WPBVliDrDUMwHXwH2zPzCdhl2x636iFe6lC5Gxzn1ttIAzLCWTo Goi9UiYXRHAV8yFyhmSX+xkVKStftw2PJDlITfDiroe67W60zPEaOMN0rPN6DJUlz4ubcc JxWXCmAzpddwDdLLSvjgtFtjLZwDFcA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=WsDOY9jQ; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf09.hostedemail.com: domain of wuyun.abel@bytedance.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=wuyun.abel@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685446829; a=rsa-sha256; cv=none; b=0a1+Yq7gCiDEjg5dkfY+1Bb+QZ4W3rXkZ4cbe+2keqprS5qANCPkfsYEXB1cX0PQnT2X4Q iGWjuXLFaz6LiCra+7Y0H1w/zwagV3+TWOsoEdo+RNjDDldoc6i31KyfyASpUlmyAGe60k OZIKGmhnxh60o2cYBMnh/JKy50IXvPg= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-64d3bc502ddso5062151b3a.0 for ; Tue, 30 May 2023 04:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1685446827; x=1688038827; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JO+xdar3MejOJZdKmBkA9ihZEhu1lJTvdVxsMRKinbc=; b=WsDOY9jQoN7Z60/CfCewtBbx5WDKyT8UAnjmpj9OQeIMppc40tAvX12MUibOoFeC7F 1yvBEnazT7feLsOMV4EmMc7BN0meQQncwW7I8uk5n4K35FpQV1ssrM64kI8qNjo86HCU q2b3VVlCgdXlWT5ljhv4SobkdECX9a/4ycYrCXq4U/GEy8xocCxQ5uD1oj2uZquQ3me1 XgBo5tCmkqXMjg0hRKZfkVek1kAWtxJIuKw9xheE9KTLYc2oxLxe/7utv8B1FrJyg2CW 1Sn6hEVW5ZWW1PfUOx9Kpa62nIcl20BGmKkT1L1FZjER2FvJLR2KYjVryJv1rdsTTDE9 movg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685446827; x=1688038827; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JO+xdar3MejOJZdKmBkA9ihZEhu1lJTvdVxsMRKinbc=; b=YmFqzQajl9oKiVaECRQc8ZLNIsOyP8R1SxCjfeqzvxN32g1PxQRdt45fwgCDLNTjEN 9vYIGQ1iAfFI/oZU3ZLpifl/PB6LFYoCoeYOFfjC177gGNcngfN86z0pnGXLi8Tgq0TC sZn1f1Q81AYtpkdk2AyS5VY8GmkJ9W6u6TVJ2gVp3upXDxGso2S1S7J3gMMYiEWiaK8i oIx/5xL1ylvSSmlZ3O4kfWdUX/QTysu9twMHgL0y+/dVsxbO3tQL0d75iftcjnpORTMr v3JP88y9kimTBoApx7KKQGK9H+kYOpPAj1euJK/d1pXQ5nKSuTKkCf0fqqGAngC2Mro6 JaTA== X-Gm-Message-State: AC+VfDzLCboDLcNoo5kQp5mEw94N5es1PUIM4KgP9tGP18UUGa3biNwD S64uo0456jMuCnnwadgBKpuYrw== X-Google-Smtp-Source: ACHHUZ7vxE2I8AcBFyrCBnPtSDWf+89hv2cMdNzv+jUYl+x0Xx48DRjOu9QgyvfV/5n8S9vBOlxxDg== X-Received: by 2002:a05:6a20:3d85:b0:100:60f3:2975 with SMTP id s5-20020a056a203d8500b0010060f32975mr2490885pzi.4.1685446827713; Tue, 30 May 2023 04:40:27 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id j20-20020aa78dd4000000b00642ea56f06fsm1515103pfr.0.2023.05.30.04.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 04:40:27 -0700 (PDT) From: Abel Wu To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Johannes Weiner , Michal Hocko , Vladimir Davydov , Shakeel Butt , Muchun Song Cc: Simon Horman , netdev@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Abel Wu Subject: [PATCH v4 0/4] sock: Improve condition on sockmem pressure Date: Tue, 30 May 2023 19:40:07 +0800 Message-Id: <20230530114011.13368-1-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Rspamd-Queue-Id: 3BCA9140007 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 86rsp3dn5yj691s1d9ixf6pouezjp5j6 X-HE-Tag: 1685446828-303408 X-HE-Meta: U2FsdGVkX1/wqDRs9F1vCdPi3bU0e/4w4uakffKGB49DApjsps9cXebRMbf/XbwQWq1FPMk5quhs4NfAGNqMjR4AzAzorHvglbwOarFcXGkbdhD6OPucWHRjrYmsasl+FDMwYBXDhDhhK/Laz6SC/VZs109JxWqUGkL6B0RT0M21vIgp4c5858WLhaxVuspcrez3/anWODGtOtjeObRGCF3By2O8W//8iDYBD4f7s6rYDZ6TlbzWtkwHFmFD4xqhjTQ5K5c7ngR/PXH2IFujpqVIs0aLr+ORR1b3FQDjRNBD214iP9r4bWOW8IXXCQEYABjHU/Z2iUY6vBmLtBtmYUv61zUDWQXnkZcXK4DD1S2FlBALjf+1XPzlVgotyu36jcrn+FxfCeTPS75KushWuKgYUXP3gUV8Rkj4N4fUzfz0r03obre+bvRwoFgpYNyuCVbcyqne87EcWh6septnJRnQYWJ45tW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SjJ8rs02j81ni7L4kHLMQTS8IRtzpMb0rAHaPb14HmHA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently the memcg's status is also accounted into the socket's memory pressure to alleviate the memcg's memstall. But there are still cases that can be improved. Please check the patches for detailed info. v4: - Per Shakeel's suggestion, removed the patch that suppresses allocation under net-memcg pressure to avoid further keeping the senders waiting if SACKed segments get dropped from the OFO queue. v3: - Fixed some coding style issues pointed out by Simon - Fold dependency into memcg pressure func to improve readability v2: - Splited into several patches and modified commit log for better readability. - Make memcg's pressure consideration function-wide in __sk_mem_raise_allocated(). v1: https://lore.kernel.org/lkml/20230506085903.96133-1-wuyun.abel@bytedance.com/ v2: https://lore.kernel.org/lkml/20230522070122.6727-1-wuyun.abel@bytedance.com/ v3: https://lore.kernel.org/lkml/20230523094652.49411-1-wuyun.abel@bytedance.com/ Abel Wu (4): net-memcg: Fold dependency into memcg pressure cond sock: Always take memcg pressure into consideration sock: Fix misuse of sk_under_memory_pressure() sock: Remove redundant cond of memcg pressure include/linux/memcontrol.h | 2 ++ include/net/sock.h | 14 ++++++++------ include/net/tcp.h | 3 +-- net/core/sock.c | 10 ++++++++-- 4 files changed, 19 insertions(+), 10 deletions(-)