Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755218AbbLVWRh (ORCPT ); Tue, 22 Dec 2015 17:17:37 -0500 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34442 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751768AbbLVWRg (ORCPT ); Tue, 22 Dec 2015 17:17:36 -0500 Date: Tue, 22 Dec 2015 14:17:34 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Joonsoo Kim cc: Andrew Morton , Vlastimil Babka , Aaron Lu , Mel Gorman , Rik van Riel , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Joonsoo Kim Subject: Re: [PATCH 2/2] mm/compaction: speed up pageblock_pfn_to_page() when zone is contiguous In-Reply-To: <1450678432-16593-2-git-send-email-iamjoonsoo.kim@lge.com> Message-ID: References: <1450678432-16593-1-git-send-email-iamjoonsoo.kim@lge.com> <1450678432-16593-2-git-send-email-iamjoonsoo.kim@lge.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2327 Lines: 47 On Mon, 21 Dec 2015, Joonsoo Kim wrote: > There is a performance drop report due to hugepage allocation and in there > half of cpu time are spent on pageblock_pfn_to_page() in compaction [1]. > In that workload, compaction is triggered to make hugepage but most of > pageblocks are un-available for compaction due to pageblock type and > skip bit so compaction usually fails. Most costly operations in this case > is to find valid pageblock while scanning whole zone range. To check > if pageblock is valid to compact, valid pfn within pageblock is required > and we can obtain it by calling pageblock_pfn_to_page(). This function > checks whether pageblock is in a single zone and return valid pfn > if possible. Problem is that we need to check it every time before > scanning pageblock even if we re-visit it and this turns out to > be very expensive in this workload. > > Although we have no way to skip this pageblock check in the system > where hole exists at arbitrary position, we can use cached value for > zone continuity and just do pfn_to_page() in the system where hole doesn't > exist. This optimization considerably speeds up in above workload. > > Before vs After > Max: 1096 MB/s vs 1325 MB/s > Min: 635 MB/s 1015 MB/s > Avg: 899 MB/s 1194 MB/s > > Avg is improved by roughly 30% [2]. > Wow, ok! I'm wondering if it would be better to maintain this as a characteristic of each pageblock rather than each zone. Have you tried to introduce a couple new bits to pageblock_bits that would track (1) if a cached value makes sense and (2) if the pageblock is contiguous? On the first call to pageblock_pfn_to_page(), set the first bit, PB_cached, and set the second bit, PB_contiguous, iff it is contiguous. On subsequent calls, if PB_cached is true, then return PB_contiguous. On memory hot-add or remove (or init), clear PB_cached. What are the cases where pageblock_pfn_to_page() is used for a subset of the pageblock and the result would be problematic for compaction? I.e., do we actually care to use pageblocks that are not contiguous at all? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/