Message ID | 20230530114011.13368-5-wuyun.abel@bytedance.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 EF8C3C77B73 for <linux-mm@archiver.kernel.org>; Tue, 30 May 2023 11:40:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 709C36B007B; Tue, 30 May 2023 07:40:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B9FF6B007D; Tue, 30 May 2023 07:40:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 533CF6B007E; Tue, 30 May 2023 07:40:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 448C36B007B for <linux-mm@kvack.org>; Tue, 30 May 2023 07:40:54 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id F0369120209 for <linux-mm@kvack.org>; Tue, 30 May 2023 11:40:53 +0000 (UTC) X-FDA: 80846729586.12.18E557F Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf26.hostedemail.com (Postfix) with ESMTP id 05EDD140024 for <linux-mm@kvack.org>; Tue, 30 May 2023 11:40:51 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=btr0FoS+; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf26.hostedemail.com: domain of wuyun.abel@bytedance.com designates 209.85.210.180 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=1685446852; 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:in-reply-to:references:references:dkim-signature; bh=RnVh2joarXNT9aj52CHZE7i4DFTKtYVUHBE2hndAHFM=; b=3QjWSOIa22kq2m7dgOvNHMJfyPhOZ0jpcHETiR5WomAI0K2vfcCZtnji4Q7Y7d+j0Os8JX eapi6cRF+NyoNX7zILkG4vaIm6/8Sv9ZG52ht5/Rl210+fhQsfvt9h6FhhGfuHBeZVCdwg 7KsqME8ZXco7zwqbnkosbhsuzpo0pxc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=btr0FoS+; dmarc=pass (policy=quarantine) header.from=bytedance.com; spf=pass (imf26.hostedemail.com: domain of wuyun.abel@bytedance.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=wuyun.abel@bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685446852; a=rsa-sha256; cv=none; b=IqTPYxgQ5XEf5N7wqgFXhnIhDoQvFrRGqZKpOYVG5GRBuvwRXR0UDX5SeByiqmeWW66ZOM MiIpYkaLV0XrXLP/AaCBsQks4ctGuWKBYfFvi27X1rabHfOBnSimdaETjUpwNjcaHouoiE R72xjB/DjViyHvkkaF/uw2YKAu7GqWg= Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-64d3fbb8c1cso4828380b3a.3 for <linux-mm@kvack.org>; Tue, 30 May 2023 04:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1685446851; x=1688038851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RnVh2joarXNT9aj52CHZE7i4DFTKtYVUHBE2hndAHFM=; b=btr0FoS+C6fgN8Erg41EU1t5DJZD+PGpyR8bakM6GW+5ICYCzcrthDnH/6xVPa+R/Q wG33TV1SZXTSdoEBPSuVByreJr8Gqe+O51Rrgz9Y73Q9ejyvJRjXK5eIT9djyPPlFgvb 7yjesf0wmL+VpcChkGgR+xTrD7A7FInxqIyHcX7V0kBikEvD+Gcmwvvj1tjFmu6SjTWU 1mtHFPzNab3djs/NQuIwpZKWzAqcOIj7G4B3U0h+DRCca2OlBrJX+tqBNTydDQfcbJO7 DKVs5NHggfUWPYEokBru5ocQ0Gp4jvD47OV3sXrkPMdZtcuktJf9yWqNjhJ2I4I7b8BW 09mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685446851; x=1688038851; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RnVh2joarXNT9aj52CHZE7i4DFTKtYVUHBE2hndAHFM=; b=Zk6MfDx0QuGILCee9nWYrcQPh+sqP4fBkDL/EboeyUOFJNTXupaJWzKtOgQrQSHIEz 5c1tG0voFJwV1Mvpry2XJa9Komb1yZhmqaTVxr7OCXtugXKNt5WzZKAFS7FjLXwIwnWn FziOp1VJlggJuTeEJC4Bvj+h3ITSjK+Bm7mbzPIDobZ5m3AxUXkV9AgOfGOXQ5216XCM 8hxAkrDFgbuUIjIWSqk1Q2NZDSTG8m9kEV9IuZbdkPkUDVpHN2ap4Rxsl5BnEs4n4YhZ OZTiDKyiEE2oXyPZzItVjcO25VI8lRdkxyXFI/YjeSgVamGtJfYzXURVsGI5iPKFh6uP /qXg== X-Gm-Message-State: AC+VfDzWJZaFKxMYGp8vf2qOGZbEXcK6+IPUtmSpCA6UEisySad1ffvF WDifgQnRA3xzehJuHu0nk+MUHQ== X-Google-Smtp-Source: ACHHUZ7/L6D/t8C+fhV1v7/kaE8Q+tmoGMGurwakklgYU2DF5zQp3EuB0WovCQ651Y9p7EeFL5iXhA== X-Received: by 2002:a05:6a00:b81:b0:643:5d7a:a898 with SMTP id g1-20020a056a000b8100b006435d7aa898mr2408213pfj.0.1685446850941; Tue, 30 May 2023 04:40:50 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 04:40:50 -0700 (PDT) From: Abel Wu <wuyun.abel@bytedance.com> To: "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Johannes Weiner <hannes@cmpxchg.org>, Michal Hocko <mhocko@kernel.org>, Vladimir Davydov <vdavydov.dev@gmail.com>, Shakeel Butt <shakeelb@google.com>, Muchun Song <muchun.song@linux.dev> Cc: Simon Horman <simon.horman@corigine.com>, netdev@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Abel Wu <wuyun.abel@bytedance.com> Subject: [PATCH v4 4/4] sock: Remove redundant cond of memcg pressure Date: Tue, 30 May 2023 19:40:11 +0800 Message-Id: <20230530114011.13368-5-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230530114011.13368-1-wuyun.abel@bytedance.com> References: <20230530114011.13368-1-wuyun.abel@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 05EDD140024 X-Stat-Signature: 4smpp3zjx6ejrwj4m3q8knepxo964jj7 X-HE-Tag: 1685446851-871495 X-HE-Meta: U2FsdGVkX1/Bk2tm/hmdzt4ep+Y1BIvVHHhxK+x7jzoN7Bc/aKsVSGGuWjuEbW4aLaUwJqr1BiLZeJfhBokY8HQxRFT/gjYHB8RJ3Cf2umc2Xw/WjPA/7R2oaaHS+oFgJ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v/sObpNXhYEywd7xOgMC7sKaY2RxMG8DN/AcGDaSuhZKkXjOeHx96sf6RTRivzlzxC2Zlc2nZLoeIhIdvlr36llGMuLnao+oyGxKxZjV54qJE6y0ODvwADhhMm1NoJRMO0Ev84Lld30DmsTYnFCV6568wgK3upgnNVhyTIrK7hYjalnpOLg+7l5lgDoLNJFLY9azUZ09oNrXa2ePXT56FEqT08h0VR1cxXz/u/d9sWpqg0jxRp4TDKcDelzyIp45sgUuN5Cl2fMqJbfK9DC1o= 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: <linux-mm.kvack.org> |
Series |
sock: Improve condition on sockmem pressure
|
expand
|
diff --git a/net/core/sock.c b/net/core/sock.c index 801df091e37a..86735ad2f903 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3020,9 +3020,15 @@ int __sk_mem_raise_allocated(struct sock *sk, int size, int amt, int kind) if (sk_has_memory_pressure(sk)) { u64 alloc; - if (!sk_under_memory_pressure(sk)) + if (!sk_under_global_memory_pressure(sk)) return 1; + alloc = sk_sockets_allocated_read_positive(sk); + + /* If under global pressure, allow the sockets that are below + * average memory usage to raise, trying to be fair among all + * the sockets under global constrains. + */ if (sk_prot_mem_limits(sk, 2) > alloc * sk_mem_pages(sk->sk_wmem_queued + atomic_read(&sk->sk_rmem_alloc) +
Now with the previous patch, __sk_mem_raise_allocated() considers the memory pressure of both global and the socket's memcg on a func- wide level, making the condition of memcg's pressure in question redundant. Signed-off-by: Abel Wu <wuyun.abel@bytedance.com> --- net/core/sock.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)