Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757463Ab2ECO6B (ORCPT ); Thu, 3 May 2012 10:58:01 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:55935 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757315Ab2ECO5W (ORCPT ); Thu, 3 May 2012 10:57:22 -0400 From: Gilad Ben-Yossef To: linux-kernel@vger.kernel.org Cc: Gilad Ben-Yossef , Thomas Gleixner , Tejun Heo , John Stultz , Andrew Morton , KOSAKI Motohiro , Mel Gorman , Mike Frysinger , David Rientjes , Hugh Dickins , Minchan Kim , Konstantin Khlebnikov , Christoph Lameter , Chris Metcalf , Hakan Akkan , Max Krasnyansky , Frederic Weisbecker , linux-mm@kvack.org Subject: [PATCH v1 4/6] mm: make lru_drain selective where it schedules work Date: Thu, 3 May 2012 17:56:00 +0300 Message-Id: <1336056962-10465-5-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1336056962-10465-1-git-send-email-gilad@benyossef.com> References: <1336056962-10465-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2240 Lines: 79 lru drain work is being done by scheduling a work queue on each CPU, whether it has LRU pages to drain or not, thus creating interference on isolated CPUs. This patch uses schedule_on_each_cpu_cond() to schedule the work only on CPUs where it seems that there are LRUs to drain. Signed-off-by: Gilad Ben-Yossef CC: Thomas Gleixner CC: Tejun Heo CC: John Stultz CC: Andrew Morton CC: KOSAKI Motohiro CC: Mel Gorman CC: Mike Frysinger CC: David Rientjes CC: Hugh Dickins CC: Minchan Kim CC: Konstantin Khlebnikov CC: Christoph Lameter CC: Chris Metcalf CC: Hakan Akkan CC: Max Krasnyansky CC: Frederic Weisbecker CC: linux-kernel@vger.kernel.org CC: linux-mm@kvack.org --- mm/swap.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 5c13f13..ab07b62 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -562,12 +562,35 @@ static void lru_add_drain_per_cpu(struct work_struct *dummy) lru_add_drain(); } +static bool lru_drain_cpu(int cpu) +{ + struct pagevec *pvecs = per_cpu(lru_add_pvecs, cpu); + struct pagevec *pvec; + int lru; + + for_each_lru(lru) { + pvec = &pvecs[lru - LRU_BASE]; + if (pagevec_count(pvec)) + return true; + } + + pvec = &per_cpu(lru_rotate_pvecs, cpu); + if (pagevec_count(pvec)) + return true; + + pvec = &per_cpu(lru_deactivate_pvecs, cpu); + if (pagevec_count(pvec)) + return true; + + return false; +} + /* * Returns 0 for success */ int lru_add_drain_all(void) { - return schedule_on_each_cpu(lru_add_drain_per_cpu); + return schedule_on_each_cpu_cond(lru_add_drain_per_cpu, lru_drain_cpu); } /* -- 1.7.0.4 -- 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/