From patchwork Fri Jun 1 12:24:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9075 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0381E23E1B for ; Fri, 1 Jun 2012 12:26:30 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id A1B24A1831F for ; Fri, 1 Jun 2012 12:26:29 +0000 (UTC) Received: by ggnf1 with SMTP id f1so1894261ggn.11 for ; Fri, 01 Jun 2012 05:26:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=UGPws3DWO4eRBJqs9zEOabzoisFKCQu36HxUdSK5WZg=; b=HWEk9RAdcWNulAlsucTEQMx5zR/Gd0ky562+ZdQuXKDpKOg35iaiJST0oDm5G+3Pf3 iLYC1jz04FeW1HM7H0258tu2CCBnBR5V4EseWPkUupT178F9H97E8/IS8Wm1a12uvX7r X5mEAyUQOaTQv9RhLwOTvGJWbBERea0OJv2NaFBUpUYMCAW9KPvaa3wlKUsLWHEcrQgi pYsrJKjUvuTRZIRe/CohhB9CUfkdczMLP/YZ3kKzVWHK709srcOUUe7AuaK6Si4W/PoB 9o0G57KCb49hWpNDqILaHOUJc1aFM7HI3GGx/bZmHA0dt16Iu9ReiEvD6BMdBssXwy9z yALQ== Received: by 10.50.163.99 with SMTP id yh3mr1141425igb.53.1338553588883; Fri, 01 Jun 2012 05:26:28 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp313870ibb; Fri, 1 Jun 2012 05:26:28 -0700 (PDT) Received: by 10.68.225.101 with SMTP id rj5mr10156299pbc.2.1338553587798; Fri, 01 Jun 2012 05:26:27 -0700 (PDT) Received: from mail-pz0-f50.google.com (mail-pz0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id hf5si4310651pbc.114.2012.06.01.05.26.27 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 01 Jun 2012 05:26:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by danh15 with SMTP id h15so3177458dan.37 for ; Fri, 01 Jun 2012 05:26:27 -0700 (PDT) Received: by 10.68.221.98 with SMTP id qd2mr10185734pbc.3.1338553587354; Fri, 01 Jun 2012 05:26:27 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id ph10sm2604277pbc.55.2012.06.01.05.26.22 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 01 Jun 2012 05:26:25 -0700 (PDT) From: Anton Vorontsov To: Pekka Enberg Cc: Leonid Moiseichuk , KOSAKI Motohiro , Minchan Kim , Bartlomiej Zolnierkiewicz , John Stultz , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 1/5] vmstat: Implement refresh_vm_stats() Date: Fri, 1 Jun 2012 05:24:02 -0700 Message-Id: <1338553446-22292-1-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <20120601122118.GA6128@lizard> References: <20120601122118.GA6128@lizard> X-Gm-Message-State: ALoCoQn1xpeCwSk3D4xtTBt8nY1TnCdHwQSWT7mFNhtCHPWS/VQFOjhjN4chNdS2+U1JYGSZ3J0Q This function forcibly flushes per-cpu vmstat diff counters to the global counters. Note that we don't try to flush percpu pagesets, the pcp will be still flushed once per 3 seconds. Signed-off-by: Anton Vorontsov --- include/linux/vmstat.h | 2 ++ mm/vmstat.c | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 65efb92..2a53896 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -200,6 +200,7 @@ extern void __inc_zone_state(struct zone *, enum zone_stat_item); extern void dec_zone_state(struct zone *, enum zone_stat_item); extern void __dec_zone_state(struct zone *, enum zone_stat_item); +void refresh_vm_stats(void); void refresh_cpu_vm_stats(int); void refresh_zone_stat_thresholds(void); @@ -253,6 +254,7 @@ static inline void __dec_zone_page_state(struct page *page, #define set_pgdat_percpu_threshold(pgdat, callback) { } +static inline void refresh_vm_stats(void) { } static inline void refresh_cpu_vm_stats(int cpu) { } static inline void refresh_zone_stat_thresholds(void) { } diff --git a/mm/vmstat.c b/mm/vmstat.c index f600557..4a9d432 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -434,7 +435,7 @@ EXPORT_SYMBOL(dec_zone_page_state); * with the global counters. These could cause remote node cache line * bouncing and will have to be only done when necessary. */ -void refresh_cpu_vm_stats(int cpu) +static void __refresh_cpu_vm_stats(int cpu, bool drain_pcp) { struct zone *zone; int i; @@ -456,11 +457,15 @@ void refresh_cpu_vm_stats(int cpu) local_irq_restore(flags); atomic_long_add(v, &zone->vm_stat[i]); global_diff[i] += v; + if (!drain_pcp) + continue; #ifdef CONFIG_NUMA /* 3 seconds idle till flush */ p->expire = 3; #endif } + if (!drain_pcp) + continue; cond_resched(); #ifdef CONFIG_NUMA /* @@ -495,6 +500,21 @@ void refresh_cpu_vm_stats(int cpu) atomic_long_add(global_diff[i], &vm_stat[i]); } +void refresh_cpu_vm_stats(int cpu) +{ + __refresh_cpu_vm_stats(cpu, 1); +} + +static void smp_call_refresh_cpu_vm_stats(void *info) +{ + __refresh_cpu_vm_stats(smp_processor_id(), 0); +} + +void refresh_vm_stats(void) +{ + smp_call_function(smp_call_refresh_cpu_vm_stats, NULL, 1); +} + #endif #ifdef CONFIG_NUMA