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=-4.0 required=3.0 tests=MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 3B34AC47255 for ; Mon, 11 May 2020 10:07:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0473120720 for ; Mon, 11 May 2020 10:07:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0473120720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8A61490001C; Mon, 11 May 2020 06:07:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 85653900006; Mon, 11 May 2020 06:07:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76DE590001C; Mon, 11 May 2020 06:07:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id 62515900006 for ; Mon, 11 May 2020 06:07:15 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2154F181AEF07 for ; Mon, 11 May 2020 10:07:15 +0000 (UTC) X-FDA: 76804010430.19.dog20_5c63726e5c005 X-HE-Tag: dog20_5c63726e5c005 X-Filterd-Recvd-Size: 4665 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Mon, 11 May 2020 10:07:14 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id u16so18482303wmc.5 for ; Mon, 11 May 2020 03:07:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=oS9WtyDRHWlRdyoRSU0/FnBNR13KjsZKG7jcHWkqIkU=; b=M+p6Loc4mFQ/5oup7AtjCHP93Cz3nM4P/bvP/aN17YqwgL7ZKi6Ap+pXh1+AMTJ/7a u/484W4tnbdf5Aijn6q1qJn/7Et7X4nQ/90M1I40I0SLrlctrPMfAOAz/yc1YyVMd3ah 7Nz2aIBejv0PBCmuoi9oVRu0Ms2oEH0EET8s3bQRhTVg283AaQlDH3KZWNzXYiH1K9OE XNqKoLhA3v9W+xCGH9h7XHsurFY7W1p86zQkkoJ5q4pvPucHY7rlHzLVXY4hFwECPs0J vS4TApsHpzIOgE/GC2E6vh7QCAB6UEh9GQwuHg2fBYrcdH06LPl1DHnWv56E98W6Xoh8 zDKQ== X-Gm-Message-State: AGi0PubD0Uga0IlBRWFC3e4CYtdSfwPLhvUJzxkmZ50qZ/3uMCTkykgv y9GiYR0HKNlIq8ttgnENkng= X-Google-Smtp-Source: APiQypJkwSIKemO65K6ZcN6yWG6sAWj3mdwEhFrdCFM8763O2S3TjPOdJ0Xitr7mhqHPujXKMLw3dg== X-Received: by 2002:a7b:c0cb:: with SMTP id s11mr33139486wmh.180.1589191633454; Mon, 11 May 2020 03:07:13 -0700 (PDT) Received: from localhost (ip-37-188-228-19.eurotel.cz. [37.188.228.19]) by smtp.gmail.com with ESMTPSA id m18sm10287104wru.78.2020.05.11.03.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2020 03:07:12 -0700 (PDT) Date: Mon, 11 May 2020 12:07:11 +0200 From: Michal Hocko To: Shakeel Butt Cc: Johannes Weiner , Roman Gushchin , Greg Thelen , Andrew Morton , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] memcg: effective memory.high reclaim for remote charging Message-ID: <20200511100711.GD29153@dhcp22.suse.cz> References: <20200507163301.229070-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200507163301.229070-1-shakeelb@google.com> 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 Thu 07-05-20 09:33:01, Shakeel Butt wrote: > Currently the reclaim of excessive usage over memory.high is scheduled > to run on returning to the userland. The main reason behind this > approach was simplicity i.e. always reclaim with GFP_KERNEL context. > However the underlying assumptions behind this approach are: the current > task shares the memcg hierarchy with the given memcg and the memcg of > the current task most probably will not change on return to userland. > > With the remote charging, the first assumption breaks and it allows the > usage to grow way beyond the memory.high as the reclaim and the > throttling becomes ineffective. > > This patch forces the synchronous reclaim and potentially throttling for > the callers with context that allows blocking. For unblockable callers > or whose synch high reclaim is still not successful, a high reclaim is > scheduled either to return-to-userland if current task shares the > hierarchy with the given memcg or to system work queue. > > Signed-off-by: Shakeel Butt Acked-by: Michal Hocko I would just make the early break a bit more clear. [...] > @@ -2600,8 +2596,23 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask, > schedule_work(&memcg->high_work); > break; > } > - current->memcg_nr_pages_over_high += batch; > - set_notify_resume(current); > + > + if (gfpflags_allow_blocking(gfp_mask)) > + reclaim_over_high(memcg, gfp_mask, batch); > + /* * reclaim_over_high reclaims parents up the * hierarchy so we can break out early here. */ > + if (page_counter_read(&memcg->memory) <= > + READ_ONCE(memcg->high)) > + break; > + /* > + * The above reclaim might not be able to do much. Punt > + * the high reclaim to return to userland if the current > + * task shares the hierarchy. > + */ > + if (current->mm && mm_match_cgroup(current->mm, memcg)) { > + current->memcg_nr_pages_over_high += batch; > + set_notify_resume(current); > + } else > + schedule_work(&memcg->high_work); > break; > } > } while ((memcg = parent_mem_cgroup(memcg))); > -- > 2.26.2.526.g744177e7f7-goog > -- Michal Hocko SUSE Labs