Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2816562pxb; Mon, 18 Oct 2021 02:28:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMjlx3Fg8VCX31K3Pkw9R/jQXdkGGheN0ctovwAFIo4bW1aHcqeB9boYoRlWOF59nf29nl X-Received: by 2002:a50:9d8e:: with SMTP id w14mr42215328ede.74.1634549281323; Mon, 18 Oct 2021 02:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634549281; cv=none; d=google.com; s=arc-20160816; b=UgV2r/FtFBUSkthfgpx9fflP0TlLxzoj/go0xGM60LVotI5xDe9jJBsinJAyHCSIyx 7qGVdJFJTMJ+PMrfvYLtifnmrRGQcVTK4eGmn5rPfYhRK0LlT8bWT51QxUOV7C3+VwKG zlC333h1clprWO1EMhrjxBQGtM/e8ZXEy8SvjqVbQGeDsOof1H3QMdpBlvw4vqBFDXwp 1Y5gZaniKp2l4lrbaeHKxFYHGQkueCmeX1utAX+Hrwn3r3J/7zPnAcv1lCQqRRw8eJFf skKBxzDstjWp1Kigfbl9nRfdi+yvCLYKlufd7EodvKZndQ++jnSVvco+V40PHqfOqSSD +X+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=c6G1gDX0KodcT+B+IPaHcSNxCrI3CJV8Wo022zcTGwY=; b=XjXJC6E5fVHU/OL7RQobGt5DdUX2w93P7+0uVDqz9AtL10rnymdy6YGcUPg6GmP+X2 x1OvP5LLy1U2rYtqHwpEOCXhy6RyCkjr0mng3Pr9Sh7U+7VaYelPA6MTfCcZfcNCbDQw +AWow1xhlMGWrNgHxOCol9khygatKzDzDFpqDeXXqXreSsa7KByEoDApXQAQHq58+/TG qXWcDbuN2dCuwQjxWL5W1TcyTJ9k29blbXkBbkGULE2TgWeeA+xEfPbm41gVlEe6VLu2 wYmMAmNRuk2WM6HvJQ6Zdk+so0xw7TV3Buy7KPw6+UjsQRuBxj3VGcXBsUKNhfOeZAV6 FYEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ra8WWSoz; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t29si20466914edc.27.2021.10.18.02.27.36; Mon, 18 Oct 2021 02:28:01 -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=@gmail.com header.s=20210112 header.b=Ra8WWSoz; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231400AbhJRJ15 (ORCPT + 99 others); Mon, 18 Oct 2021 05:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbhJRJ14 (ORCPT ); Mon, 18 Oct 2021 05:27:56 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E89F0C06161C for ; Mon, 18 Oct 2021 02:25:45 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id z15so9848986qvj.7 for ; Mon, 18 Oct 2021 02:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c6G1gDX0KodcT+B+IPaHcSNxCrI3CJV8Wo022zcTGwY=; b=Ra8WWSozEac0AuCeiOFrRWfgnppu7WS7DGNDykXOGxBpKM1P9lpzj0zeBRV+r8AAXB VGFTxH9IKRhNmKZgsKGUGsI4txUCjgu86skcnWNDN64otXTKjqx4Ta1sQLN/1RkeCTzc Tppdw1eP+rBA3NZd+OXQvPCaij5XrGSslvH+uETiD3fOUgfVgaSuYFvs2Pi++HKuQW+q wKmrS0UQqrxBPXfs6z3YrRDkdwuSVYUDsvwMIO/lhJJpvU0/zng4eenKIGRd8gxd111B Wv1HcmygVlSROQEImkNou0WL06hWkltfwj7XsuvTIKxCI+Nk6APl0idJq/Dc2y/I5W9D YfYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=c6G1gDX0KodcT+B+IPaHcSNxCrI3CJV8Wo022zcTGwY=; b=QohUyBJ1mkhYLAvQ3BRXxppfXUFxQJ9ots4wXFK9CHLdgN/PpKszyLIcsW+6mQNa6V xmqUl52IQ11t/jaqS2z83RcrC6a+y76EbV2BH6gKjpwnfcpEiKDunOW7SWneZTqCVzVm wEjKLDeB+sVDEhtW/1BcnrwYJ76QUkPo8OGqjaT//s9ffC5iNSFPruiShzZLF/IS5Ymj rQdVw+d2q7gYrzKF8Tb/+hukFF/6Ovjlkg7IbGbDokEMfkgaV+sZRbh4Q2+DMyS6bPy8 KafRDHjcst4IOie+IjBBgPgxEBXFzkutYzjjN1j7QkgGEsNC38GyVHT7yL4DCebql2g7 f5gA== X-Gm-Message-State: AOAM533xqvr97KCM/sgxb1rXXPASAZ8GOGaZeUBF6VVwHfEXcuGexmJZ EZol/u/llKH4t2nyDxEAIvYnTQYkoiy//FAwnfY= X-Received: by 2002:ad4:5621:: with SMTP id cb1mr24448220qvb.6.1634549145111; Mon, 18 Oct 2021 02:25:45 -0700 (PDT) MIME-Version: 1.0 References: <1634278529-16983-1-git-send-email-huangzhaoyang@gmail.com> In-Reply-To: From: Zhaoyang Huang Date: Mon, 18 Oct 2021 17:25:23 +0800 Message-ID: Subject: Re: [PATCH] mm: skip current when memcg reclaim To: Michal Hocko Cc: Andrew Morton , Johannes Weiner , Vladimir Davydov , Zhaoyang Huang , "open list:MEMORY MANAGEMENT" , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 18, 2021 at 4:23 PM Michal Hocko wrote: > > On Fri 15-10-21 14:15:29, Huangzhaoyang wrote: > > From: Zhaoyang Huang > > > > Sibling thread of the same process could refault the reclaimed pages > > in the same time, which would be typical in None global reclaim and > > introduce thrashing. > > It is hard to understand what kind of problem you see (ideally along > with some numbers) and how the proposed patch addresses that problem > > Also you are missing Signed-off-by tag (please have a look at > Documentation/process/submitting-patches.rst which is much more > comprehensive about the process). sorry for that, I will fix it. > > > --- > > mm/vmscan.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 5199b96..ebbdc37 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -2841,6 +2841,11 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) > > sc->memcg_low_skipped = 1; > > continue; > > } > > + /* > > + * Don't bother current when its memcg is below low > > + */ > > + if (get_mem_cgroup_from_mm(current->mm) == memcg) > > + continue; > > This code is executed when none of memcg in the reclaimed hierarchy > could be reclaimed. Low limit is then ignored and this change is > tweaking that behavior without any description of the effect. A very > vague note about trashing would indicate that you have something like > the following > > A (hiting hard limit) > / \ > B C > > Both B and C low limit protected and current task associated with B. As > none of the two could be reclaimed due to soft protection yuu prefer to > reclaim from C as you do not want to reclaim from the current process as > that could reclaim current's working set. Correct? > > I would be really curious about more specifics of the used hierarchy. What I am facing is a typical scenario on Android, that is a big memory consuming APP(camera etc) launched while background filled by other processes. The hierarchy is like what you describe above where B represents the APP and memory.low is set to help warm restart. Both of kswapd and direct reclaim work together to reclaim pages under this scenario, which can cause 20MB file page delete from LRU in several second. This change could help to have current process's page escape from being reclaimed and cause page thrashing. We observed the result via systrace which shows that the Uninterruptible sleep(block on page bit) and iowait get smaller than usual. > > Thanks! > > > memcg_memory_event(memcg, MEMCG_LOW); > > } > > > > -- > > 1.9.1 > > -- > Michal Hocko > SUSE Labs