Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2239778rwd; Fri, 16 Jun 2023 00:51:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NzrKGFICwsIoZ7zDZpUjehS3eKPJTmMXkRpx938EgX/imAPRiDbgJCo5/XoxeHuIkg5Qs X-Received: by 2002:a05:6a00:811:b0:658:26a8:9d9e with SMTP id m17-20020a056a00081100b0065826a89d9emr1771418pfk.29.1686901883445; Fri, 16 Jun 2023 00:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686901883; cv=none; d=google.com; s=arc-20160816; b=lY6jBgIf6PrCupYPA1L8CxIPqAxIPeOyXnzBru1BlS7lK11QvMKH1mVtxknNfHK0J3 WYjDWkIdEy7+8tLfLHzrzpiBpukxD/jy3eoo5ckOliAZSo/ZBcDUm2TIBzwsqvA3AfMO yuDJn7viqCFlUKKH4hRWcFS51svBrTSnZcm0ouDql9v+b70UhKivzGO574PXRYMMjsVp Kgkg+UUv5tP+MJW1rcmhMCeBt1KCYSD+mgT1NNjXNqJr/AdgX+DK4s9gxEjzqtm4httE R/CBvpUjb8j6DPn08d+8zOyEl1/ETayAkKaaovGezixl8LHc9leCMTyM+I98Ca6zGnnI VZ+w== 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 :content-language:references:cc:to:from:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=9nn1acQnmBrxxKtKr0fIyJP3cG1pp8tJvpkDo6e+3KI=; b=lxRkay8K62BJzVJHCNn4w0l14/bP6vReiEiFFk+LLdxSyU/I73Y029K+aw8FCCEXGQ gCTl7InDBwUz/e7R3QMyw1/o2Oq3i1+Kyvu9/RlChCwE0GTgvzGYvVFns79wAwzhBul7 dqb14b0Slutxk4FgqA840uW9jRw7j+IZQ3u2BZiVtLk3KFLs/+CtEh0Cw48ZevME2OxJ 0pfdoknW3Dpvnayl9MrIZXwtwqfSIpuf1QCb6c5dr1lS4nqsKKlLcO8L2+Ohxz6evadA onzPuQHYgmZYw1HjqLBVhMUk+l4hDvHg9e0Cafxv6WHZ1f8uWuW8A5vLpl/mZ6AA0bri w6ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=VRySI+g5; 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 n6-20020aa79846000000b0065e1ce9e90esi13714129pfq.162.2023.06.16.00.51.08; Fri, 16 Jun 2023 00:51:23 -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=VRySI+g5; 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 S229768AbjFPH2B (ORCPT + 99 others); Fri, 16 Jun 2023 03:28:01 -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-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 X-Spam-Status: No, score=-2.2 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,URIBL_BLOCKED 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 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)