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=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 24F32C433ED for ; Mon, 10 May 2021 08:03:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A8B7861364 for ; Mon, 10 May 2021 08:03:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8B7861364 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CC7966B0073; Mon, 10 May 2021 04:03:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C77D96B0074; Mon, 10 May 2021 04:03:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B18A96B0075; Mon, 10 May 2021 04:03:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id 94C056B0073 for ; Mon, 10 May 2021 04:03:18 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 57CCD906D for ; Mon, 10 May 2021 08:03:18 +0000 (UTC) X-FDA: 78124581276.12.A1D5903 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by imf10.hostedemail.com (Postfix) with ESMTP id 2E254407F8DB for ; Mon, 10 May 2021 08:02:59 +0000 (UTC) IronPort-SDR: 6QPWoJKixmfbLj+jDupdE21j/DSlCdMyFTOb4VygwiLx4K7zsO5Wsn1Xp5ed/eNKEo0k5vo4cI hG458Jsq/idA== X-IronPort-AV: E=McAfee;i="6200,9189,9979"; a="197151930" X-IronPort-AV: E=Sophos;i="5.82,287,1613462400"; d="scan'208";a="197151930" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2021 01:03:12 -0700 IronPort-SDR: AN/y3RejuPlCqM6tUe4aYI6QY++WmxRRK9R505lkXc1IHP4TrsL3gOYKKXisCHC3CygmspOFLi GLFHwYqOCDXA== X-IronPort-AV: E=Sophos;i="5.82,287,1613462400"; d="scan'208";a="433704819" Received: from xingzhen-mobl.ccr.corp.intel.com (HELO [10.238.4.87]) ([10.238.4.87]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2021 01:03:08 -0700 Subject: Re: [RFC] mm/vmscan.c: avoid possible long latency caused by too_many_isolated() To: Hillf Danton Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, ying.huang@intel.com, tim.c.chen@linux.intel.com, Shakeel Butt , Michal Hocko , yuzhao@google.com, wfg@mail.ustc.edu.cn References: <20210416023536.168632-1-zhengjun.xing@linux.intel.com> <20210422102325.1332-1-hdanton@sina.com> <20210430064319.2189-1-hdanton@sina.com> From: Xing Zhengjun Message-ID: Date: Mon, 10 May 2021 16:03:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210430064319.2189-1-hdanton@sina.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=intel.com (policy=none); spf=none (imf10.hostedemail.com: domain of zhengjun.xing@linux.intel.com has no SPF policy when checking 192.55.52.120) smtp.mailfrom=zhengjun.xing@linux.intel.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2E254407F8DB X-Stat-Signature: 3boqe9fsu6gum5z3zqq4odpjf6eom99z Received-SPF: none (linux.intel.com>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=mga04.intel.com; client-ip=192.55.52.120 X-HE-DKIM-Result: none/none X-HE-Tag: 1620633779-756455 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: Hi Hillf, On 4/30/2021 2:43 PM, Hillf Danton wrote: > On Fri, 30 Apr 2021 13:33:57 +0800 Xing Zhengjun wrote: >> >> I use my compaction test case to test it, 1/10 ratio can reproduce 100ms >> sleep. >> >> 60) @ 103942.6 us | shrink_node(); >> >> 60) @ 103795.8 us | shrink_node(); > > Thanks for your test. > > In bid to cut the number of 100ms sleepers further down, add another place > for them to nap by flushing lru cache before falling in sleep, instead of > mulling why 50ms or 10ms is more adequate. > > Alternatively, and simpler IMHO, take a 5ms nap one time until !tmi. > > --- y/mm/vmscan.c > +++ x/mm/vmscan.c > @@ -118,6 +118,9 @@ struct scan_control { > /* The file pages on the current node are dangerously low */ > unsigned int file_is_tiny:1; > > + unsigned int file_tmi:1; /* too many isolated */ > + unsigned int anon_tmi:1; > + > /* Allocation order */ > s8 order; > > @@ -2092,6 +2095,22 @@ static int current_may_throttle(void) > bdi_write_congested(current->backing_dev_info); > } > > +static void set_sc_tmi(struct scan_control *sc, bool file, int tmi) > +{ > + if (file) > + sc->file_tmi = tmi; > + else > + sc->anon_tmi = tmi; > +} > + > +static bool is_sc_tmi(struct scan_control *sc, bool file) > +{ > + if (file) > + return sc->file_tmi != 0; > + else > + return sc->anon_tmi != 0; > +} > + > /* > * shrink_inactive_list() is a helper for shrink_node(). It returns the number > * of reclaimed pages > @@ -2109,11 +2128,23 @@ shrink_inactive_list(unsigned long nr_to > enum vm_event_item item; > struct pglist_data *pgdat = lruvec_pgdat(lruvec); > bool stalled = false; > + bool drained = false; > > while (unlikely(too_many_isolated(pgdat, file, sc))) { > if (stalled) > return 0; > > + if (!is_sc_tmi(sc, file)) { > + set_sc_tmi(sc, file, 1); > + return 0; > + } > + > + if (!drained) { > + drained = true; > + lru_add_drain_all(); > + continue; > + } > + > /* wait a bit for the reclaimer. */ > msleep(100); > stalled = true; > @@ -2123,6 +2154,9 @@ shrink_inactive_list(unsigned long nr_to > return SWAP_CLUSTER_MAX; > } > > + if (is_sc_tmi(sc, file)) > + set_sc_tmi(sc, file, 0); > + > lru_add_drain(); > > spin_lock_irq(&lruvec->lru_lock); > I tried the patch, it still can reproduce the 100ms sleep. 52) @ 103829.8 us | shrink_lruvec(); -- Zhengjun Xing