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 AD0EEC4363D for ; Fri, 25 Sep 2020 14:40:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3D20521D42 for ; Fri, 25 Sep 2020 14:40:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D20521D42 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 65CEC6B005C; Fri, 25 Sep 2020 10:40:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 634966B005D; Fri, 25 Sep 2020 10:40:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 54A036B0062; Fri, 25 Sep 2020 10:40:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3F58B6B005C for ; Fri, 25 Sep 2020 10:40:06 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id ED8F9824999B for ; Fri, 25 Sep 2020 14:40:05 +0000 (UTC) X-FDA: 77301843570.09.grain86_0c0c26427168 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id CDC7F180AD801 for ; Fri, 25 Sep 2020 14:40:05 +0000 (UTC) X-HE-Tag: grain86_0c0c26427168 X-Filterd-Recvd-Size: 2816 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Fri, 25 Sep 2020 14:40:05 +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 BF407AD72; Fri, 25 Sep 2020 14:40:03 +0000 (UTC) Date: Fri, 25 Sep 2020 15:40:01 +0100 From: Mel Gorman To: Yafang Shao Cc: hannes@cmpxchg.org, mhocko@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org Subject: Re: [PATCH v2] mm, fadvise: improve the expensive remote LRU cache draining after FADV_DONTNEED Message-ID: <20200925144001.GM3117@suse.de> References: <20200923133318.14373-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20200923133318.14373-1-laoar.shao@gmail.com> 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 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? -- Mel Gorman SUSE Labs