From: Anton Vorontsov <anton.vorontsov@linaro.org>
To: Pekka Enberg <penberg@kernel.org>
Cc: Mel Gorman <mgorman@suse.de>,
Leonid Moiseichuk <leonid.moiseichuk@nokia.com>,
KOSAKI Motohiro <kosaki.motohiro@gmail.com>,
Minchan Kim <minchan@kernel.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
John Stultz <john.stultz@linaro.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linaro-kernel@lists.linaro.org, patches@linaro.org,
kernel-team@android.com
Subject: [PATCH 2/3] mm: vmevent: Use value2 for setting vmstat thresholds
Date: Fri, 12 Oct 2012 03:11:58 -0700 [thread overview]
Message-ID: <1350036719-29031-2-git-send-email-anton.vorontsov@linaro.org> (raw)
In-Reply-To: <20121012101115.GA11825@lizard>
Attributes that use vmstat can now use attr->value2 to specify an optional
accuracy. Based on the provided value, we will setup appropriate vmstat
thresholds.
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
---
include/linux/vmevent.h | 5 +++++
mm/vmevent.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/include/linux/vmevent.h b/include/linux/vmevent.h
index b1c4016..b8c1394 100644
--- a/include/linux/vmevent.h
+++ b/include/linux/vmevent.h
@@ -46,6 +46,11 @@ struct vmevent_attr {
__u64 value;
/*
+ * Some attributes accept two configuration values.
+ */
+ __u64 value2;
+
+ /*
* Type of profiled attribute from VMEVENT_ATTR_XXX
*/
__u32 type;
diff --git a/mm/vmevent.c b/mm/vmevent.c
index 8c0fbe6..8113bda 100644
--- a/mm/vmevent.c
+++ b/mm/vmevent.c
@@ -28,8 +28,13 @@ struct vmevent_watch {
/* poll */
wait_queue_head_t waitq;
+
+ struct list_head node;
};
+static LIST_HEAD(vmevent_watchers);
+static DEFINE_SPINLOCK(vmevent_watchers_lock);
+
typedef u64 (*vmevent_attr_sample_fn)(struct vmevent_watch *watch,
struct vmevent_attr *attr);
@@ -259,12 +264,57 @@ out:
return ret;
}
+#ifdef CONFIG_SMP
+
+static void vmevent_set_thresholds(void)
+{
+ struct vmevent_watch *w;
+ struct zone *zone;
+ u64 thres = ULLONG_MAX;
+
+ spin_lock(&vmevent_watchers_lock);
+
+ list_for_each_entry(w, &vmevent_watchers, node) {
+ int i;
+
+ for (i = 0; i < w->config.counter; i++) {
+ struct vmevent_attr *attr = &w->config.attrs[i];
+
+ if (attr->type != VMEVENT_ATTR_NR_FREE_PAGES)
+ continue;
+ if (!attr->value2)
+ continue;
+ thres = min(thres, attr->value2);
+ }
+ }
+
+ if (thres == ULLONG_MAX)
+ thres = 0;
+
+ thres = (thres + PAGE_SIZE - 1) / PAGE_SIZE;
+
+ for_each_populated_zone(zone)
+ set_zone_stat_thresholds(zone, NULL, thres);
+
+ spin_unlock(&vmevent_watchers_lock);
+}
+
+#else
+static inline void vmevent_set_thresholds(void) {}
+#endif /* CONFIG_SMP */
+
static int vmevent_release(struct inode *inode, struct file *file)
{
struct vmevent_watch *watch = file->private_data;
cancel_delayed_work_sync(&watch->work);
+ spin_lock(&vmevent_watchers_lock);
+ list_del(&watch->node);
+ spin_unlock(&vmevent_watchers_lock);
+
+ vmevent_set_thresholds();
+
kfree(watch);
return 0;
@@ -328,6 +378,10 @@ static int vmevent_setup_watch(struct vmevent_watch *watch)
watch->sample_attrs = attrs;
watch->nr_attrs = nr;
+ spin_lock(&vmevent_watchers_lock);
+ list_add(&watch->node, &vmevent_watchers);
+ spin_unlock(&vmevent_watchers_lock);
+
return 0;
}
@@ -363,6 +417,8 @@ SYSCALL_DEFINE1(vmevent_fd,
if (err)
goto err_free;
+ vmevent_set_thresholds();
+
fd = get_unused_fd_flags(O_RDONLY);
if (fd < 0) {
err = fd;
--
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-12 10:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-12 10:11 [RFC 0/3] mm: vmevent: Stats accuracy improvements Anton Vorontsov
2012-10-12 10:11 ` [PATCH 1/3] mm: vmstat: Implement set_zone_stat_thresholds() helper Anton Vorontsov
2012-10-12 10:11 ` Anton Vorontsov [this message]
2012-10-12 10:11 ` [PATCH 3/3] mm: vmevent: Sum per cpu pagesets stats asynchronously Anton Vorontsov
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=1350036719-29031-2-git-send-email-anton.vorontsov@linaro.org \
--to=anton.vorontsov@linaro.org \
--cc=b.zolnierkie@samsung.com \
--cc=john.stultz@linaro.org \
--cc=kernel-team@android.com \
--cc=kosaki.motohiro@gmail.com \
--cc=leonid.moiseichuk@nokia.com \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=minchan@kernel.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