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=-11.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 4E3C0C4BA3A for ; Thu, 27 Feb 2020 02:36:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 145B124672 for ; Thu, 27 Feb 2020 02:36:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NxVZZMPH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 145B124672 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9CD376B0006; Wed, 26 Feb 2020 21:36:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 97E1B6B0007; Wed, 26 Feb 2020 21:36:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 893106B0008; Wed, 26 Feb 2020 21:36:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 6E7B26B0006 for ; Wed, 26 Feb 2020 21:36:47 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3AEE7181AEF07 for ; Thu, 27 Feb 2020 02:36:47 +0000 (UTC) X-FDA: 76534344054.29.lamp74_fc507053909 X-HE-Tag: lamp74_fc507053909 X-Filterd-Recvd-Size: 5822 Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 27 Feb 2020 02:36:46 +0000 (UTC) Received: by mail-oi1-f196.google.com with SMTP id r16so131584oie.6 for ; Wed, 26 Feb 2020 18:36:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FgDRP53fhRc849hJWqV/+PwhPD91i+668jgIHMCfsLU=; b=NxVZZMPHkldyISQkt/j9q46fqdC/fTHYg2D8rxmu3JQ5FQTpEWAnsrfAW1INOGxpeL 7h/DwX4EseSXzq8DPxsx7tT89LiU3NA/LHAN4Sx7xeCJY7jLlWu2wlI7PxFLojwfUju3 XCXCv0GNC9Xz5gwwW7M6ZQvAHCRuijZey00McNQxQ9NVe7aC2WLqdpYWQ76fRU+M2TSD fCSLoyGAnvdSsxpdtTUIC1FBt0jEnZJWNiN/eJ1V1HI2R4d3LlFZziKBBFNxThGx34jE FKNM7vbPt25+yqO0LpSs/FWkruIUFSvFAow7Xv2uEwRevRGyVVEdbZ3TS4R6adpOe9Q4 7e2Q== 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=FgDRP53fhRc849hJWqV/+PwhPD91i+668jgIHMCfsLU=; b=OtP44iBgyQnCsVNE4P+YkVOeK6YzNlwo4pZIo4iyuYpf5W316QQzBEa9W5HlyLStoz ficXa/XLVOdZy/QGo7ZQvffcotvb3XpQuhmmcC889LrRmIG9+Le8feOF1R/uo2ODB88m p73p3MAdJSARcDGGrYVScrNKNWTQqQEl0T0BS2NHDCzkrFgONKmUt4zldHiR0M3nPUXc gesYLPWnIzT9SkJ42V3MhQ1LG+MJd3TSYf2heM0/5KXMHTYtkPZuSi3+U51jWE6QRa5d WVqLfWd2ValGd87ESR6ojiQAUmgP+t9qTOzbwIQg58JNtM3FWL6PHHSF+J4RvrnH5I1g 92Ug== X-Gm-Message-State: APjAAAXYnmcCBpbeYcHALyGlxWW/GBEjCXWzds7myyoEWdzhqeuhgK2e ZHpMFXgvS0SIfDGD71k7WGe0mCa5iZ3aFQ2eH2fj1w== X-Google-Smtp-Source: APXvYqxSTajCLv39pHIuIJCvAXLQ9cYdJjHOg6fBj1Fml1OToHYqpXa6HgimPFRGsX9+cCOOLCiKuAaOHamSjyEnxZA= X-Received: by 2002:a05:6808:30d:: with SMTP id i13mr1610873oie.144.1582771005560; Wed, 26 Feb 2020 18:36:45 -0800 (PST) MIME-Version: 1.0 References: <20200219181219.54356-1-hannes@cmpxchg.org> <1bfd6ea4-f012-5778-64c6-36731e69b5ba@linux.alibaba.com> In-Reply-To: <1bfd6ea4-f012-5778-64c6-36731e69b5ba@linux.alibaba.com> From: Shakeel Butt Date: Wed, 26 Feb 2020 18:36:34 -0800 Message-ID: Subject: Re: [PATCH] mm: memcontrol: asynchronous reclaim for memory.high To: Yang Shi Cc: Johannes Weiner , Andrew Morton , Michal Hocko , Tejun Heo , Roman Gushchin , Linux MM , Cgroups , LKML , Kernel Team 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 Wed, Feb 26, 2020 at 3:59 PM Yang Shi wrote: > > > > On 2/26/20 12:25 PM, Shakeel Butt wrote: > > On Wed, Feb 19, 2020 at 10:12 AM Johannes Weiner wrote: > >> We have received regression reports from users whose workloads moved > >> into containers and subsequently encountered new latencies. For some > >> users these were a nuisance, but for some it meant missing their SLA > >> response times. We tracked those delays down to cgroup limits, which > >> inject direct reclaim stalls into the workload where previously all > >> reclaim was handled my kswapd. > >> > >> This patch adds asynchronous reclaim to the memory.high cgroup limit > >> while keeping direct reclaim as a fallback. In our testing, this > >> eliminated all direct reclaim from the affected workload. > >> > >> memory.high has a grace buffer of about 4% between when it becomes > >> exceeded and when allocating threads get throttled. We can use the > >> same buffer for the async reclaimer to operate in. If the worker > >> cannot keep up and the grace buffer is exceeded, allocating threads > >> will fall back to direct reclaim before getting throttled. > >> > >> For irq-context, there's already async memory.high enforcement. Re-use > >> that work item for all allocating contexts, but switch it to the > >> unbound workqueue so reclaim work doesn't compete with the workload. > >> The work item is per cgroup, which means the workqueue infrastructure > >> will create at maximum one worker thread per reclaiming cgroup. > >> > >> Signed-off-by: Johannes Weiner > >> --- > >> mm/memcontrol.c | 60 +++++++++++++++++++++++++++++++++++++------------ > >> mm/vmscan.c | 10 +++++++-- > > This reminds me of the per-memcg kswapd proposal from LSFMM 2018 > > (https://lwn.net/Articles/753162/). > > Thanks for bringing this up. > > > > > If I understand this correctly, the use-case is that the job instead > > of direct reclaiming (potentially in latency sensitive tasks), prefers > > a background non-latency sensitive task to do the reclaim. I am > > wondering if we can use the memory.high notification along with a new > > memcg interface (like memory.try_to_free_pages) to implement a user > > space background reclaimer. That would resolve the cpu accounting > > concerns as the user space background reclaimer can share the cpu cost > > with the task. > > Actually I'm interested how you implement userspace reclaimer. Via a new > syscall or a variant of existing syscall? > We have a per-memcg interface memory.try_to_free_pages on which user space can echo two numbers i.e. number of bytes to reclaim and a byte representing flags (I/O allowed or just reclaim zombies e.t.c). However nowadays we are just using it for zombie cleanup. Shakeel