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=-8.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 7F340C47420 for ; Mon, 28 Sep 2020 10:22:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1DCA621548 for ; Mon, 28 Sep 2020 10:22:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DCA621548 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B0B566B0062; Mon, 28 Sep 2020 06:22:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE3058E0001; Mon, 28 Sep 2020 06:22:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 937586B006C; Mon, 28 Sep 2020 06:22:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id 7F1446B0062 for ; Mon, 28 Sep 2020 06:22:57 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 4685D180AD802 for ; Mon, 28 Sep 2020 10:22:57 +0000 (UTC) X-FDA: 77312081994.09.cart77_3c11c5d27180 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 28741180AD804 for ; Mon, 28 Sep 2020 10:22:57 +0000 (UTC) X-HE-Tag: cart77_3c11c5d27180 X-Filterd-Recvd-Size: 3452 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Mon, 28 Sep 2020 10:22:56 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 44D80B207; Mon, 28 Sep 2020 10:22:55 +0000 (UTC) Date: Mon, 28 Sep 2020 11:22:53 +0100 From: Mel Gorman To: Yafang Shao Cc: Johannes Weiner , Michal Hocko , Andrew Morton , Linux MM Subject: Re: [PATCH v2] mm, fadvise: improve the expensive remote LRU cache draining after FADV_DONTNEED Message-ID: <20200928102253.GA3165@suse.de> References: <20200923133318.14373-1-laoar.shao@gmail.com> <20200925144001.GM3117@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 Sun, Sep 27, 2020 at 12:22:16PM +0800, Yafang Shao wrote: > On Fri, Sep 25, 2020 at 10:40 PM Mel Gorman wrote: > > > > On Wed, Sep 23, 2020 at 09:33:18PM +0800, Yafang Shao wrote: > > > Our users reported that there're some random latency spikes when their RT > > > process is running. Finally we found that latency spike is caused by > > > FADV_DONTNEED. Which may call lru_add_drain_all() to drain LRU cache on > > > remote CPUs, and then waits the per-cpu work to complete. The wait time > > > is uncertain, which may be tens millisecond. > > > That behavior is unreasonable, because this process is bound to a > > > specific CPU and the file is only accessed by itself, IOW, there should > > > be no pagecache pages on a per-cpu pagevec of a remote CPU. That > > > unreasonable behavior is partially caused by the wrong comparation of the > > > number of invalidated pages and the number of the target. For example, > > > if (count < (end_index - start_index + 1)) > > > The count above is how many pages were invalidated in the local CPU, and > > > (end_index - start_index + 1) is how many pages should be invalidated. > > > The usage of (end_index - start_index + 1) is incorrect, because they > > > are virtual addresses, which may not mapped to pages. Besides that, > > > there may be holes between start and end. So we'd better check whether > > > there are still pages on per-cpu pagevec after drain the local cpu, and > > > then decide whether or not to call lru_add_drain_all(). > > > > > > After I applied it with a hotfix to our production environment, most of > > > the lru_add_drain_all() can be avoided. > > > > > > Suggested-by: Mel Gorman > > > Signed-off-by: Yafang Shao > > > Cc: Mel Gorman > > > Cc: Johannes Weiner > > > > I think that's ok. Does it succeed with the original test case from the > > commit that introduced the behaviour and one modified to truncate part > > of the mapping? > > > > Yes, I verified the test case in commit 67d46b296a1b and then modified > it with truncate. > Both works fine. > In that case Acked-by: Mel Gorman -- Mel Gorman SUSE Labs