From: Martin Peschke <mp3@de.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: a.p.zijlstra@chello.nl, jbaron@redhat.com, rostedt@goodmis.org,
billh@gnuppy.monkey.org, mingo@elte.hu,
linux-s390@vger.kernel.org
Subject: [RFC] [Patch 1/4] statistics: no include hell for users
Date: Wed, 06 Jun 2007 23:33:29 +0200 [thread overview]
Message-ID: <1181165609.7133.20.camel@dix> (raw)
Cleaning up inclusion of header files. Don't want to create
an include hell for users.
Maintain void pointers instead of dentry pointers for debugfs files.
We never poke inside those dentries anyway. We just keep them in order
to pass them back as a kind of handle to debugfs on cleanup.
Getting rid of seq_file as parameter to the label-function.
Now we just pass a buffer to the label-function.
Signed-off-by: Martin Peschke <mp3@de.ibm.com>
---
include/linux/statistic.h | 11 ++++-------
lib/statistic.c | 23 +++++++++++++++++++----
2 files changed, 23 insertions(+), 11 deletions(-)
Index: linux/include/linux/statistic.h
===================================================================
--- linux.orig/include/linux/statistic.h
+++ linux/include/linux/statistic.h
@@ -23,9 +23,7 @@
#ifndef STATISTIC_H
#define STATISTIC_H
-#include <linux/fs.h>
#include <linux/types.h>
-#include <linux/percpu.h>
/**
* struct statistic_info - description of a class of statistics
@@ -124,17 +122,16 @@ struct statistic {
struct statistic_interface {
/* private: */
struct list_head list;
- struct dentry *debugfs_dir;
- struct dentry *data_file;
- struct dentry *def_file;
+ void *debugfs_dir;
+ void *data_file;
+ void *def_file;
/* public: */
struct statistic *stat;
struct statistic_info *info;
int number;
int (*pull)(struct statistic_interface *interface);
void (*label)(struct statistic_interface *interface,
- int i, void *key,
- struct seq_file *seq);
+ int i, void *key, char *buf, int size);
void *private;
};
Index: linux/lib/statistic.c
===================================================================
--- linux.orig/lib/statistic.c
+++ linux/lib/statistic.c
@@ -483,6 +483,23 @@ static void statistic_parse_line(struct
/* sequential files comprising user interface */
+#define STATISTIC_LABEL_SIZE 128
+static void statistic_label(struct statistic_interface *interface, int i,
+ void *key, struct seq_file *seq)
+{
+ struct statistic_info *info = &interface->info[i];
+ char *buf;
+
+ if (!(info->flags & STATISTIC_FLAGS_LABEL))
+ return;
+ buf = kzalloc(STATISTIC_LABEL_SIZE, GFP_ATOMIC);
+ if (!buf)
+ return;
+ interface->label(interface, i, key, buf, STATISTIC_LABEL_SIZE - 1);
+ seq_printf(seq, "%s", buf);
+ kfree(buf);
+}
+
struct statistic_seq_private {
struct statistic_interface *interface;
int i;
@@ -995,8 +1012,7 @@ static void _statistic_data_histogram(st
int i)
{
seq_printf(seq, "%s %s%Ld %Lu ", info->name, prefix, bound, hits);
- if (info->flags & STATISTIC_FLAGS_LABEL)
- interface->label(interface, i, &bound, seq);
+ statistic_label(interface, i, &bound, seq);
seq_printf(seq, "\n");
}
@@ -1218,8 +1234,7 @@ static void statistic_data_sparse(struct
seq_printf(seq, "0x%Lx ",
*(signed long long *)entry->key);
seq_printf(seq, "%Lu ", (unsigned long long)entry->hits);
- if (info->flags & STATISTIC_FLAGS_LABEL)
- interface->label(interface, i, entry->key, seq);
+ statistic_label(interface, i, entry->key, seq);
seq_printf(seq, "\n");
}
}
next reply other threads:[~2007-06-06 21:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-06 21:33 Martin Peschke [this message]
2007-06-06 21:39 ` [RFC] [Patch 1/4] statistics: no include hell for users Dave Hansen
2007-06-07 0:32 ` Martin Peschke
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=1181165609.7133.20.camel@dix \
--to=mp3@de.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=billh@gnuppy.monkey.org \
--cc=jbaron@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.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