Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932849AbcLMMdD (ORCPT ); Tue, 13 Dec 2016 07:33:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:46382 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932297AbcLMMdC (ORCPT ); Tue, 13 Dec 2016 07:33:02 -0500 Subject: Re: [PATCH] mm: fadvise: avoid expensive remote LRU cache draining after FADV_DONTNEED To: Johannes Weiner References: <20161210172658.5182-1-hannes@cmpxchg.org> <5cc0eb6f-bede-a34a-522b-e30d06723ffa@suse.cz> <20161212155552.GA7148@cmpxchg.org> Cc: Andrew Morton , Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com From: Vlastimil Babka Message-ID: Date: Tue, 13 Dec 2016 13:32:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161212155552.GA7148@cmpxchg.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1384 Lines: 27 On 12/12/2016 04:55 PM, Johannes Weiner wrote: > On Mon, Dec 12, 2016 at 10:21:24AM +0100, Vlastimil Babka wrote: >> On 12/10/2016 06:26 PM, Johannes Weiner wrote: >>> When FADV_DONTNEED cannot drop all pages in the range, it observes >>> that some pages might still be on per-cpu LRU caches after recent >>> instantiation and so initiates remote calls to all CPUs to flush their >>> local caches. However, in most cases, the fadvise happens from the >>> same context that instantiated the pages, and any pre-LRU pages in the >>> specified range are most likely sitting on the local CPU's LRU cache, >>> and so in many cases this results in unnecessary remote calls, which, >>> in a loaded system, can hold up the fadvise() call significantly. >> >> Got any numbers for this part? > > I didn't record it in the extreme case we observed, unfortunately. We > had a slow-to-respond system and noticed it spending seconds in > lru_add_drain_all() after fadvise calls, and this patch came out of > thinking about the code and how we commonly call FADV_DONTNEED. > > FWIW, I wrote a silly directory tree walker/searcher that recurses > through /usr to read and FADV_DONTNEED each file it finds. On a 2 > socket 40 ht machine, over 1% is spent in lru_add_drain_all(). With > the patch, that cost is gone; the local drain cost shows at 0.09%. Thanks, worth adding to changelog :) Vlastimil