Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965659AbbBCPA5 (ORCPT ); Tue, 3 Feb 2015 10:00:57 -0500 Received: from mail-oi0-f42.google.com ([209.85.218.42]:47550 "EHLO mail-oi0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752353AbbBCPAz (ORCPT ); Tue, 3 Feb 2015 10:00:55 -0500 MIME-Version: 1.0 In-Reply-To: <54D08F48.5030909@suse.cz> References: <1421661920-4114-1-git-send-email-vbabka@suse.cz> <20150203064941.GA9822@js1304-P5Q-DELUXE> <54D08F48.5030909@suse.cz> Date: Wed, 4 Feb 2015 00:00:55 +0900 Message-ID: Subject: Re: [RFC PATCH 0/5] compaction: changing initial position of scanners From: Joonsoo Kim To: Vlastimil Babka Cc: Joonsoo Kim , Linux Memory Management List , LKML , Andrew Morton , David Rientjes , Christoph Lameter , Mel Gorman , Michal Nazarewicz , Minchan Kim , Naoya Horiguchi , Rik van Riel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5026 Lines: 101 2015-02-03 18:05 GMT+09:00 Vlastimil Babka : > On 02/03/2015 07:49 AM, Joonsoo Kim wrote: >> On Mon, Jan 19, 2015 at 11:05:15AM +0100, Vlastimil Babka wrote: >> >> Hello, >> >> I don't have any elegant idea, but, have some humble opinion. >> >> The point is that migrate scanner should scan whole zone. >> Although your pivot approach makes some sense and it can scan whole zone, >> it could cause back and forth migration in a very short term whenever >> both scanners get toward and passed each other. > > I don't understand the scenario you suggest? The scanners don't overlap in any > single run, that doesn't change. If they meet, compaction terminates. They can > "overlap" if you compare the current run with previous run, after pivot change. Yeah, I mean this case. I think that we should regard single run as whole zone scan rather than just terminating criteria we have artificially defined and try to avoid back and forth problem as much as possible in this scale. Not overlapping in a single run you mentioned doesn't solve this problem in this scale. > The it's true that e.g. migration scanner will operate on pageblocks where the > free scanner has operated on previously. But pivot changes are only done after > the full defer cycle, which is not short term. I don't think it's not short term. After successful run, if next high order request comes immediately, migrate scanner will immediately restart at the position where previous free scanner has operated. > >> I think that if we permit >> overlap of scanner, we don't need to adhere to reverse linear scanning >> in freepage scanner since reverse liner scan doesn't prevent back and >> forth migration from now on. > > I believe that we still don't permit overlap, but anyway... > >> There are two solutions on this problem. >> One is that free scanner scans pfn in same direction where migrate scanner >> goes with having proper interval. >> >> |=========================| >> MMM==> FFF==> >> >> Enough interval guarantees to prevent back and forth migration, >> at least, in a very short period. > > That would depend on the termination criteria and what to do after restart. > You would have to terminate as soon as one scanner approaches the position where > the other started. Otherwise you overlap and migrate back in a single run. So > you terminate and that will typically mean one of the scanners did not finish > its part fully, so there are pageblocks scanned by neither one. You could adjust > the interval to find the optimal one. But you shouldn't do it immediately next > run, as that would overlap the previous run too soon. Or maybe adjust it only a > little... I don't know if that's simpler than my approach, it seems more quirky. Yeah, the idea comes from quick thought so it's not perfect. In fact, if we regard single run as whole zone scan, back and forth problem is inevitable. What we can do best is reducing bad effect of that problem. With interval, we don't try to migrate page which we immediately use for freepage in a very short period. I think that we can break relationship of free scanner and migrate scanner. It's not necessary that summation of scanned range of both scanner is whole zone. The point is migrate scanner should scan whole zone. Free scanner would adjust scanning position based on the position where migrate scanner is, whenever necessary. >> Or, we could make free scanner totally different with linear scan. >> Linear scanning to get freepage wastes much time if system memory >> is really big and most of it is used. If we takes freepage from the >> buddy, we can eliminate this scanning overhead. With additional >> logic, that is, comparing position of freepage with migrate scanner >> and selectively taking it, we can avoid back and forth migration >> in a very short period. > > I think the metric we should be looking is the ration between free pages scanned > and migrate pages scanned. It's true that after this series in the > allocate-as-thp scenario, it was more than 10 in the first run after reboot. > So maybe it could be more efficient to search the buddy lists. But then again, > when to terminate in this case? The free lists are changing continuously. And to > compare position, you also need to predict how much the migrate scanner will > progress in the single run, because you don't want to take pages from there. We can terminate when whole zone is scanned. As I mentioned above, we can't avoid back and forth problem in case of whole zone range and I'd like to do what we can do our best, avoiding back and forth in a very short term. Maybe, taking freepage positioned zone_range/2 far from with migrated scanner at that time would prevent the problem occurrence in a very short term. Thanks. -- 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/