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 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81321C2D0E2 for ; Tue, 22 Sep 2020 20:03:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2328238D6 for ; Tue, 22 Sep 2020 20:03:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gQf7T+W3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2328238D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B21AB6B0003; Tue, 22 Sep 2020 16:03:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD31B6B0055; Tue, 22 Sep 2020 16:03:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A10466B005A; Tue, 22 Sep 2020 16:03:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0032.hostedemail.com [216.40.44.32]) by kanga.kvack.org (Postfix) with ESMTP id 8CBAB6B0003 for ; Tue, 22 Sep 2020 16:03:02 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3BD0C8249980 for ; Tue, 22 Sep 2020 20:03:02 +0000 (UTC) X-FDA: 77291771004.11.rice23_0615f6127150 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 184C5180F8B80 for ; Tue, 22 Sep 2020 20:03:02 +0000 (UTC) X-HE-Tag: rice23_0615f6127150 X-Filterd-Recvd-Size: 5593 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 20:03:01 +0000 (UTC) Received: by mail-ej1-f67.google.com with SMTP id u21so24679796eja.2 for ; Tue, 22 Sep 2020 13:03:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ux/FWhUKlfKba4R9gSVXh2d9U57fEhQO969QMh4dk+k=; b=gQf7T+W348/cUa7xWPDW9mvfpBriiULeP1ZiFwI/jDSAJXi3GsqBEJgVzaZkuZ3KCN DAYlg61fYR1XNjaNGtmQGHh+hKXwEWxOJ2n9Ghee/kUzRlnQLH4Zeu/fTNenx15m6XXp FX71AJvEK80xn0Xkbrrlt/6VoGll00mpOfki/B1Ag5oQTK/iMuyJLByVfKQai4xyvfj0 6cq+Fp5kLtWHQ1iy4C4sDrTPsNplpHsgHhuCGhzzQTpVKI0kxMIqTs4NYwGmwWMehVua LE3pRNdZ19xyq6AwCiTwJBamQsck+Xhems9XXbzyJSxo7b4G4hWnCHQ+KzCpyQTnyven 0LKw== 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; bh=Ux/FWhUKlfKba4R9gSVXh2d9U57fEhQO969QMh4dk+k=; b=uDXlHPZ9Wpg9Zjfvizar84RKtsw5iankPBpsE/PYv+FFZWu38x33oYsFh08QhMsPXU f0Np0dRAgkIHPHTA0gGLaRZeGlwFScgfDS+KjEh56is0OjJhl6BHTTsaftk4QbV7Gv6u wObmTPQvlhTOKKiehfGxcm1Rw7JEAY7dwXVTEa8vrOBSuKgY1uXQMR6ucinzVvIQ1fbG XQHHFpZtAl8WiOIn97MyRib5bN408nGM+jhw80tzXwjMxDL6ugkfMmxvG6qZ4hTy1KXn 7cZ5LVg/ndYYG6+TGFNvpEJr71I2UYqT1qSWwWncrSoO7AApb9TUgLMxCbQiLtvnUEce 2C2g== X-Gm-Message-State: AOAM533Ge+vcLtsyMh1U0mhqHaV34f0ZbdKt+1GNSmttfKUx61m7lWsY XXrBXstFwNVz6ktGsMF4uJd64b1DSVj+Mu5JWdI= X-Google-Smtp-Source: ABdhPJzrukxcqBwmPMNwZEfjF9bZU4xr+6NJgA7Fjwt063EvqbKJpTcRE4M8HENKWwjen25q8n7in1Ofle1X8HiQuYQ= X-Received: by 2002:a17:906:fb8f:: with SMTP id lr15mr6669776ejb.25.1600804980354; Tue, 22 Sep 2020 13:03:00 -0700 (PDT) MIME-Version: 1.0 References: <20200909215752.1725525-1-shakeelb@google.com> <20200921163055.GQ12990@dhcp22.suse.cz> <20200922114908.GZ12990@dhcp22.suse.cz> <20200922165527.GD12990@dhcp22.suse.cz> <20200922190859.GH12990@dhcp22.suse.cz> In-Reply-To: <20200922190859.GH12990@dhcp22.suse.cz> From: Yang Shi Date: Tue, 22 Sep 2020 13:02:47 -0700 Message-ID: Subject: Re: [PATCH] memcg: introduce per-memcg reclaim interface To: Michal Hocko Cc: Shakeel Butt , Minchan Kim , Johannes Weiner , Roman Gushchin , Greg Thelen , David Rientjes , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Andrew Morton , Linux MM , Cgroups , LKML Content-Type: text/plain; charset="UTF-8" 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: On Tue, Sep 22, 2020 at 12:09 PM Michal Hocko wrote: > > On Tue 22-09-20 11:10:17, Shakeel Butt wrote: > > On Tue, Sep 22, 2020 at 9:55 AM Michal Hocko wrote: > [...] > > > Last but not least the memcg > > > background reclaim is something that should be possible without a new > > > interface. > > > > So, it comes down to adding more functionality/semantics to > > memory.high or introducing a new simple interface. I am fine with > > either of one but IMO convoluted memory.high might have a higher > > maintenance cost. > > One idea would be to schedule a background worker (which work on behalf > on the memcg) to do the high limit reclaim with high limit target as > soon as the high limit is reached. There would be one work item for each > memcg. Userspace would recheck the high limit on return to the userspace > and do the reclaim if the excess is larger than a threshold, and sleep > as the fallback. > > Excessive consumers would get throttled if the background work cannot > keep up with the charge pace and most of them would return without doing > any reclaim because there is somebody working on their behalf - and is > accounted for that. > > The semantic of high limit would be preserved IMHO because high limit is > actively throttled. Where that work is done shouldn't matter as long as > it is accounted properly and memcg cannot outsource all the work to the > rest of the system. > > Would something like that (with many details to be sorted out of course) > be feasible? This is exactly how our "per-memcg kswapd" works. The missing piece is how to account the background worker (it is a kernel work thread) properly as what we discussed before. You mentioned such work is WIP in earlier email of this thread, I think once this is done the per-memcg background worker could be supported easily. > > If we do not want to change the existing semantic of high and want a new > api then I think having another limit for the background reclaim then > that would make more sense to me. It would resemble the global reclaim > and kswapd model and something that would be easier to reason about. > Comparing to echo $N > reclaim which might mean to reclaim any number > pages around N. > -- > Michal Hocko > SUSE Labs