From: Anton Vorontsov <anton.vorontsov@linaro.org>
To: Pekka Enberg <penberg@kernel.org>
Cc: John Stultz <john.stultz@linaro.org>,
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 [thread overview]
Message-ID: <1349346078-24874-3-git-send-email-anton.vorontsov@linaro.org> (raw)
In-Reply-To: <20121004102013.GA23284@lizard>
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 <anton.vorontsov@linaro.org>
---
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);
}
--
1.7.12.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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-10-04 10:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-04 10:20 [PATCH 0/3] A few cleanups and refactorings, sync w/ upstream Anton Vorontsov
2012-10-04 10:21 ` [PATCH 1/3] vmevent: Remove unused code Anton Vorontsov
2012-10-04 10:21 ` [PATCH 2/3] vmevent: Factor vmevent_match_attr() out of vmevent_match() Anton Vorontsov
2012-10-12 12:37 ` Pekka Enberg
2012-10-12 22:21 ` Anton Vorontsov
2012-10-04 10:21 ` Anton Vorontsov [this message]
2012-10-12 12:12 ` [PATCH 0/3] A few cleanups and refactorings, sync w/ upstream Pekka Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1349346078-24874-3-git-send-email-anton.vorontsov@linaro.org \
--to=anton.vorontsov@linaro.org \
--cc=john.stultz@linaro.org \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=patches@linaro.org \
--cc=penberg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).