Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759682Ab3EGVUd (ORCPT ); Tue, 7 May 2013 17:20:33 -0400 Received: from mga03.intel.com ([143.182.124.21]:59532 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758922Ab3EGVUF (ORCPT ); Tue, 7 May 2013 17:20:05 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,629,1363158000"; d="scan'208";a="238235512" Subject: [RFC][PATCH 7/7] drain batch list during long operations To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, mgorman@suse.de, tim.c.chen@linux.intel.com, Dave Hansen From: Dave Hansen Date: Tue, 07 May 2013 14:20:03 -0700 References: <20130507211954.9815F9D1@viggo.jf.intel.com> In-Reply-To: <20130507211954.9815F9D1@viggo.jf.intel.com> Message-Id: <20130507212003.7990B2F5@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2656 Lines: 70 From: Dave Hansen This was a suggestion from Mel: http://lkml.kernel.org/r/20120914085634.GM11157@csn.ul.ie Any pages we collect on 'batch_for_mapping_removal' will have their lock_page() held during the duration of their stay on the list. If some other user is trying to get at them during this time, they might end up having to wait for a while, especially if we go off and do pageout() on some other page. This ensures that we drain the batch if we are about to perform a writeout. I added some statistics to the __remove_mapping_batch() code to track how large the lists are that we pass in to it. With this patch, the average list length drops about 10% (from about 4.1 to 3.8). The workload here was a make -j4 kernel compile on a VM with 200MB of RAM. I've still got the statistics patch around if anyone is interested. Signed-off-by: Dave Hansen --- linux.git-davehans/kernel/sched/fair.c | 2 ++ linux.git-davehans/mm/vmscan.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff -puN kernel/sched/fair.c~drain-batch-list-during-long-operations kernel/sched/fair.c --- linux.git/kernel/sched/fair.c~drain-batch-list-during-long-operations 2013-05-07 13:48:15.267113941 -0700 +++ linux.git-davehans/kernel/sched/fair.c 2013-05-07 13:48:15.275114295 -0700 @@ -5211,6 +5211,8 @@ more_balance: if (sd->balance_interval < sd->max_interval) sd->balance_interval *= 2; } + //if (printk_ratelimit()) + // printk("sd->balance_interval: %d\n", sd->balance_interval); goto out; diff -puN mm/vmscan.c~drain-batch-list-during-long-operations mm/vmscan.c --- linux.git/mm/vmscan.c~drain-batch-list-during-long-operations 2013-05-07 13:48:15.268113985 -0700 +++ linux.git-davehans/mm/vmscan.c 2013-05-07 13:48:15.272114163 -0700 @@ -936,6 +936,16 @@ static unsigned long shrink_page_list(st if (!sc->may_writepage) goto keep_locked; + /* + * We hold a bunch of page locks on the batch. + * pageout() can take a while, so drain the + * batch before we perform pageout. + */ + nr_reclaimed += + __remove_mapping_batch(&batch_for_mapping_removal, + &ret_pages, + &free_pages); + /* Page is dirty, try to write it out here */ switch (pageout(page, mapping, sc)) { case PAGE_KEEP: _ -- 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/