Skip to contentSkip to conversation

lock stat kills lock meter for -rt (core)

PATCH New Bill Huey (hui) 1 participant 1 message Dec 14, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 lock stat kills lock meter for -rt (core)

Core infrastructure files with /proc interface

============================================================

linux/lock_stat.h +147 -0
@@ -0,0 +1,147 @@
+/*
+ * By Bill Huey (hui) at <[email protected]>
+ *
+ * Release under the what ever the Linux kernel chooses for a
+ * license, GNU Public License GPL v2
+ *
+ * Tue Sep  5 17:27:48 PDT 2006
+ *	Created lock_stat.h
+ *
+ * Wed Sep  6 15:36:14 PDT 2006
+ *	Thinking about the object lifetime of a spinlock. Please refer to
+ *	comments in kernel/lock_stat.c instead.
+ *
+ */
+
+#ifndef	LOCK_STAT_H
+#define LOCK_STAT_H
+
+#ifdef CONFIG_LOCK_STAT
+
+#include <linux/list.h>
+#include <linux/rbtree.h>
+#include <linux/kallsyms.h>
+#include <linux/string.h>
+
+#include <asm/atomic.h>
+
+typedef struct lock_stat {
+	char	function[KSYM_NAME_LEN];
+	int	line;
+	char	*file;
+
+	atomic_t		ncontended;
+	unsigned int		ntracked;
+	atomic_t		ninlined;
+	atomic_t		nspinnable;
+
+	struct rb_node		rb_node;
+	struct list_head	list_head;
+} lock_stat_t;
+
+typedef lock_stat_t *lock_stat_ref_t;
+
+struct task_struct;
+
+#define LOCK_STAT_INIT(field)
+#define LOCK_STAT_INITIALIZER(field) { 			\
+		__FILE__, __FUNCTION__, __LINE__,	\
+		ATOMIC_INIT(0), LIST_HEAD_INIT(field)}
+
+#define LOCK_STAT_NOTE			__FILE__, __FUNCTION__, __LINE__
+#define LOCK_STAT_NOTE_VARS		_file, _function, _line
+#define LOCK_STAT_NOTE_PARAM_DECL	const char *_file,	\
+					const char *_function,	\
+					int _line
+
+#define __COMMA_LOCK_STAT_FN_DECL	, const char *_function
+#define __COMMA_LOCK_STAT_FN_VAR	, _function
+#define __COMMA_LOCK_STAT_NOTE_FN	, __FUNCTION__
+
+#define __COMMA_LOCK_STAT_NOTE		, LOCK_STAT_NOTE
+#define __COMMA_LOCK_STAT_NOTE_VARS	, LOCK_STAT_NOTE_VARS
+#define __COMMA_LOCK_STAT_NOTE_PARAM_DECL , LOCK_STAT_NOTE_PARAM_DECL
+
+
+#define __COMMA_LOCK_STAT_NOTE_FLLN_DECL , const char *_file, int _line
+#define __COMMA_LOCK_STAT_NOTE_FLLN	 , __FILE__, __LINE__
+#define __COMMA_LOCK_STAT_NOTE_FLLN_VARS , _file, _line
+
+#define __COMMA_LOCK_STAT_INITIALIZER	, .lock_stat = NULL,
+
+#define __COMMA_LOCK_STAT_IP_DECL	, unsigned long _ip
+#define __COMMA_LOCK_STAT_IP		, _ip
+#define __COMMA_LOCK_STAT_RET_IP	, (unsigned long) __builtin_return_address(0)
+
+extern void lock_stat_init(struct lock_stat *ls);
+extern void lock_stat_sys_init(void);
+
+#define lock_stat_is_initialized(o) ((unsigned long) (*o)->file)
+
+extern void lock_stat_note_contention(lock_stat_ref_t *ls, struct task_struct *owner, unsigned long ip);
+extern void lock_stat_print(void);
+extern void lock_stat_scoped_attach(lock_stat_ref_t *_s, LOCK_STAT_NOTE_PARAM_DECL);
+
+#define ksym_strcmp(a, b) strncmp(a, b, KSYM_NAME_LEN)
+#define ksym_strcpy(a, b) strncpy(a, b, KSYM_NAME_LEN)
+#define ksym_strlen(a) strnlen(a, KSYM_NAME_LEN)
+
+/*
+static inline char * ksym_strdup(const char *a)
+{
+	char *s = (char *) kmalloc(ksym_strlen(a), GFP_KERNEL);
+	return strncpy(s, a, KSYM_NAME_LEN);
+}
+*/
+
+#define LS_INIT(name, h) {				\
+	/*.function,*/ .file = h, .line = 1,		\
+	.ntracked = 0, .ncontended = ATOMIC_INIT(0),	\
+	.list_head = LIST_HEAD_INIT(name.list_head),	\
+	.rb_node.rb_left = NULL, .rb_node.rb_left = NULL \
+	}
+
+#define DECLARE_LS_ENTRY(name)				\
+	extern struct lock_stat _lock_stat_##name##_entry
+
+/*	char _##name##_string[] = #name;		\
+*/
+
+#define DEFINE_LS_ENTRY(name)				\
+	struct lock_stat _lock_stat_##name##_entry = LS_INIT(_lock_stat_##name##_entry, #name "_string")
+
+DECLARE_LS_ENTRY(d_alloc);
+DECLARE_LS_ENTRY(eventpoll_init_file);
+/*
+DECLARE_LS_ENTRY(get_empty_filp);
+DECLARE_LS_ENTRY(init_once_1);
+DECLARE_LS_ENTRY(init_once_2);
+DECLARE_LS_ENTRY(inode_init_once_1);
+DECLARE_LS_ENTRY(inode_init_once_2);
+DECLARE_LS_ENTRY(inode_init_once_3);
+DECLARE_LS_ENTRY(inode_init_once_4);
+DECLARE_LS_ENTRY(inode_init_once_5);
+DECLARE_LS_ENTRY(inode_init_once_6);
+DECLARE_LS_ENTRY(inode_init_once_7);
+*/
+
+#else /* CONFIG_LOCK_STAT  */
+
+#define __COMMA_LOCK_STAT_FN_DECL
+#define __COMMA_LOCK_STAT_FN_VAR
+#define __COMMA_LOCK_STAT_NOTE_FN
+
+#define __COMMA_LOCK_STAT_NOTE_FLLN_DECL
+#define __COMMA_LOCK_STAT_NOTE_FLLN
+#define __COMMA_LOCK_STAT_NOTE_FLLN_VARS
+
+#define __COMMA_LOCK_STAT_INITIALIZER	
+
+#define __COMMA_LOCK_STAT_IP_DECL
+#define __COMMA_LOCK_STAT_IP
+#define __COMMA_LOCK_STAT_RET_IP
+
+#endif /* CONFIG_LOCK_STAT */
+
+#endif /* LOCK_STAT_H */
+

============================================================

lock_stat.c +677 -0

677 lines not on this page · raw message