Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp94213pxk; Tue, 22 Sep 2020 20:04:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypRzZjkFo9Q3aXA704A5sHSFUdnAKHaGESnPAww4BMgX4DucgIeIGdWilCJ2AdBnrmyIgu X-Received: by 2002:a17:906:b7c1:: with SMTP id fy1mr7926650ejb.342.1600830278567; Tue, 22 Sep 2020 20:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600830278; cv=none; d=google.com; s=arc-20160816; b=rSE/G2IsJElNsLZ8nkkMISatffm/IL/NF5jE99migps2U+TL9yk2kJpWT1IvSIyUPz zKqIwn91+ZxeW3SBgTnLHKmgFv6iQVJQqn7H2m9jdoUQurKEHtjstrTGYrnlHLbIWL0/ RrfKHjkS6B95WFpYgmLr7xh5WsTb2rQMN0GOrIj+GRI/6iZ3hFu1OQW0nb2iFX3heoTA i05AQuI6+DI7ezagX41Xq6i//2q4ALtcB0z27/E/gxY5g+fKEGVGkW6kXZrO0w6SVRvf WW3nvkfX2CX0WVY5bA7+LtWSF5fuTT2JfqYVX4A+1Wk6+c9s8OksonuYUyu6BTL9X4js HKXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jc8uPyWeA8lh2ZEVJXFhzEZM6SYIOAImDuM4KwfSrTg=; b=0oQOX68lo7a/lD5IBTrmqPWOWjM65EgkEhkwi3IWi69sYME2ZIH0fBEcGp625t+FZs hkDePva5FCxSOWVUzpDfXbIQ36GLn1/SmJSCfst0gO8eL8vLnAIbP2jSibUGTCB2cGYN 5OdGWYVuEV9f6AFSFhUngwoOButlFX6DY6B4utj/+svAvF+5M9T2ZZt1pc5qop0Wjzpi IGZ600OhtpsFWZ81V6fVulw3Zbns2r78bXreod+91zZ+VK5VvoqWXTA0eXsEACu/esYB rBos49zoJ1Gbsv3Sj+T25VQLg0I5bV2j+uJz5r/Q+BhcGeauBjp3LRsBF07S6UJEYsUu 0/Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=D48LKiLW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v16si11170838eds.222.2020.09.22.20.04.15; Tue, 22 Sep 2020 20:04:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=D48LKiLW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727244AbgIWClO (ORCPT + 99 others); Tue, 22 Sep 2020 22:41:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726728AbgIWClN (ORCPT ); Tue, 22 Sep 2020 22:41:13 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96E85C0613D3 for ; Tue, 22 Sep 2020 19:41:12 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id n25so15912202ljj.4 for ; Tue, 22 Sep 2020 19:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=jc8uPyWeA8lh2ZEVJXFhzEZM6SYIOAImDuM4KwfSrTg=; b=D48LKiLW724RXEbvVDcCcvfb/bjfn6Fz7yz848goAqBzaGa96OEdXkzKjJWrEmtr2B u1Ww6BlgX5m69XKUjtHN8FSlwIlBBUpYuv+Iprcmx2j45NU7WOcpX7v16h5UuMpNF38e rsVxKDi8d64KgOP8GtIFzSYqLc0BiBaOMx2UDviVVwCnG96aL140S/UQe+emedYdhZEg hLu/zoRv1FrpWJxCY41I5V0IOBitx8WcSRot3JvqOKnLgKIvj1M9XJRrffwtrDXr8TdH 22yXODro1beLbWdfHb8BQK9j1iuDsUBHVXXEoj11HOHfDNHMT70/R3FvWVOmVx7rcYUS MoMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=jc8uPyWeA8lh2ZEVJXFhzEZM6SYIOAImDuM4KwfSrTg=; b=gnaMLUZhdjfy5e/Jf+rKVu6zYW8XExCUkFf7aDELxWawNQXbuEc/jrEQ3dVo+tAIub +lkvtK1FW8gDIwNr0tZMKP43YZo/kRLvSyr2g+FrH8Y4OiKiWrDXPX5MfrX0NsX22/Ws k+UfOuZcTLg5lsv7ME3HGi9fnPs4nvTmVFMNizyAM3VYRWLIx6/flzEG66HbBcl7ECsq cQ2tsaWVe+di5ffFiFgjUeSFuzz1/8P4pwv1GGI6KoGlC0aH/oIwuTg6Zblydy7bH6Yn ZFde36fhu1cHLKKlVcmFdPfMg3djs3vnYNEogF58B9he6n3ttt6EbDH/YGGiTMYY0F92 5XzA== X-Gm-Message-State: AOAM532xtZXm+ljF6pa5URiOvBryTdxB9LM4ByyKMPLMF97fOnCC70ao iZc5Ibes426cYU0Nrnju86EdWYvhqyk3t6CTc2xOpw== X-Received: by 2002:a2e:889a:: with SMTP id k26mr2388797lji.214.1600828870825; Tue, 22 Sep 2020 19:41:10 -0700 (PDT) MIME-Version: 1.0 References: <20200921080255.15505-1-zangchunxin@bytedance.com> <20200921081200.GE12990@dhcp22.suse.cz> <20200921110505.GH12990@dhcp22.suse.cz> <20200922095136.GA9682@chrisdown.name> <20200922104252.GB9682@chrisdown.name> In-Reply-To: From: Chunxin Zang Date: Wed, 23 Sep 2020 10:40:59 +0800 Message-ID: Subject: Re: [External] Re: [PATCH] mm/memcontrol: Add the drop_cache interface for cgroup v2 To: Shakeel Butt Cc: Chris Down , Michal Hocko , Yafang Shao , Johannes Weiner , Vladimir Davydov , Andrew Morton , Tejun Heo , Li Zefan , Jonathan Corbet , Alexei Starovoitov , Daniel Borkmann , kafai@fb.com, Song Liu , Yonghong Song , andriin@fb.com, john.fastabend@gmail.com, kpsingh@chromium.org, Cgroups , linux-doc@vger.kernel.org, Linux MM , LKML , netdev , bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 23, 2020 at 3:57 AM Shakeel Butt wrote: > > On Tue, Sep 22, 2020 at 5:37 AM Chunxin Zang = wrote: > > > > On Tue, Sep 22, 2020 at 6:42 PM Chris Down wrote= : > > > > > > Chunxin Zang writes: > > > >On Tue, Sep 22, 2020 at 5:51 PM Chris Down wr= ote: > > > >> > > > >> Chunxin Zang writes: > > > >> >My usecase is that there are two types of services in one server.= They > > > >> >have difference > > > >> >priorities. Type_A has the highest priority, we need to ensure it= 's > > > >> >schedule latency=E3=80=81I/O > > > >> >latency=E3=80=81memory enough. Type_B has the lowest priority, we= expect it > > > >> >will not affect > > > >> >Type_A when executed. > > > >> >So Type_A could use memory without any limit. Type_B could use me= mory > > > >> >only when the > > > >> >memory is absolutely sufficient. But we cannot estimate how much > > > >> >memory Type_B should > > > >> >use. Because everything is dynamic. So we can't set Type_B's memo= ry.high. > > > >> > > > > >> >So we want to release the memory of Type_B when global memory is > > > >> >insufficient in order > > > >> >to ensure the quality of service of Type_A . In the past, we used= the > > > >> >'force_empty' interface > > > >> >of cgroup v1. > > > >> > > > >> This sounds like a perfect use case for memory.low on Type_A, and = it's pretty > > > >> much exactly what we invented it for. What's the problem with that= ? > > > > > > > >But we cannot estimate how much memory Type_A uses at least. > > > > > > memory.low allows ballparking, you don't have to know exactly how muc= h it uses. > > > Any amount of protection biases reclaim away from that cgroup. > > > > > > >For example: > > > >total memory: 100G > > > >At the beginning, Type_A was in an idle state, and it only used 10G = of memory. > > > >The load is very low. We want to run Type_B to avoid wasting machine= resources. > > > >When Type_B runs for a while, it used 80G of memory. > > > >At this time Type_A is busy, it needs more memory. > > > > > > Ok, so set memory.low for Type_A close to your maximum expected value= . > > > > Please forgive me for not being able to understand why setting > > memory.low for Type_A can solve the problem. > > In my scene, Type_A is the most important, so I will set 100G to memory= .low. > > But 'memory.low' only takes effect passively when the kernel is > > reclaiming memory. It means that reclaim Type_B's memory only when > > Type_A in alloc memory slow path. This will affect Type_A's > > performance. > > We want to reclaim Type_B's memory in advance when A is expected to be = busy. > > > > How will you know when to reclaim from B? Are you polling /proc/meminfo? > Monitor global memory usage through the daemon. If the memory is used 80% or 90%, it will reclaim B's memory. > From what I understand, you want to proactively reclaim from B, so > that A does not go into global reclaim and in the worst case kill B, > right? Yes, it is. > > BTW you can use memory.high to reclaim from B by setting it lower than > memory.current of B and reset it to 'max' once the reclaim is done. > Since 'B' is not high priority (I am assuming not a latency sensitive > workload), B hitting temporary memory.high should not be an issue. > Also I am assuming you don't much care about the amount of memory to > be reclaimed from B, so I think memory.high can fulfil your use-case. > However if in future you decide to proactively reclaim from all the > jobs based on their priority i.e. more aggressive reclaim from B and a > little bit reclaim from A then memory.high is not a good interface. > > Shakeel Thanks for these suggestions, I will give it a try. Best wishes Chunxin