From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC8A0EB64D7 for ; Fri, 16 Jun 2023 07:28:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244583AbjFPH2D (ORCPT ); Fri, 16 Jun 2023 03:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbjFPH16 (ORCPT ); Fri, 16 Jun 2023 03:27:58 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63C7E1FF5 for ; Fri, 16 Jun 2023 00:27:36 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1b51780bed0so3481445ad.3 for ; Fri, 16 Jun 2023 00:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1686900456; x=1689492456; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=9nn1acQnmBrxxKtKr0fIyJP3cG1pp8tJvpkDo6e+3KI=; b=VRySI+g5OyhFq3+xJSt3XxtxCawIas+z+Lic4uM27Z/udSbrXCTBXMbmW3AmwIUo/g +j64SzyuI3pM64/QBgs69XNPGhOiAnEjKd6QtJiH1liw/ezSt6iX9shVnsA95OXnchOh 9JvQ6UQRi5s4QwwA7Ua701jbMXoPDsn53P3dOg+psguoZBsLTojgzvwwyEy8UdhAuk71 ojp4elmyT5+Dm/h2WqZsUNvIm63ZHNQ2j7KP4DKglGusmxmVk8EFDp2wFt7xMuAuKHbj IRMA0WEPlxSgbgehJyNbJGm9KVDEcvEkN2yP5QuROXtcc5BpmvVpV0ZDyvA8ehpR3gUI s+ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686900456; x=1689492456; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9nn1acQnmBrxxKtKr0fIyJP3cG1pp8tJvpkDo6e+3KI=; b=Vbo0qv8AXVl5p2D+jOfKkLesKJfJWZQJCB5PVBrDm6sUtdr1aXnRBnbtmxtFHMszI8 M2MYeoumba85NPkapBSnO26LxfDTb9Ea5v0DMi9ycOTXpLt1tTotVPobzk4hahjL1I7d DLuJSP+QVavIzWJRdyfATUSsz1r8KSwsGf3y1LYJwvB4wiHyNtZNW0dDK0WmXhJ1dmCh gzQfahJlcpbXDBvkuTdMI4wnhmcVXTJ49/Bp9j8R++zBOx9VTtYoSFR9S04hiJYW+evg SnqReml0pIfVkdktQsdk5qwcmONwoD46FHLt9CSsN4iaPw+4UmuKmeHM+b5Z7kpACMig QU8w== X-Gm-Message-State: AC+VfDw6kENh1cRUJNv4i0/V7wcyqpuFfx99svbPA1mzkL4RP1BpT095 k7eT7QZiauk3MmIym2jfFW+4IQ== X-Google-Smtp-Source: ACHHUZ4Te5AMaBMV4npizDm9kAcBpyZOp8TbKLvyw8d9l0goDJOvXNEARkOTk+KEZVqTMAkytPeHmA== X-Received: by 2002:a17:902:d386:b0:1b3:f8db:6f0c with SMTP id e6-20020a170902d38600b001b3f8db6f0cmr1151225pld.58.1686900455916; Fri, 16 Jun 2023 00:27:35 -0700 (PDT) Received: from [10.254.80.225] ([139.177.225.255]) by smtp.gmail.com with ESMTPSA id d18-20020a170902ced200b001b02713a301sm10913613plg.181.2023.06.16.00.27.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Jun 2023 00:27:35 -0700 (PDT) Message-ID: <42285da4-ea80-78ca-4c71-6562170614c8@bytedance.com> Date: Fri, 16 Jun 2023 15:27:24 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [RFC PATCH net-next] sock: Propose socket.urgent for sockmem isolation From: Abel Wu To: Eric Dumazet , Shakeel Butt Cc: Tejun Heo , Christian Warloe , Wei Wang , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Andrew Morton , David Ahern , Yosry Ahmed , "Matthew Wilcox (Oracle)" , Yu Zhao , Vasily Averin , Kuniyuki Iwashima , Martin KaFai Lau , Xin Long , Jason Xing , Michal Hocko , Alexei Starovoitov , open list , "open list:NETWORKING [GENERAL]" , "open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)" , "open list:CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)" References: <20230609082712.34889-1-wuyun.abel@bytedance.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Gentle ping :) Any suggestions for memory over-committed scenario? Thanks, Abel On 6/13/23 2:46 PM, Abel Wu wrote: > On 6/9/23 5:07 PM, Eric Dumazet wrote: >> On Fri, Jun 9, 2023 at 10:28 AM Abel Wu wrote: >>> >>> This is just a PoC patch intended to resume the discussion about >>> tcpmem isolation opened by Google in LPC'22 [1]. >>> >>> We are facing the same problem that the global shared threshold can >>> cause isolation issues. Low priority jobs can hog TCP memory and >>> adversely impact higher priority jobs. What's worse is that these >>> low priority jobs usually have smaller cpu weights leading to poor >>> ability to consume rx data. >>> >>> To tackle this problem, an interface for non-root cgroup memory >>> controller named 'socket.urgent' is proposed. It determines whether >>> the sockets of this cgroup and its descendants can escape from the >>> constrains or not under global socket memory pressure. >>> >>> The 'urgent' semantics will not take effect under memcg pressure in >>> order to protect against worse memstalls, thus will be the same as >>> before without this patch. >>> >>> This proposal doesn't remove protocal's threshold as we found it >>> useful in restraining memory defragment. As aforementioned the low >>> priority jobs can hog lots of memory, which is unreclaimable and >>> unmovable, for some time due to small cpu weight. >>> >>> So in practice we allow high priority jobs with net-memcg accounting >>> enabled to escape the global constrains if the net-memcg itselt is >>> not under pressure. While for lower priority jobs, the budget will >>> be tightened as the memory usage of 'urgent' jobs increases. In this >>> way we can finally achieve: >>> >>>    - Important jobs won't be priority inversed by the background >>>      jobs in terms of socket memory pressure/limit. >>> >>>    - Global constrains are still effective, but only on non-urgent >>>      jobs, useful for admins on policy decision on defrag. >>> >>> Comments/Ideas are welcomed, thanks! >>> >> >> This seems to go in a complete opposite direction than memcg promises. >> >> Can we fix memcg, so that : >> >> Each group can use the memory it was provisioned (this includes TCP >> buffers) > > Yes, but might not be easy once memory gets over-committed (which is > common in modern data-centers). So as a tradeoff, we intend to put > harder constraint on memory allocation for low priority jobs. Or else > if every job can use its provisioned memory, than there will be more > memstalls blocking random jobs which could be the important ones. > Either way hurts performance, but the difference is whose performance > gets hurt. > > Memory protection (memory.{min,low}) helps the important jobs less > affected by memstalls. But once low priority jobs use lots of kernel > memory like sockmem, the protection might become much less efficient. > >> >> Global tcp_memory can disappear (set tcp_mem to infinity)