From: Kirill Korotaev <dev@sw.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Alan Cox <alan@lxorguk.ukuu.org.uk>, Ingo Molnar <mingo@elte.hu>,
Christoph Hellwig <hch@infradead.org>,
Pavel Emelianov <xemul@openvz.org>, Andrey Savochkin <saw@sw.ru>,
devel@openvz.org, Rik van Riel <riel@redhat.com>,
hugh@veritas.com, ckrm-tech@lists.sourceforge.net,
Andi Kleen <ak@suse.de>
Subject: [RFC][PATCH 7/7] UBC: proc interface
Date: Wed, 16 Aug 2006 19:44:30 +0400 [thread overview]
Message-ID: <44E33D5E.7000205@sw.ru> (raw)
In-Reply-To: <44E33893.6020700@sw.ru>
Add proc interface (/proc/user_beancounters) allowing to see current
state (usage/limits/fails for each UB). Implemented via seq files.
Signed-Off-By: Pavel Emelianov <xemul@sw.ru>
Signed-Off-By: Kirill Korotaev <dev@sw.ru>
---
init/main.c | 1
kernel/ub/Makefile | 1
kernel/ub/proc.c | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 207 insertions(+)
--- ./init/main.c.ubproc 2006-07-31 18:40:20.000000000 +0400
+++ ./init/main.c 2006-08-03 16:02:19.000000000 +0400
@@ -578,6 +578,7 @@ asmlinkage void __init start_kernel(void
page_writeback_init();
#ifdef CONFIG_PROC_FS
proc_root_init();
+ ub_init_proc();
#endif
cpuset_init();
taskstats_init_early();
--- ./kernel/ub/Makefile.ubproc 2006-07-31 17:49:05.000000000 +0400
+++ ./kernel/ub/Makefile 2006-08-01 11:08:39.000000000 +0400
@@ -4,3 +4,4 @@ obj-$(CONFIG_USER_RESOURCE) += beancount
obj-$(CONFIG_USER_RESOURCE) += misc.o
obj-y += sys.o
obj-$(CONFIG_USER_RESOURCE) += kmem.o
+obj-$(CONFIG_USER_RESOURCE) += proc.o
--- ./kernel/ub/proc.c.ubproc 2006-08-01 10:22:09.000000000 +0400
+++ ./kernel/ub/proc.c 2006-08-03 15:50:35.000000000 +0400
@@ -0,0 +1,205 @@
+/*
+ * kernel/ub/proc.c
+ *
+ * Copyright (C) 2006 OpenVZ. SWsoft Inc.
+ *
+ */
+
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+
+#include <ub/beancounter.h>
+
+#ifdef CONFIG_PROC_FS
+
+#if BITS_PER_LONG == 32
+static const char *head_fmt = "%10s %-12s %10s %10s %10s %10s %10s\n";
+static const char *res_fmt = "%10s %-12s %10lu %10lu %10lu %10lu %10lu\n";
+#else
+static const char *head_fmt = "%10s %-12s %20s %20s %20s %20s %20s\n";
+static const char *res_fmt = "%10s %-12s %20lu %20lu %20lu %20lu %20lu\n";
+#endif
+
+static void ub_show_header(struct seq_file *f)
+{
+ seq_printf(f, head_fmt, "uid", "resource",
+ "held", "maxheld", "barrier", "limit", "failcnt");
+}
+
+static void ub_show_res(struct seq_file *f, struct user_beancounter *ub, int r)
+{
+ char ub_uid[64];
+
+ if (r == 0)
+ ub_print_uid(ub, ub_uid, sizeof(ub_uid));
+ else
+ strcpy(ub_uid, "");
+
+ seq_printf(f, res_fmt, ub_uid, ub_rnames[r],
+ ub->ub_parms[r].held,
+ ub->ub_parms[r].maxheld,
+ ub->ub_parms[r].barrier,
+ ub->ub_parms[r].limit,
+ ub->ub_parms[r].failcnt);
+}
+
+static struct ub_seq_struct {
+ unsigned long flags;
+ int slot;
+ struct user_beancounter *ub;
+} ub_seq_ctx;
+
+static int ub_show(struct seq_file *f, void *v)
+{
+ int res;
+
+ for (res = 0; res < UB_RESOURCES; res++)
+ ub_show_res(f, ub_seq_ctx.ub, res);
+ return 0;
+}
+
+static void *ub_start_ctx(struct seq_file *f, unsigned long p, int sub)
+{
+ struct user_beancounter *ub;
+ struct hlist_node *pos;
+ unsigned long flags;
+ int slot;
+
+ if (p == 0)
+ ub_show_header(f);
+
+ spin_lock_irqsave(&ub_hash_lock, flags);
+ ub_seq_ctx.flags = flags;
+
+ for (slot = 0; slot < UB_HASH_SIZE; slot++)
+ hlist_for_each_entry (ub, pos, &ub_hash[slot], hash) {
+ if (!sub && ub->parent != NULL)
+ continue;
+
+ if (p-- == 0) {
+ ub_seq_ctx.ub = ub;
+ ub_seq_ctx.slot = slot;
+ return &ub_seq_ctx;
+ }
+ }
+
+ return NULL;
+}
+
+static void *ub_next_ctx(struct seq_file *f, loff_t *ppos, int sub)
+{
+ struct user_beancounter *ub;
+ struct hlist_node *pos;
+ int slot;
+
+ ub = ub_seq_ctx.ub;
+
+ pos = &ub->hash;
+ hlist_for_each_entry_continue (ub, pos, hash) {
+ if (!sub && ub->parent != NULL)
+ continue;
+
+ ub_seq_ctx.ub = ub;
+ (*ppos)++;
+ return &ub_seq_ctx;
+ }
+
+ for (slot = ub_seq_ctx.slot + 1; slot < UB_HASH_SIZE; slot++)
+ hlist_for_each_entry (ub, pos, &ub_hash[slot], hash) {
+ if (!sub && ub->parent != NULL)
+ continue;
+
+ ub_seq_ctx.ub = ub;
+ ub_seq_ctx.slot = slot;
+ (*ppos)++;
+ return &ub_seq_ctx;
+ }
+
+ return NULL;
+}
+
+static void *ub_start(struct seq_file *f, loff_t *ppos)
+{
+ return ub_start_ctx(f, *ppos, 0);
+}
+
+static void *ub_sub_start(struct seq_file *f, loff_t *ppos)
+{
+ return ub_start_ctx(f, *ppos, 1);
+}
+
+static void *ub_next(struct seq_file *f, void *v, loff_t *pos)
+{
+ return ub_next_ctx(f, pos, 0);
+}
+
+static void *ub_sub_next(struct seq_file *f, void *v, loff_t *pos)
+{
+ return ub_next_ctx(f, pos, 1);
+}
+
+static void ub_stop(struct seq_file *f, void *v)
+{
+ unsigned long flags;
+
+ flags = ub_seq_ctx.flags;
+ spin_unlock_irqrestore(&ub_hash_lock, flags);
+}
+
+static struct seq_operations ub_seq_ops = {
+ .start = ub_start,
+ .next = ub_next,
+ .stop = ub_stop,
+ .show = ub_show
+};
+
+static int ub_open(struct inode *inode, struct file *filp)
+{
+ return seq_open(filp, &ub_seq_ops);
+}
+
+static struct file_operations ub_file_operations = {
+ .open = ub_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+
+static struct seq_operations ub_sub_seq_ops = {
+ .start = ub_sub_start,
+ .next = ub_sub_next,
+ .stop = ub_stop,
+ .show = ub_show
+};
+
+static int ub_sub_open(struct inode *inode, struct file *filp)
+{
+ return seq_open(filp, &ub_sub_seq_ops);
+}
+
+static struct file_operations ub_sub_file_operations = {
+ .open = ub_sub_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+
+void __init ub_init_proc(void)
+{
+ struct proc_dir_entry *entry;
+
+ entry = create_proc_entry("user_beancounters", S_IRUGO, NULL);
+ if (entry)
+ entry->proc_fops = &ub_file_operations;
+ else
+ panic("Can't create /proc/user_beancounters\n");
+
+ entry = create_proc_entry("user_beancounters_sub", S_IRUGO, NULL);
+ if (entry)
+ entry->proc_fops = &ub_sub_file_operations;
+ else
+ panic("Can't create /proc/user_beancounters_sub\n");
+}
+#endif
next prev parent reply other threads:[~2006-08-16 15:42 UTC|newest]
Thread overview: 209+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-16 15:24 [RFC][PATCH] UBC: user resource beancounters Kirill Korotaev
2006-08-16 15:35 ` [RFC][PATCH 1/7] UBC: kconfig Kirill Korotaev
2006-08-18 19:57 ` [ckrm-tech] " Chandra Seetharaman
2006-08-18 21:14 ` Adrian Bunk
2006-08-25 15:12 ` Pavel Machek
2006-08-16 15:37 ` [RFC][PATCH 2/7] UBC: core (structures, API) Kirill Korotaev
2006-08-16 16:58 ` Alan Cox
2006-08-17 11:42 ` Kirill Korotaev
2006-08-16 17:15 ` Greg KH
2006-08-17 11:45 ` Kirill Korotaev
2006-08-17 12:14 ` Greg KH
2006-08-17 14:32 ` [ckrm-tech] " Dave Hansen
2006-08-18 12:36 ` Kirill Korotaev
2006-08-16 18:11 ` Rohit Seth
2006-08-16 18:18 ` Andrew Morton
2006-08-17 11:54 ` Kirill Korotaev
2006-08-17 11:53 ` Kirill Korotaev
2006-08-17 16:55 ` Rohit Seth
2006-08-18 11:14 ` Kirill Korotaev
2006-08-18 17:51 ` Rohit Seth
2006-08-18 5:31 ` Andrew Morton
2006-08-18 7:35 ` [PATCH " Andrey Savochkin
2006-08-18 8:26 ` [ckrm-tech] " Matt Helsley
2006-08-18 11:52 ` Kirill Korotaev
2006-08-18 15:59 ` [RFC][PATCH " Alan Cox
2006-08-17 11:09 ` [ckrm-tech] " Srivatsa Vaddagiri
2006-08-17 14:02 ` Kirill Korotaev
2006-08-17 18:59 ` Chandra Seetharaman
2006-08-18 1:58 ` Matt Helsley
2006-08-18 11:36 ` Kirill Korotaev
2006-08-19 2:38 ` Matt Helsley
2006-08-21 11:02 ` Kirill Korotaev
2006-08-22 12:23 ` Srivatsa Vaddagiri
2006-08-22 12:46 ` Kirill Korotaev
2006-08-22 14:38 ` Srivatsa Vaddagiri
2006-08-21 17:35 ` Chandra Seetharaman
2006-08-20 4:58 ` Balbir Singh
2006-08-20 5:01 ` Balbir Singh
2006-08-16 15:38 ` [RFC][PATCH 3/7] UBC: ub context and inheritance Kirill Korotaev
2006-08-16 16:51 ` Alan Cox
2006-08-17 11:09 ` [ckrm-tech] " Srivatsa Vaddagiri
2006-08-17 13:21 ` [Devel] " Pavel V. Emelianov
2006-08-18 2:42 ` Matt Helsley
2006-08-18 9:23 ` Kirill Korotaev
2006-08-19 2:19 ` Matt Helsley
2006-08-18 20:03 ` Chandra Seetharaman
2006-08-21 10:32 ` Kirill Korotaev
2006-08-21 20:48 ` Chandra Seetharaman
2006-08-16 15:39 ` [RFC][PATCH 4/7] UBC: syscalls (user interface) Kirill Korotaev
2006-08-16 16:52 ` Alan Cox
2006-08-16 17:17 ` Greg KH
2006-08-17 12:02 ` Kirill Korotaev
2006-08-16 18:17 ` Rohit Seth
2006-08-16 19:04 ` Alan Cox
2006-08-16 19:22 ` Rohit Seth
2006-08-17 12:13 ` Kirill Korotaev
2006-08-17 15:40 ` Andrew Morton
2006-08-18 8:08 ` [PATCH " Andrey Savochkin
2006-08-18 14:45 ` [ckrm-tech] " Dave Hansen
2006-08-18 16:42 ` Andrew Morton
2006-08-18 17:29 ` Dave Hansen
2006-08-18 17:38 ` Andrew Morton
2006-08-18 17:59 ` Rohit Seth
2006-08-18 18:18 ` Andrew Morton
2006-08-21 2:42 ` Magnus Damm
2006-08-18 18:09 ` Paul Jackson
2006-08-18 18:17 ` Chandra Seetharaman
2006-08-18 18:27 ` Chandra Seetharaman
2006-08-18 18:56 ` Paul Jackson
2006-08-18 19:16 ` Chris Friesen
2006-08-18 21:19 ` Paul Jackson
2006-08-18 19:48 ` Chandra Seetharaman
2006-08-18 21:16 ` Paul Jackson
2006-08-21 2:38 ` Magnus Damm
2006-08-21 7:48 ` Andi Kleen
2006-08-21 8:42 ` Magnus Damm
2006-08-21 9:03 ` Andi Kleen
2006-08-21 9:18 ` Magnus Damm
2006-08-21 13:35 ` Kirill Korotaev
2006-08-21 17:51 ` Paul Jackson
2006-08-22 8:52 ` Kirill Korotaev
2006-08-21 2:47 ` Magnus Damm
2006-08-22 1:16 ` Rohit Seth
2006-08-22 3:58 ` Magnus Damm
2006-08-22 18:34 ` Chandra Seetharaman
2006-08-24 1:20 ` Rohit Seth
2006-08-18 11:05 ` [RFC][PATCH " Kirill Korotaev
2006-08-17 17:08 ` Rohit Seth
2006-08-17 12:04 ` Kirill Korotaev
2006-08-17 17:05 ` Rohit Seth
2006-08-17 11:09 ` [ckrm-tech] " Srivatsa Vaddagiri
2006-08-17 14:04 ` Kirill Korotaev
2006-08-17 16:19 ` Srivatsa Vaddagiri
2006-08-18 2:31 ` Matt Helsley
2006-08-18 11:45 ` Kirill Korotaev
2006-08-19 2:43 ` Matt Helsley
2006-08-18 11:40 ` Arnd Bergmann
2006-08-18 20:13 ` [ckrm-tech] " Chandra Seetharaman
2006-08-16 15:40 ` [RFC][PATCH 5/7] UBC: kernel memory accounting (core) Kirill Korotaev
2006-08-16 16:56 ` Alan Cox
2006-08-17 13:47 ` Kirill Korotaev
2006-08-16 18:24 ` Rohit Seth
2006-08-17 13:27 ` Kirill Korotaev
2006-08-17 14:38 ` [ckrm-tech] " Dave Hansen
2006-08-18 9:31 ` Kirill Korotaev
2006-08-18 14:58 ` Dave Hansen
2006-08-21 10:40 ` Kirill Korotaev
2006-08-21 15:10 ` Dave Hansen
2006-08-18 15:06 ` Dave Hansen
2006-08-21 12:38 ` Kirill Korotaev
2006-08-17 17:02 ` Rohit Seth
2006-08-18 9:38 ` Kirill Korotaev
2006-08-18 16:55 ` Rohit Seth
2006-08-21 10:43 ` Kirill Korotaev
2006-08-22 1:23 ` Rohit Seth
2006-08-16 18:47 ` Dave Hansen
2006-08-16 19:15 ` Rohit Seth
2006-08-16 19:59 ` [ckrm-tech] " Dave Hansen
2006-08-17 0:24 ` Alan Cox
2006-08-17 14:26 ` Dave Hansen
2006-08-17 15:01 ` Alan Cox
2006-08-17 16:04 ` Andi Kleen
2006-08-18 10:54 ` Kirill Korotaev
2006-08-17 16:37 ` Dave Hansen
2006-08-17 15:19 ` Rik van Riel
2006-08-17 17:28 ` Rohit Seth
2006-08-17 18:43 ` Andi Kleen
2006-08-17 17:49 ` Dave Hansen
2006-08-18 8:29 ` Kirill Korotaev
2006-08-18 17:06 ` Rohit Seth
2006-08-17 17:16 ` Rohit Seth
2006-08-17 17:23 ` Dave Hansen
2006-08-17 17:36 ` Rohit Seth
2006-08-17 17:53 ` Dave Hansen
2006-08-18 8:54 ` Kirill Korotaev
2006-08-18 14:52 ` Dave Hansen
2006-08-18 17:38 ` Rohit Seth
2006-08-21 11:29 ` Kirill Korotaev
2006-08-22 1:48 ` Rohit Seth
2006-08-22 7:43 ` Pavel V. Emelianov
2006-08-18 8:51 ` Kirill Korotaev
2006-08-18 8:52 ` Kirill Korotaev
2006-08-18 14:59 ` Alan Cox
2006-08-18 19:32 ` Dave Hansen
2006-08-18 20:52 ` Alan Cox
2006-08-21 9:44 ` Kirill Korotaev
2006-08-17 16:42 ` Rohit Seth
2006-08-17 16:31 ` Rohit Seth
2006-08-17 0:22 ` Alan Cox
2006-08-17 16:36 ` Rohit Seth
2006-08-18 8:44 ` [ckrm-tech] " Kirill Korotaev
2006-08-17 13:35 ` Kirill Korotaev
2006-08-17 17:13 ` Rohit Seth
2006-08-18 8:49 ` [ckrm-tech] " Kirill Korotaev
2006-08-17 13:31 ` Kirill Korotaev
2006-08-17 14:36 ` Dave Hansen
2006-08-18 8:12 ` [ckrm-tech] " Kirill Korotaev
2006-08-18 14:43 ` Dave Hansen
2006-08-21 8:57 ` Kirill Korotaev
2006-08-18 20:26 ` Chandra Seetharaman
2006-08-21 10:51 ` Kirill Korotaev
2006-08-21 20:55 ` Chandra Seetharaman
2006-08-16 15:42 ` [RFC][PATCH 6/7] UBC: kernel memory acconting (mark objects) Kirill Korotaev
2006-08-16 16:57 ` Alan Cox
2006-08-16 15:44 ` Kirill Korotaev [this message]
2006-08-16 17:13 ` [RFC][PATCH 7/7] UBC: proc interface Greg KH
2006-08-17 13:43 ` Kirill Korotaev
2006-08-17 15:40 ` Greg KH
2006-08-17 16:12 ` [Devel] " Kir Kolyshkin
2006-08-16 18:53 ` [RFC][PATCH] UBC: user resource beancounters Rohit Seth
2006-08-16 19:26 ` Alan Cox
2006-08-17 0:15 ` [ckrm-tech] " Chandra Seetharaman
2006-08-17 11:02 ` Srivatsa Vaddagiri
2006-08-17 13:55 ` Kirill Korotaev
2006-08-17 19:55 ` Chandra Seetharaman
2006-08-18 10:36 ` Kirill Korotaev
2006-08-18 18:53 ` Chandra Seetharaman
2006-08-18 22:55 ` Matt Helsley
2006-08-21 10:55 ` Kirill Korotaev
2006-08-21 21:04 ` Chandra Seetharaman
2006-08-18 19:39 ` Chandra Seetharaman
2006-08-21 13:24 ` Kirill Korotaev
2006-08-21 21:45 ` Chandra Seetharaman
2006-08-21 22:20 ` Alan Cox
2006-08-21 22:44 ` Chandra Seetharaman
2006-08-22 1:45 ` Rohit Seth
2006-08-22 10:02 ` Alan Cox
2006-08-22 9:57 ` Arjan van de Ven
2006-08-22 11:15 ` Alan Cox
2006-08-24 1:31 ` Rohit Seth
2006-08-22 18:55 ` Chandra Seetharaman
2006-08-24 1:44 ` Rohit Seth
2006-08-24 2:04 ` Chandra Seetharaman
2006-08-24 11:10 ` Alan Cox
2006-08-24 23:48 ` Chandra Seetharaman
2006-08-24 23:55 ` Kyle Moffett
2006-08-25 18:21 ` Chandra Seetharaman
2006-08-25 20:46 ` Alan Cox
2006-08-25 21:37 ` Chandra Seetharaman
2006-08-25 22:51 ` Alan Cox
2006-08-25 22:59 ` Chandra Seetharaman
2006-08-24 17:27 ` Rohit Seth
2006-08-24 23:52 ` Chandra Seetharaman
2006-08-25 11:12 ` Kirill Korotaev
2006-08-25 18:47 ` Chandra Seetharaman
2006-08-25 20:52 ` Alan Cox
2006-08-25 22:23 ` Chandra Seetharaman
2006-08-25 23:12 ` Alan Cox
2006-08-25 23:00 ` Chandra Seetharaman
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=44E33D5E.7000205@sw.ru \
--to=dev@sw.ru \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=ckrm-tech@lists.sourceforge.net \
--cc=devel@openvz.org \
--cc=hch@infradead.org \
--cc=hugh@veritas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=riel@redhat.com \
--cc=saw@sw.ru \
--cc=xemul@openvz.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