Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753597AbbHVKqC (ORCPT ); Sat, 22 Aug 2015 06:46:02 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:33076 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753522AbbHVKpd (ORCPT ); Sat, 22 Aug 2015 06:45:33 -0400 From: Ingo Molnar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Dave Hansen , Peter Zijlstra , David Rientjes , Rik van Riel , Rasmus Villemoes , Linus Torvalds Subject: [PATCH 3/3] mm/vmalloc: Cache the vmalloc memory info Date: Sat, 22 Aug 2015 12:45:00 +0200 Message-Id: <1440240300-6206-4-git-send-email-mingo@kernel.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1440240300-6206-1-git-send-email-mingo@kernel.org> References: <1440240300-6206-1-git-send-email-mingo@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1812 Lines: 66 Linus reported that glibc (rather stupidly) reads /proc/meminfo for every sysinfo() call, which causes the Git build to use a surprising amount of CPU time, mostly due to the overhead of get_vmalloc_info() - which walks a long list to do its statistics. Modify Linus's jiffies based patch to use the newly introduced vmap_info_changed flag instead: when we cache the vmalloc-info, we clear the flag. If the flag gets re-set then we'll calculate the information again. Cc: Linus Torvalds Cc: Andrew Morton Cc: Rik van Riel Cc: linux-mm@kvack.org Signed-off-by: Ingo Molnar --- mm/vmalloc.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d21febaa557a..ef48e557df5a 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2702,7 +2702,7 @@ static int __init proc_vmalloc_init(void) } module_init(proc_vmalloc_init); -void get_vmalloc_info(struct vmalloc_info *vmi) +static void calc_vmalloc_info(struct vmalloc_info *vmi) { struct vmap_area *va; unsigned long free_area_size; @@ -2749,5 +2749,23 @@ void get_vmalloc_info(struct vmalloc_info *vmi) out: rcu_read_unlock(); } -#endif +void get_vmalloc_info(struct vmalloc_info *vmi) +{ + static struct vmalloc_info cached_info; + + if (!vmap_info_changed) { + *vmi = cached_info; + return; + } + + WRITE_ONCE(vmap_info_changed, 0); + barrier(); + + calc_vmalloc_info(vmi); + + barrier(); + cached_info = *vmi; +} + +#endif -- 2.1.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/