From patchwork Thu Oct 4 10:21:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 11982 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 60DAE24146 for ; Thu, 4 Oct 2012 10:24:19 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 28FD4A18788 for ; Thu, 4 Oct 2012 10:24:19 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so124221iag.11 for ; Thu, 04 Oct 2012 03:24:18 -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=zYqY/VHMDTtdQeh9jNU782aawjB+AJHexTifZCglEwc=; b=PmSY9FVqnAiOUv0q/1Dm4rHPVlbSyCcRm8N0SF8KxuUknvoCudd7ClVc89NdgAz4Bu 1bogy+pwnIFURwg6Ygzge+IPUwgmXFYLvETSKWV8HHMVy7zxo2nbjP6vkWmYZc+vkgSb sjoavPrjK4tqeGhuQsdRjb9+DdemUhdZbeeGzizFcdvOW6N1jBfFRQbA2Pxy3Vf6B2st 2JWfHbZxzfZLcRu+ueY7NaG9GJ0zZESvFrJhihzVtfNp5bvUW1938iopQyt970aHQ6La FPhTR+fCHBcdMN9O6wYYbpr8ZeoZMvbMLrzrrl25+e2taTupP2xdzpg/Y3J+NJ4U5bUe 5/CQ== Received: by 10.50.7.212 with SMTP id l20mr4643025iga.43.1349346258613; Thu, 04 Oct 2012 03:24:18 -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.50.184.232 with SMTP id ex8csp58557igc; Thu, 4 Oct 2012 03:24:18 -0700 (PDT) Received: by 10.68.190.71 with SMTP id go7mr20920399pbc.66.1349346258059; Thu, 04 Oct 2012 03:24:18 -0700 (PDT) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id rr1si13304918pbc.128.2012.10.04.03.24.17 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Oct 2012 03:24:18 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.220.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.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 mail-pa0-f50.google.com with SMTP id hz11so427391pad.37 for ; Thu, 04 Oct 2012 03:24:17 -0700 (PDT) Received: by 10.68.217.202 with SMTP id pa10mr21002197pbc.15.1349346257791; Thu, 04 Oct 2012 03:24:17 -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 qd9sm4144019pbb.31.2012.10.04.03.24.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Oct 2012 03:24:17 -0700 (PDT) From: Anton Vorontsov To: Pekka Enberg Cc: John Stultz , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, patches@linaro.org Subject: [PATCH 3/3] vmevent: Don't sample values twice Date: Thu, 4 Oct 2012 03:21:18 -0700 Message-Id: <1349346078-24874-3-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <20121004102013.GA23284@lizard> References: <20121004102013.GA23284@lizard> X-Gm-Message-State: ALoCoQmXCXK1Vo1/ZHCp2jMRUu+bwDHf/UsResIkahr1n3uRUq/3hM55eedXaQVcgToerV81N9cv Currently, we sample the same values in vmevent_sample() and vmevent_match(), but we can easily avoid this. Also saves loop iterations. Signed-off-by: Anton Vorontsov --- mm/vmevent.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/mm/vmevent.c b/mm/vmevent.c index d434c11..d643615 100644 --- a/mm/vmevent.c +++ b/mm/vmevent.c @@ -133,18 +133,22 @@ static bool vmevent_match_attr(struct vmevent_attr *attr, u64 value) static bool vmevent_match(struct vmevent_watch *watch) { struct vmevent_config *config = &watch->config; + bool ret = 0; int i; for (i = 0; i < config->counter; i++) { struct vmevent_attr *attr = &config->attrs[i]; + struct vmevent_attr *samp = &watch->sample_attrs[i]; u64 val; val = vmevent_sample_attr(watch, attr); - if (vmevent_match_attr(attr, val)) - return true; + if (!ret && vmevent_match_attr(attr, val)) + ret = 1; + + samp->value = val; } - return false; + return ret; } /* @@ -161,20 +165,11 @@ static bool vmevent_match(struct vmevent_watch *watch) */ static void vmevent_sample(struct vmevent_watch *watch) { - int i; - if (atomic_read(&watch->pending)) return; if (!vmevent_match(watch)) return; - for (i = 0; i < watch->nr_attrs; i++) { - struct vmevent_attr *attr = &watch->sample_attrs[i]; - - attr->value = vmevent_sample_attr(watch, - watch->config_attrs[i]); - } - atomic_set(&watch->pending, 1); }