Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1805630rwd; Mon, 15 May 2023 03:22:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ54tbe1x32OnpXQ8dRue2DrZ1d52dQJF1Cyhy2xsfEAMCKSNtyFhKVMhUsw+FroZ0mZbhro X-Received: by 2002:a05:6a20:5481:b0:101:7ccd:e195 with SMTP id i1-20020a056a20548100b001017ccde195mr29403171pzk.8.1684146139638; Mon, 15 May 2023 03:22:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684146139; cv=none; d=google.com; s=arc-20160816; b=YyiKq5ZFd/4kmVE2HFPVA+W8FFNXnQMQR2iic+0Eb4fxPxSJkxQ1eb/HWBnsP7/x5q BjR+t1X24LtlecHEYyg/14J0SvLc5r+7CQ/RtL8DEVpmdTjqihRIkDjFYKR5KXjosGUz TJ5kS1TTOh1jCrHMhfMzq8OeP3i7soODS5zy+ALqkSg55pGh3q5FlxvjJiNEYerT1DS0 1zlvaq4h9wWjQoh+4x8VXHQuuxH6uFPJJLOlYwywRy9bQWLmmt3zBVGoo5B1HxpqrK18 A8SBY23m87IGDfsMqrAvkVXxtYKO3eTWDicuFPR4S/BOZOfEKVJnQf0k8tsxFqnbV79g 51/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=bVcYbGMTcnCH725Fn9H40mWDeMdYeKHUtwfwgBEqrVs=; b=n69pBEwArfK7PVn/LfjxzDUkAh9JAzGNWr+9cweDpDU4pum2bW8HggCPym5on0gMb/ FfAG5MpFY0mBkM/I7NbWWST7JoShxr49OxfWl1tb1FYjpD8PXjeGLI6oUCXinTa89R5a SgisTMfAfQc6Wb4kOrSdKh2sO5hcs7gwdphoChCPi7XiSiEotuGYj1c9uTOX5cQCt+HG Onk1Ud/zDKZV68ukIxiGDRD2gFfj4OcUbXQGtKzAH0O9xCp3CzEkX477+6BCfEILJiPo KUy7cVFLy5kWY1gWiBzR7cIiyCvq1n4lWnG/ZWvw0ZzD0oVRPaurGtjhOs/qS+xUo1UG WcUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=NUFknoKL; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a636d09000000b00524d4b572e9si15791121pgc.370.2023.05.15.03.22.07; Mon, 15 May 2023 03:22:19 -0700 (PDT) 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=@bytedance.com header.s=google header.b=NUFknoKL; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240871AbjEOKVU (ORCPT + 99 others); Mon, 15 May 2023 06:21:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241191AbjEOKUv (ORCPT ); Mon, 15 May 2023 06:20:51 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A418E49 for ; Mon, 15 May 2023 03:20:28 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1a516fb6523so117574325ad.3 for ; Mon, 15 May 2023 03:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684146028; x=1686738028; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bVcYbGMTcnCH725Fn9H40mWDeMdYeKHUtwfwgBEqrVs=; b=NUFknoKLINs0CRaF8sgFYTioxUzqdoPQbpm6deM6LbunJlP6nK3LRvmgH31/KF7rOm plxnTbhvqKVathcad8a++qW04F3Xsdw/7TrqRCTRFR4/1bCCaUmczeG5A5ybQN12bnjq ZkKTwXjnWyfiIOyqcS58NIpwUgTOXuLqLOw9Vt2fsBZ6rTRWVozrl8MYzm3WfIPnMBY3 Sc/KJ9aMkDeAFbKBP4T8L9b+29I66i0KSBuStbd9khsYdwPFDCyl41lgVQHAEfQauy5e Wm1AgkvrE4u0RyHvz8xTJQNg/oePvQ4uH09Qb5lQBahRQK7COrrAzWienBrTxgHXyXLN UEHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684146028; x=1686738028; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bVcYbGMTcnCH725Fn9H40mWDeMdYeKHUtwfwgBEqrVs=; b=ZCQ4EZIe7Uu9suqYNxH7FUJc6k2qgL65sDImXJj6u3hXHeXpLEvsLVqJ7JJZyfwo6C eFQH+3ucwKYcqXRAP8hDS8eyeX/bTHgTOBOyRxUWEElMVM1X+UT0G7Tqyk1ADKOkA2iR e9nq+qMN9sl8B+4pnN5nnDcJFUWPII0Pj/s0AacsUTp4zmvx2tW6ievDI8N7S6ip9HFj ARRaJq6Qo8KNYcsZofliipHSoLLuz4kZ4/sMenMwEMvNXIFrEP3estgdZi1k+v+cdcnj SXSBoWZC0gmU9abYquzfZC7frIA4ryMhufOZ49LLPxfhh8cTdYKCyFCo1EN7EZlkVHpR ta/w== X-Gm-Message-State: AC+VfDxDv6QNTRJ7y7Mp7HCZXvBmnBOlCz7FyWacAN7aR3AMot9ZEY2h BXj95cZC7IWuPgtDyR2i+CrxDA== X-Received: by 2002:a17:902:cec9:b0:19a:a9d8:e47f with SMTP id d9-20020a170902cec900b0019aa9d8e47fmr47490935plg.36.1684146027973; Mon, 15 May 2023 03:20:27 -0700 (PDT) Received: from [10.255.9.129] ([139.177.225.233]) by smtp.gmail.com with ESMTPSA id m12-20020a170902db0c00b001adbb8991b3sm9383747plx.89.2023.05.15.03.20.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 May 2023 03:20:27 -0700 (PDT) Message-ID: Date: Mon, 15 May 2023 18:20:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: Re: [PATCH] sock: Fix misuse of sk_under_memory_pressure() Content-Language: en-US To: Eric Dumazet Cc: Paolo Abeni , "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230506085903.96133-1-wuyun.abel@bytedance.com> <588689343dcd6c904e7fc142a001043015e5b14e.camel@redhat.com> <6b355d57-30b4-748d-87f4-d79a50fe5487@bytedance.com> From: Abel Wu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 5/15/23 3:21 PM, Eric Dumazet wrote:> > I still do not understand the patch. > > If I do not understand the patch and its changelog now in May 2023, > how will anyone understand it later > when/if a regression is investigated ? > > I repeat : > > Changelog is evasive, I do not see what practical problem you want to solve. > > > sk_has_memory_pressure() is not about memcg, simply the fact that a > proto has a non NULL memory_pressure pointer. Yes, it has nothing to do with sk_has_memory_pressure(), this accessor is removed only due to it is not used anymore after this fix. I really should have put this into a separate patch. > > I suggest that you answer these questions, and send a V2 with an > updated changelog. OK, I will. > > Again, what is the practical problem you want to solve ? > What is the behavior of the current stack that you think is a problem ? The status of global tcp_mem pressure is updated when: a) __sk_mem_raise_allocated(): enter: sk_memory_allocated(sk) > tcp_mem[1] leave: sk_memory_allocated(sk) <= tcp_mem[0] b) __sk_mem_reduce_allocated(): leave: sk_under_memory_pressure(sk) && sk_memory_allocated(sk) < tcp_mem[0] So the conditions of leaving global pressure are inconstant, which may lead to the situation that one pressured memcg prevents the global pressure from being cleared when there is indeed no global pressure, thus the global constrains are still in effect unexpectedly on the other sockets. The patch fixes this by removing the condition of net-memcg's pressure in __sk_mem_reduce_allocated(). As for the changes in __sk_mem_raise_allocated(), I don't think it is the right place to check the pressure of the @sk's memcg. That piece of code was originally only trying to be fair between all the sockets if there is global pressure. And if we really want to forbid the socket memory from being raised when the socket's memcg is in pressure, the condition should be in the first place inside this function. So I plan to split this patch into three in v2: [1/3] fix inconstant condition in __sk_mem_reduce_allocated() [2/3] remove unrelated check in __sk_mem_raise_allocated() [3/3] remove sk_has_memory_pressure() since it is no longer used Does this make sense to you? Thanks & Best, Abel