From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758494Ab3HMXHJ (ORCPT ); Tue, 13 Aug 2013 19:07:09 -0400 Received: from usmamail.tilera.com ([12.216.194.151]:16724 "EHLO USMAMAIL.TILERA.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758408Ab3HMXHF (ORCPT ); Tue, 13 Aug 2013 19:07:05 -0400 Message-ID: <201308132307.r7DN74M5029053@farm-0021.internal.tilera.com> From: Chris Metcalf Date: Tue, 13 Aug 2013 18:53:32 -0400 In-Reply-To: <520AAF9C.1050702@tilera.com> To: Andrew Morton CC: Tejun Heo , , , Thomas Gleixner , Frederic Weisbecker , Cody P Schafer Subject: [PATCH v7 2/2] mm: make lru_add_drain_all() selective MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change makes lru_add_drain_all() only selectively interrupt the cpus that have per-cpu free pages that can be drained. This is important in nohz mode where calling mlockall(), for example, otherwise will interrupt every core unnecessarily. Signed-off-by: Chris Metcalf --- v7: try a version with callbacks instead of cpu masks. Either this or v6 seem like reasonable solutions. v6: add Tejun's Acked-by, and add missing get/put_cpu_online to lru_add_drain_all(). v5: provide validity checking on the cpumask for schedule_on_cpu_mask. By providing an all-or-nothing EINVAL check, we impose the requirement that the calling code actually know clearly what it's trying to do. (Note: no change to the mm/swap.c commit) v4: don't lose possible -ENOMEM in schedule_on_each_cpu() (Note: no change to the mm/swap.c commit) v3: split commit into two, one for workqueue and one for mm, though both should probably be taken through -mm. mm/swap.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/mm/swap.c b/mm/swap.c index 4a1d0d2..fe3a488 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -405,6 +405,11 @@ static void activate_page_drain(int cpu) pagevec_lru_move_fn(pvec, __activate_page, NULL); } +static bool need_activate_page_drain(int cpu) +{ + return pagevec_count(&per_cpu(activate_page_pvecs, cpu)) != 0; +} + void activate_page(struct page *page) { if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) { @@ -422,6 +427,11 @@ static inline void activate_page_drain(int cpu) { } +static bool need_activate_page_drain(int cpu) +{ + return false; +} + void activate_page(struct page *page) { struct zone *zone = page_zone(page); @@ -673,6 +683,14 @@ void lru_add_drain(void) put_cpu(); } +static bool lru_add_drain_cond(void *data, int cpu) +{ + return pagevec_count(&per_cpu(lru_add_pvec, cpu)) || + pagevec_count(&per_cpu(lru_rotate_pvecs, cpu)) || + pagevec_count(&per_cpu(lru_deactivate_pvecs, cpu)) || + need_activate_page_drain(cpu); +} + static void lru_add_drain_per_cpu(struct work_struct *dummy) { lru_add_drain(); @@ -683,7 +701,8 @@ static void lru_add_drain_per_cpu(struct work_struct *dummy) */ 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_add_drain_cond, NULL); } /* -- 1.8.3.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx118.postini.com [74.125.245.118]) by kanga.kvack.org (Postfix) with SMTP id 1BDA36B0033 for ; Tue, 13 Aug 2013 19:07:06 -0400 (EDT) Message-ID: <201308132307.r7DN74M5029053@farm-0021.internal.tilera.com> From: Chris Metcalf Date: Tue, 13 Aug 2013 18:53:32 -0400 In-Reply-To: <520AAF9C.1050702@tilera.com> Subject: [PATCH v7 2/2] mm: make lru_add_drain_all() selective MIME-Version: 1.0 Content-Type: text/plain Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Tejun Heo , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Thomas Gleixner , Frederic Weisbecker , Cody P Schafer This change makes lru_add_drain_all() only selectively interrupt the cpus that have per-cpu free pages that can be drained. This is important in nohz mode where calling mlockall(), for example, otherwise will interrupt every core unnecessarily. Signed-off-by: Chris Metcalf --- v7: try a version with callbacks instead of cpu masks. Either this or v6 seem like reasonable solutions. v6: add Tejun's Acked-by, and add missing get/put_cpu_online to lru_add_drain_all(). v5: provide validity checking on the cpumask for schedule_on_cpu_mask. By providing an all-or-nothing EINVAL check, we impose the requirement that the calling code actually know clearly what it's trying to do. (Note: no change to the mm/swap.c commit) v4: don't lose possible -ENOMEM in schedule_on_each_cpu() (Note: no change to the mm/swap.c commit) v3: split commit into two, one for workqueue and one for mm, though both should probably be taken through -mm. mm/swap.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/mm/swap.c b/mm/swap.c index 4a1d0d2..fe3a488 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -405,6 +405,11 @@ static void activate_page_drain(int cpu) pagevec_lru_move_fn(pvec, __activate_page, NULL); } +static bool need_activate_page_drain(int cpu) +{ + return pagevec_count(&per_cpu(activate_page_pvecs, cpu)) != 0; +} + void activate_page(struct page *page) { if (PageLRU(page) && !PageActive(page) && !PageUnevictable(page)) { @@ -422,6 +427,11 @@ static inline void activate_page_drain(int cpu) { } +static bool need_activate_page_drain(int cpu) +{ + return false; +} + void activate_page(struct page *page) { struct zone *zone = page_zone(page); @@ -673,6 +683,14 @@ void lru_add_drain(void) put_cpu(); } +static bool lru_add_drain_cond(void *data, int cpu) +{ + return pagevec_count(&per_cpu(lru_add_pvec, cpu)) || + pagevec_count(&per_cpu(lru_rotate_pvecs, cpu)) || + pagevec_count(&per_cpu(lru_deactivate_pvecs, cpu)) || + need_activate_page_drain(cpu); +} + static void lru_add_drain_per_cpu(struct work_struct *dummy) { lru_add_drain(); @@ -683,7 +701,8 @@ static void lru_add_drain_per_cpu(struct work_struct *dummy) */ 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_add_drain_cond, NULL); } /* -- 1.8.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org