CKRM: Core patch set with Classification Engine, basic controllers
Subsystems (10)
cover CKRM: Core patch set with Classification Engine, basic controllers
--
Here are the core patches for CKRM updated to 2.6.12-rc3, along with the most basic classification engine and a slightly more advanced derivative and, several bug fixes to the core code.
All of these changes have been tested on IA32 and PPC64, with CONIG_CKRM on and off, including both basic functionality tests and a variety of stress/performance tests. There are still a few minor code cleanups that are in progress, but nothing functional outstanding in this set.
Upcoming patches (soon to be included) are the memory controller (parts of which are being currently discussed on linux-mm), the listen accept queue and an IO contoller (or maybe two).
Here is the current series file:
01-diff_ckrm_events
02-diff_delay_acct
03-diff_ckrm_core
04-diff_rcfs
05-diff_taskclass
06-diff_sockclass
07-diff_numtasks
10-diff_docs
03a-missing_unlock
06a-ckrm_net_cb
06b-ckrm_sockc
07a-numtasks_config
07c-numtasks_cleanup
07c2-numtasks-undo-delete
09-01-rbce_fs
09-02-rbce_fs-main
09-03-rbce_main-opt
09-04-rbce_opt-core
09-05-rbce_core-crbce
ckrm-printf-cleanup
compiler-warning-fix
--
gerrit
PATCH 1/21 CKRM: Core CKRM Event Callbacks
--
Content-Disposition: inline; filename=01-diff_ckrm_events
Core CKRM Event Callbacks.
On exec, fork, exit, real/effective gid/uid, use CKRM to associate tasks with appropriate class.
Addressed all review comments except:
Use of __bitwise and sparse in enum's
Use of kernel list type
Signed-off-by: Shailabh Nagar <[email protected]> Signed-off-by: Hubertus Franke <[email protected]> Signed-off-by: Chandra Seetharaman <[email protected]> Signed-off-by: Gerrit Huizenga <[email protected]>
fs/exec.c | 2 include/linux/ckrm_events.h | 192 ++++++++++++++++++++++++++++++++++++++++++++ init/Kconfig | 16 +++ kernel/Makefile | 1 kernel/ckrm/Makefile | 5 + kernel/ckrm/ckrm_events.c | 86 +++++++++++++++++++ kernel/exit.c | 3 kernel/fork.c | 4 kernel/sys.c | 10 ++ 9 files changed, 319 insertions(+)
fs/exec.c +2 -0
@@ -48,6 +48,7 @@#include <linux/syscalls.h> #include <linux/rmap.h> #include <linux/acct.h> +#include <linux/ckrm_events.h> #include <asm/uaccess.h> #include <asm/mmu_context.h>
@@ -1087,6 +1088,7 @@ int search_binary_handler(struct linux_bfput (bprm->file); bprm->file =NULL ; current->did_exec =1 ; +ckrm_cb_exec (bprm->filename);return retval; }read_lock (&binfmt_lock);
include/linux/ckrm_events.h new file +192 -0
192 lines not on this page · raw message
init/Kconfig +16 -0
@@ -146,6 +146,22 @@ config BSD_PROCESS_ACCT_V3 for processing it. A preliminary version of these tools is available at <http://www.physik3.uni-rostock.de/tim/kernel/utils/acct/>. +menu "Class Based Kernel Resource Management" + +config CKRM + bool "Class Based Kernel Resource Management Core" + depends on EXPERIMENTAL + help + Class-based Kernel Resource Management is a framework for controlling + and monitoring resource allocation of user-defined groups of tasks or + incoming socket connections. For more information, please visit + http://ckrm.sf.net. + + If you say Y here, enable the Resource Class File System and at least + one of the resource controllers below. Say N if you are unsure. + +endmenu + config SYSCTL bool "Sysctl support" ---help---
kernel/ckrm/ckrm_events.c new file +86 -0
86 lines not on this page · raw message
kernel/ckrm/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for CKRM +# + +obj-y := ckrm_events.o
kernel/exit.c +3 -0
@@ -27,6 +27,7 @@#include <linux/mempolicy.h> #include <linux/cpuset.h> #include <linux/syscalls.h> +#include <linux/ckrm_events.h> #include <asm/uaccess.h> #include <asm/unistd.h>
@@ -654,6 +655,8 @@ static void exit_notify(struct task_strustruct task_struct *t;struct list_head ptrace_dead, *_p, *_n; +ckrm_cb_exit (tsk); +if (signal_pending (tsk) && !(tsk->signal->flags &SIGNAL_GROUP_EXIT ) && !thread_group_empty (tsk)) {/*
kernel/fork.c +4 -0
@@ -41,6 +41,7 @@#include <linux/profile.h> #include <linux/rmap.h> #include <linux/acct.h> +#include <linux/ckrm_events.h> #include <asm/pgtable.h> #include <asm/pgalloc.h>
@@ -174,6 +175,7 @@ static struct task_struct *dup_task_stru tsk->thread_info = ti; ti->task = tsk; +ckrm_cb_newtask (tsk);/* One for us, one for whoever does the "release_task()" (usually parent) */ atomic_set (&tsk->usage,2 );return tsk;
@@ -1216,6 +1218,8 @@ long do_fork(unsigned long clone_flags,if (!IS_ERR (p)) {struct completion vfork; +ckrm_cb_fork (p); +if (clone_flags &CLONE_VFORK ) { p->vfork_done = &vfork;init_completion (&vfork);
kernel/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_SYSFS) += ksysfs.o obj-$(CONFIG_GENERIC_HARDIRQS) += irq/ obj-$(CONFIG_SECCOMP) += seccomp.o +obj-$(CONFIG_CKRM) += ckrm/ ifneq ($(CONFIG_IA64),y) # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
kernel/sys.c +10 -0
@@ -25,6 +25,7 @@#include <linux/dcookies.h> #include <linux/suspend.h> #include <linux/tty.h> +#include <linux/ckrm_events.h> #include <linux/compat.h> #include <linux/syscalls.h>
@@ -534,6 +535,7 @@ asmlinkage long sys_setregid(gid_t rgid, current->egid = new_egid; current->gid = new_rgid;key_fsgid_changed (current); +ckrm_cb_gid ();return 0 ; }
@@ -573,6 +575,7 @@ asmlinkage long sys_setgid(gid_t gid)return -EPERM ;key_fsgid_changed (current); +ckrm_cb_gid ();return 0 ; }
@@ -663,6 +666,8 @@ asmlinkage long sys_setreuid(uid_t ruid,key_fsuid_changed (current); +ckrm_cb_uid (); +return security_task_post_setuid (old_ruid, old_euid, old_suid,LSM_SETID_RE ); }
@@ -710,6 +715,8 @@ asmlinkage long sys_setuid(uid_t uid)key_fsuid_changed (current); +ckrm_cb_uid (); +return security_task_post_setuid (old_ruid, old_euid, old_suid,LSM_SETID_ID ); }
@@ -758,6 +765,8 @@ asmlinkage long sys_setresuid(uid_t ruidkey_fsuid_changed (current); +ckrm_cb_uid (); +return security_task_post_setuid (old_ruid, old_euid, old_suid,LSM_SETID_RES ); }
@@ -809,6 +818,7 @@ asmlinkage long sys_setresgid(gid_t rgid current->sgid = sgid;key_fsgid_changed (current); +ckrm_cb_gid ();return 0 ; }
--
PATCH 2/21 CKRM: Processor Delay Accounting
In reply to [email protected]--
Content-Disposition: inline; filename=02-diff_delay_acct
CKRM processor scheduling delay accounting - provides a mechanism to In addition to counting frequency the total delay in ns is also recorded. CPU delays are specified as cpu-wait and cpu-run. I/O delays are recorded for memory and regular I/O. Information is accessible through /proc/<pid>/delay.
fs/proc/array.c | 18 +++++++++ fs/proc/base.c | 17 ++++++++ fs/proc/internal.h | 1 include/linux/sched.h | 89 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/taskdelays.h | 35 +++++++++++++++++ init/Kconfig | 8 ++++ kernel/fork.c | 1 kernel/sched.c | 20 ++++++++++ mm/memory.c | 9 ++++ 9 files changed, 197 insertions(+), 1 deletion(-)
fs/proc/array.c +18 -0
@@ -482,3 +482,21 @@ int proc_pid_statm(struct task_struct *treturn sprintf (buffer,"%d %d %d %d %d %d %d\n" , size, resident, shared, text, lib, data,0 ); } + + +int proc_pid_delay (struct task_struct *task,char * buffer) +{ +int res; + + res =sprintf (buffer,"%u %llu %llu %u %llu %u %llu\n" , + (unsigned int )get_delay (task,runs), + (uint64_t )get_delay (task,runcpu_total), + (uint64_t )get_delay (task,waitcpu_total), + (unsigned int )get_delay (task,num_iowaits), + (uint64_t )get_delay (task,iowait_total), + (unsigned int )get_delay (task,num_memwaits), + (uint64_t )get_delay (task,mem_iowait_total) + ); +return res; +} +
fs/proc/base.c +17 -0
@@ -120,6 +120,10 @@ enum pid_directory_inos {#ifdef CONFIG_AUDITSYSCALL PROC_TID_LOGINUID,#endif +#ifdef CONFIG_DELAY_ACCT +PROC_TID_DELAY_ACCT , +PROC_TGID_DELAY_ACCT , +#endifPROC_TID_FD_DIR =0x8000 ,/* 0x8000-0xffff */ PROC_TID_OOM_SCORE , PROC_TID_OOM_ADJUST,
@@ -155,6 +159,9 @@ static struct pid_entry tgid_base_stuff[#ifdef CONFIG_SECURITY E(PROC_TGID_ATTR, "attr", S_IFDIR|S_IRUGO|S_IXUGO),#endif +#ifdef CONFIG_DELAY_ACCT + E(PROC_TGID_DELAY_ACCT,"delay", S_IFREG|S_IRUGO), +#endif #ifdef CONFIG_KALLSYMS E(PROC_TGID_WCHAN, "wchan", S_IFREG|S_IRUGO),#endif
@@ -191,6 +198,9 @@ static struct pid_entry tid_base_stuff[]#ifdef CONFIG_SECURITY E(PROC_TID_ATTR, "attr", S_IFDIR|S_IRUGO|S_IXUGO),#endif +#ifdef CONFIG_DELAY_ACCT + E(PROC_TGID_DELAY_ACCT,"delay", S_IFREG|S_IRUGO), +#endif #ifdef CONFIG_KALLSYMS E(PROC_TID_WCHAN, "wchan", S_IFREG|S_IRUGO),#endif
@@ -1564,6 +1574,13 @@ static struct dentry *proc_pident_lookup ei->op.proc_read = proc_pid_wchan;break ;#endif +#ifdef CONFIG_DELAY_ACCT +case PROC_TID_DELAY_ACCT : +case PROC_TGID_DELAY_ACCT : + inode->i_fop = &proc_info_file_operations; + ei->op.proc_read = proc_pid_delay; +break ; +#endif #ifdef CONFIG_SCHEDSTATS case PROC_TID_SCHEDSTAT :case PROC_TGID_SCHEDSTAT :
fs/proc/internal.h +1 -0
@@ -36,6 +36,7 @@ extern int proc_tid_stat(struct task_strextern int proc_tgid_stat (struct task_struct *,char *);extern int proc_pid_status (struct task_struct *,char *);extern int proc_pid_statm (struct task_struct *,char *); +extern int proc_pid_delay (struct task_struct *,char *);static inline struct task_struct *proc_task (struct inode *inode) {
include/linux/sched.h +89 -0
113 lines not on this page · raw message
include/linux/taskdelays.h new file +35 -0
@@ -0,0 +1,35 @@ +/* taskdelays.h - for delay accounting +* +* Copyright (C) Hubertus Franke, IBM Corp. 2003, 2004 +* +* Has the data structure for delay counting. +* +* Latest version, more details at http://ckrm.sf.net +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2.1 of the GNU Lesser General Public License +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +#ifndef _LINUX_TASKDELAYS_H +#define _LINUX_TASKDELAYS_H + +#include <linux/config.h> +#include <linux/types.h> + +struct task_delay_info { +/* delay statistics in usecs */ +uint64_t waitcpu_total; +uint64_t runcpu_total; +uint64_t iowait_total; +uint64_t mem_iowait_total; +uint32_t runs; +uint32_t num_iowaits; +uint32_t num_memwaits; +}; + +#endif /* _LINUX_TASKDELAYS_H */
init/Kconfig +8 -0
@@ -261,6 +261,14 @@ menuconfig EMBEDDED environments which can tolerate a "non-standard" kernel. Only use this if you really know what you are doing. +config DELAY_ACCT + bool "Enable delay accounting (EXPERIMENTAL)" + help + In addition to counting frequency the total delay in ns is also + recorded. CPU delays are specified as cpu-wait and cpu-run. + I/O delays are recorded for memory and regular I/O. + Information is accessible through /proc/<pid>/delay. + config KALLSYMS bool "Load all symbols for debugging/kksymoops" if EMBEDDED default y
kernel/fork.c +1 -0
@@ -901,6 +901,7 @@ static task_t *copy_process(unsigned lonif (p->binfmt && !try_module_get (p->binfmt->module)) goto bad_fork_cleanup_put_domain; +init_delays (p); p->did_exec =0 ;copy_flags (clone_flags, p); p->pid = pid;
kernel/sched.c +20 -0
@@ -268,6 +268,8 @@ static DEFINE_PER_CPU(struct runqueue, r#define task_rq (p) cpu_rq(task_cpu(p))#define cpu_curr (cpu) (cpu_rq(cpu)->curr) +#define task_is_running (p) (this_rq() == task_rq(p)) +/* * Default context-switch locking: */
@@ -2749,6 +2751,7 @@ switch_tasks:update_cpu_clock (prev, rq, now); +add_delay_ts (prev, runcpu_total, prev->timestamp, now); prev->sleep_avg -= run_time;if ((long )prev->sleep_avg <=0 ) prev->sleep_avg =0 ;
@@ -2756,6 +2759,8 @@ switch_tasks:sched_info_switch (prev, next);if (likely (prev != next)) { +add_delay_ts (next, waitcpu_total, next->timestamp, now); +inc_delay (next, runs); next->timestamp = now; rq->nr_switches++; rq->curr = next;
@@ -3799,9 +3804,12 @@ void __sched io_schedule(void) {struct runqueue *rq = &per_cpu (runqueues,_smp_processor_id ()); +def_delay_var (dstart); +start_delay_set (dstart,PF_IOWAIT );atomic_inc (&rq->nr_iowait);schedule ();atomic_dec (&rq->nr_iowait); +add_io_delay (dstart); }EXPORT_SYMBOL (io_schedule);
@@ -3810,10 +3818,13 @@ long __sched io_schedule_timeout(long ti {struct runqueue *rq = &per_cpu (runqueues,_smp_processor_id ());long ret; +def_delay_var (dstart); +start_delay_set (dstart,PF_IOWAIT );atomic_inc (&rq->nr_iowait); ret =schedule_timeout (timeout);atomic_dec (&rq->nr_iowait); +add_io_delay (dstart);return ret; }
@@ -5002,3 +5013,12 @@ void normalize_rt_tasks(void) }#endif /* CONFIG_MAGIC_SYSRQ */ + +#ifdef CONFIG_DELAY_ACCT +int task_running_sys (struct task_struct *p) +{ +return task_is_running (p); +} +EXPORT_SYMBOL_GPL (task_running_sys); +#endif +
mm/memory.c +8 -1
@@ -2031,6 +2031,7 @@ int handle_mm_fault(struct mm_struct *mmpud_t *pud;pmd_t *pmd;pte_t *pte; +int rc;__set_current_state (TASK_RUNNING );
@@ -2044,6 +2045,9 @@ int handle_mm_fault(struct mm_struct *mm* and the SMP-safe atomic PTE updates. */ pgd =pgd_offset (mm, address); + +set_delay_flag (current,PF_MEMIO ); +spin_lock (&mm->page_table_lock); pud =pud_alloc (mm, pgd, address);
@@ -2058,10 +2062,13 @@ int handle_mm_fault(struct mm_struct *mmif (!pte) goto oom; -return handle_pte_fault (mm, vma, address, write_access, pte, pmd); + rc =handle_pte_fault (mm, vma, address, write_access, pte, pmd); +clear_delay_flag (current,PF_MEMIO ); +return rc; oom:spin_unlock (&mm->page_table_lock); +clear_delay_flag (current,PF_MEMIO );return VM_FAULT_OOM ; }
--
PATCH 3/21 CKRM: Core infrastructure
In reply to [email protected]--
Content-Disposition: inline; filename=03-diff_ckrm_core
This patch contains the core infrastructure code for CKRM. It includes the interfaces for the classification engine code and the resource control filesystems (rcfs). Rcfs is the mechanism for setting class assignments and policies within CKRM.
include/linux/ckrm_ce.h | 95 ++++ include/linux/ckrm_events.h | 38 + include/linux/ckrm_rc.h | 345 +++++++++++++++++ include/linux/rcfs.h | 96 ++++ include/linux/sched.h | 5 init/main.c | 2 kernel/ckrm/Makefile | 2 kernel/ckrm/ckrm.c | 892 ++++++++++++++++++++++++++++++++++++++++++++ kernel/ckrm/ckrmutils.c | 188 +++++++++ 9 files changed, 1648 insertions(+), 15 deletions(-)
include/linux/ckrm_ce.h new file +95 -0
@@ -0,0 +1,95 @@ +/* +* ckrm_ce.h - Header file to be used by Classification Engine of CKRM +* +* Copyright (C) Hubertus Franke, IBM Corp. 2003 +* (C) Shailabh Nagar, IBM Corp. 2003 +* (C) Chandra Seetharaman, IBM Corp. 2003 +* +* Provides data structures, macros and kernel API of CKRM for +* classification engine. +* +* Latest version, more details at http://ckrm.sf.net +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2.1 of the GNU Lesser General Public License +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +*/ + +#ifndef _LINUX_CKRM_CE_H +#define _LINUX_CKRM_CE_H + +#ifdef CONFIG_CKRM + +#include <linux/ckrm_events.h> + +/* +* Action parameters identifying the cause of a task<->class notify callback +* these can perculate up to user daemon consuming records send by the +* classification engine +*/ + +typedef void *(*ce_classify_fct ) (enum ckrm_event event,void *obj, ...); +typedef void (*ce_notify_fct ) (enum ckrm_event event,void *classobj, +void *obj); + +struct ckrm_eng_callback { +/* general state information */ +int always_callback;/* set if CE should always be called back +regardless of numclasses */ + +/* callbacks which are called without holding locks */ + +unsigned long c_interest;/* set of classification events of +* interest to CE +*/ + +/* generic classify */ +ce_classify_fct classify; + +/* class added */ +void (*class_add) (const char *name,void *core,int classtype); + +/* class deleted */ +void (*class_delete) (const char *name,void *core,int classtype); + +/* callbacks which are called while holding task_lock(tsk) */ +unsigned long n_interest;/* set of notification events of +* interest to CE +*/ +/* notify on class switch */ +ce_notify_fct notify; +}; + +struct inode ; +struct dentry ; + +struct rbce_eng_callback { +int (*mkdir) (struct inode *,struct dentry *,int );/* mkdir */ +int (*rmdir) (struct inode *,struct dentry *);/* rmdir */ +int (*mnt) (void ); +int (*umnt) (void ); +}; + +extern int ckrm_register_engine (const char *name,struct ckrm_eng_callback *); +extern int ckrm_unregister_engine (const char *name); + +extern void *ckrm_classobj (char *,int *classtype); + +extern int rcfs_register_engine (struct rbce_eng_callback *); +extern int rcfs_unregister_engine (struct rbce_eng_callback *); + +extern int ckrm_reclassify (int pid); + +#ifndef _LINUX_CKRM_RC_H + +extern void ckrm_core_grab (struct ckrm_core_class *core); +extern void ckrm_core_drop (struct ckrm_core_class *core); +#endif + +#endif /* CONFIG_CKRM */ +#endif /* _LINUX_CKRM_CE_H */
include/linux/ckrm_events.h +24 -14
@@ -108,70 +108,78 @@ int ckrm_unregister_event_cb(enum ckrm_eextern void ckrm_invoke_event_cb_chain (enum ckrm_event ev,void *arg);/* forward declarations for function arguments */ -struct task_struct ; + +#include <linux/sched.h> /* for task_struct */ +struct sock ;struct user_struct ;static inline void ckrm_cb_fork (struct task_struct *p) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_FORK , p); +ckrm_invoke_event_cb_chain (CKRM_EVENT_FORK , p); }static inline void ckrm_cb_newtask (struct task_struct *p) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_NEWTASK , p); + + p->ce_data =NULL ; +spin_lock_init (&p->ckrm_tsklock); +ckrm_invoke_event_cb_chain (CKRM_EVENT_NEWTASK , p); }static inline void ckrm_cb_exit (struct task_struct *p) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_EXIT , p); +ckrm_invoke_event_cb_chain (CKRM_EVENT_EXIT , p); + p->ce_data =NULL ; }static inline void ckrm_cb_exec (char *c) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_EXEC , c); -} +ckrm_invoke_event_cb_chain (CKRM_EVENT_EXEC , c); + }static inline void ckrm_cb_uid (void ) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_UID ,NULL ); +ckrm_invoke_event_cb_chain (CKRM_EVENT_UID ,NULL ); }static inline void ckrm_cb_gid (void ) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_GID ,NULL ); +ckrm_invoke_event_cb_chain (CKRM_EVENT_GID ,NULL ); }static inline void ckrm_cb_apptag (void ) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_APPTAG ,NULL ); +ckrm_invoke_event_cb_chain (CKRM_EVENT_APPTAG ,NULL ); }static inline void ckrm_cb_login (void ) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_LOGIN ,NULL ); +ckrm_invoke_event_cb_chain (CKRM_EVENT_LOGIN ,NULL ); }static inline void ckrm_cb_useradd (struct user_struct *u) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_USERADD , u); +ckrm_invoke_event_cb_chain (CKRM_EVENT_USERADD , u); }static inline void ckrm_cb_userdel (struct user_struct *u) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_USERDEL , u); +ckrm_invoke_event_cb_chain (CKRM_EVENT_USERDEL , u); }static inline void ckrm_cb_listen_start (struct sock *s) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_LISTEN_START , s); +ckrm_invoke_event_cb_chain (CKRM_EVENT_LISTEN_START , s); }static inline void ckrm_cb_listen_stop (struct sock *s) { -ckrm_invoke_event_cb_chain (CKRM_EVENT_LISTEN_STOP , s); +ckrm_invoke_event_cb_chain (CKRM_EVENT_LISTEN_STOP , s); } +extern void ckrm_init (void ); +#else /* !CONFIG_CKRM */ static inline void ckrm_cb_fork (struct task_struct *p) { }
@@ -187,6 +195,8 @@ static inline void ckrm_cb_userdel(strucstatic inline void ckrm_cb_listen_start (struct sock *s) { }static inline void ckrm_cb_listen_stop (struct sock *s) { } +#define ckrm_init () do { } while (0) +#endif /* CONFIG_CKRM */ #endif /* _LINUX_CKRM_EVENTS_H */
include/linux/ckrm_rc.h new file +345 -0
345 lines not on this page · raw message
include/linux/rcfs.h new file +96 -0
96 lines not on this page · raw message
include/linux/sched.h +5 -0
@@ -741,6 +741,11 @@ struct task_struct {#ifdef CONFIG_DELAY_ACCT struct task_delay_info delays;#endif +#ifdef CONFIG_CKRM +spinlock_t ckrm_tsklock; +void *ce_data; +#endif + };static inline pid_t process_group (struct task_struct *tsk)
init/main.c +2 -0
@@ -47,6 +47,7 @@#include <linux/rmap.h> #include <linux/mempolicy.h> #include <linux/key.h> +#include <linux/ckrm_events.h> #include <asm/io.h> #include <asm/bugs.h>
@@ -465,6 +466,7 @@ asmlinkage void __init start_kernel(voidrcu_init ();init_IRQ ();pidhash_init (); +ckrm_init ();init_timers ();softirq_init ();time_init ();
kernel/ckrm/ckrm.c new file +892 -0
892 lines not on this page · raw message
kernel/ckrm/ckrmutils.c new file +188 -0
188 lines not on this page · raw message
kernel/ckrm/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for CKRM # -obj-y := ckrm_events.o +obj-y += ckrm_events.o ckrm.o ckrmutils.o
--
PATCH 4/21 CKRM: Resource Control File System (rcfs)
In reply to [email protected]--
Content-Disposition: inline; filename=04-diff_rcfs
Updates CKRM Resource Control Filesystem (rcfs) to include full directory structure support. This is the user level API for managing CKRM.
fs/Makefile | 1 fs/rcfs/Makefile | 7 fs/rcfs/dir.c | 220 +++++++++++++++++++++ fs/rcfs/inode.c | 160 +++++++++++++++ fs/rcfs/magic.c | 517 +++++++++++++++++++++++++++++++++++++++++++++++++++ fs/rcfs/rootdir.c | 198 +++++++++++++++++++ fs/rcfs/super.c | 291 ++++++++++++++++++++++++++++ include/linux/rcfs.h | 20 + init/Kconfig | 10 9 files changed, 1417 insertions(+), 7 deletions(-)
fs/Makefile +1 -0
@@ -92,6 +92,7 @@ obj-$(CONFIG_JFS_FS) += jfs/ obj-$(CONFIG_XFS_FS) += xfs/ obj-$(CONFIG_AFS_FS) += afs/ obj-$(CONFIG_BEFS_FS) += befs/ +obj-$(CONFIG_RCFS_FS) += rcfs/ obj-$(CONFIG_HOSTFS) += hostfs/ obj-$(CONFIG_HPPFS) += hppfs/ obj-$(CONFIG_DEBUG_FS) += debugfs/
fs/rcfs/dir.c new file +220 -0
220 lines not on this page · raw message
fs/rcfs/inode.c new file +160 -0
160 lines not on this page · raw message
fs/rcfs/magic.c new file +517 -0
517 lines not on this page · raw message
fs/rcfs/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# +# Makefile for rcfs routines. +# + +obj-$(CONFIG_RCFS_FS) += rcfs.o + +rcfs-y := super.o inode.o dir.o rootdir.o magic.o
fs/rcfs/rootdir.c new file +198 -0
198 lines not on this page · raw message
fs/rcfs/super.c new file +291 -0
291 lines not on this page · raw message
include/linux/rcfs.h +13 -7
@@ -16,12 +16,24 @@#define RCFS_MAGF_NAMELEN 20extern int RCFS_IS_MAGIC ; +/* +* Following strings are the names of the system defined files under +* the rcfs filesystem +*/ + +#define RCFS_CONFIG_NAME "config" +#define RCFS_MEMBERS_NAME "members" +#define RCFS_STATS_NAME "stats" +#define RCFS_SHARES_NAME "shares" +#define RCFS_RECLASSIFY_NAME "reclassify" +#define rcfs_is_magic (dentry) ((dentry)->d_fsdata == &RCFS_IS_MAGIC)struct rcfs_inode_info {struct ckrm_core_class *core;char *name;struct inode vfs_inode; +struct dentry *mfdentry; };#define RCFS_DEFAULT_DIR_MODE (S_IFDIR | S_IRUGO | S_IXUGO)
@@ -45,16 +57,10 @@ struct rcfs_mfdesc {extern struct rcfs_mfdesc *genmfdesc[]; -struct rcfs_inode_info *RCFS_I (struct inode *inode); - -int rcfs_empty (struct dentry *); +struct rcfs_inode_info *rcfs_get_inode_info (struct inode *inode);struct inode *rcfs_get_inode (struct super_block *,int ,dev_t );int rcfs_mknod (struct inode *,struct dentry *,int ,dev_t ); -int _rcfs_mknod (struct inode *,struct dentry *,int ,dev_t ); -int rcfs_mkdir (struct inode *,struct dentry *,int ); -struct ckrm_core_class *rcfs_make_core (struct dentry *,struct ckrm_core_class *);struct dentry *rcfs_set_magf_byname (char *,void *); -struct dentry *rcfs_create_internal (struct dentry *,struct rcfs_magf *,int );int rcfs_delete_internal (struct dentry *);int rcfs_create_magic (struct dentry *,struct rcfs_magf *,int );
init/Kconfig +10 -0
@@ -160,6 +160,16 @@ config CKRM If you say Y here, enable the Resource Class File System and at least one of the resource controllers below. Say N if you are unsure. +config RCFS_FS + tristate "Resource Class File System (User API)" + depends on CKRM + default m + help + RCFS is the filesystem API for CKRM. Compiling it as a module permits + users to only load RCFS if they intend to use CKRM. + + Say M if unsure, Y to save on module loading. N doesn't make sense + when CKRM has been configured. endmenu config SYSCTL
--
PATCH 5/21 CKRM: Classtype definitions for task class
In reply to [email protected]--
Content-Disposition: inline; filename=05-diff_taskclass
This patch provides the extensions for CKRM to track task classes. This is the base to enable task class based resource control for cpu, memory and disk I/O.
fs/rcfs/Makefile | 1 fs/rcfs/rootdir.c | 12 fs/rcfs/tc_magic.c | 93 +++++ include/linux/ckrm_tc.h | 46 ++ include/linux/sched.h | 11 init/Kconfig | 12 kernel/ckrm/Makefile | 1 kernel/ckrm/ckrm_tc.c | 745 ++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 915 insertions(+), 6 deletions(-)
fs/rcfs/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_RCFS_FS) += rcfs.o rcfs-y := super.o inode.o dir.o rootdir.o magic.o +rcfs-$(CONFIG_CKRM_TYPE_TASKCLASS) += tc_magic.o
fs/rcfs/rootdir.c +10 -2
@@ -58,7 +58,7 @@ int rcfs_unregister_engine(struct rbce_ereturn 0 ; } -EXPORT_SYMBOL (rcfs_unregister_engine); +EXPORT_SYMBOL_GPL (rcfs_unregister_engine);/* * rcfs_mkroot
@@ -183,6 +183,10 @@ int rcfs_deregister_classtype(struct ckrEXPORT_SYMBOL_GPL (rcfs_deregister_classtype); +#ifdef CONFIG_CKRM_TYPE_TASKCLASS +extern struct rcfs_mfdesc tc_mfdesc; +#endif +/* Common root and magic file entries. * root name, root permissions, magic file names and magic file permissions * are needed by all entities (classtypes and classification engines) existing
@@ -193,6 +197,10 @@ EXPORT_SYMBOL_GPL(rcfs_deregister_classt* table to initialize their magf entries. */ -struct rcfs_mfdesc *genmfdesc[] = { +struct rcfs_mfdesc *genmfdesc[CKRM_MAX_CLASSTYPES ] = { +#ifdef CONFIG_CKRM_TYPE_TASKCLASS + &tc_mfdesc, +#elseNULL , +#endif };
fs/rcfs/tc_magic.c new file +93 -0
93 lines not on this page · raw message
include/linux/ckrm_tc.h new file +46 -0
46 lines not on this page · raw message
include/linux/sched.h +7 -4
@@ -738,14 +738,17 @@ struct task_struct {nodemask_t mems_allowed;int cpuset_mems_generation;#endif -#ifdef CONFIG_DELAY_ACCT -struct task_delay_info delays; -#endif #ifdef CONFIG_CKRM spinlock_t ckrm_tsklock;void *ce_data; +#ifdef CONFIG_CKRM_TYPE_TASKCLASS +struct ckrm_task_class *taskclass; +struct list_head taskclass_link; +#endif /* CONFIG_CKRM_TYPE_TASKCLASS */ +#endif /* CONFIG_CKRM */ +#ifdef CONFIG_DELAY_ACCT +struct task_delay_info delays;#endif - };static inline pid_t process_group (struct task_struct *tsk)
init/Kconfig +12 -0
@@ -170,6 +170,18 @@ config RCFS_FS Say M if unsure, Y to save on module loading. N doesn't make sense when CKRM has been configured. + +config CKRM_TYPE_TASKCLASS + bool "Class Manager for Task Groups" + depends on CKRM && RCFS_FS + default y + help + TASKCLASS provides the extensions for CKRM to track task classes + This is the base to enable task class based resource control for + cpu, memory and disk I/O. + + Say Y if unsure + endmenu config SYSCTL
kernel/ckrm/ckrm_tc.c new file +745 -0
745 lines not on this page · raw message
kernel/ckrm/Makefile +1 -0
@@ -3,3 +3,4 @@ # obj-y += ckrm_events.o ckrm.o ckrmutils.o +obj-$(CONFIG_CKRM_TYPE_TASKCLASS) += ckrm_tc.o
--
PATCH 6/21 CKRM: Classtype definitions for socket class
In reply to [email protected]--
Content-Disposition: inline; filename=06-diff_sockclass
This patch provides the extensions for CKRM to track per socket classes. This is the base to enable socket based resource control for inbound connection control, bandwidth control etc.
fs/rcfs/Makefile | 1 fs/rcfs/rootdir.c | 10 fs/rcfs/socket_fs.c | 280 +++++++++++++++++++++++ include/linux/ckrm_net.h | 42 +++ include/net/sock.h | 3 include/net/tcp.h | 4 init/Kconfig | 11 kernel/ckrm/Makefile | 1 kernel/ckrm/ckrm_sockc.c | 559 +++++++++++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_ipv4.c | 4 10 files changed, 914 insertions(+), 1 deletion(-)
fs/rcfs/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-$(CONFIG_RCFS_FS) += rcfs.o rcfs-y := super.o inode.o dir.o rootdir.o magic.o rcfs-$(CONFIG_CKRM_TYPE_TASKCLASS) += tc_magic.o +rcfs-$(CONFIG_CKRM_TYPE_SOCKETCLASS) += socket_fs.o
fs/rcfs/rootdir.c +10 -0
@@ -187,6 +187,10 @@ EXPORT_SYMBOL_GPL(rcfs_deregister_classtextern struct rcfs_mfdesc tc_mfdesc;#endif +#ifdef CONFIG_CKRM_TYPE_SOCKETCLASS +extern struct rcfs_mfdesc rcfs_sock_mfdesc; +#endif +/* Common root and magic file entries. * root name, root permissions, magic file names and magic file permissions * are needed by all entities (classtypes and classification engines) existing
@@ -203,4 +207,10 @@ struct rcfs_mfdesc *genmfdesc[CKRM_MAX_C#else NULL,#endif +#ifdef CONFIG_CKRM_TYPE_SOCKETCLASS + &rcfs_sock_mfdesc, +#else + NULL, +#endif + };
fs/rcfs/socket_fs.c new file +280 -0
280 lines not on this page · raw message
include/linux/ckrm_net.h new file +42 -0
42 lines not on this page · raw message
include/net/sock.h +3 -0
@@ -112,6 +112,8 @@ struct sock_common {atomic_t skc_refcnt; }; +struct ckrm_net_struct ; +/** * struct sock - network layer representation of sockets * @__sk_common - shared layout with tcp_tw_bucket
@@ -233,6 +235,7 @@ struct sock {struct timeval sk_stamp;struct socket *sk_socket;void *sk_user_data; +struct ckrm_net_struct *sk_ckrm_ns;struct page *sk_sndmsg_page;struct sk_buff *sk_send_head;__u32 sk_sndmsg_off;
include/net/tcp.h +4 -0
@@ -800,6 +800,7 @@ extern int tcp_rcv_established(structextern void tcp_rcv_space_adjust (struct sock *sk); +enum tcp_ack_state_t {TCP_ACK_SCHED =1 ,
@@ -930,6 +931,9 @@ extern void tcp_unhash(struct sock *skextern int tcp_v4_hash_connecting (struct sock *sk); +extern struct sock *tcp_v4_lookup_listener (u32 daddr, +unsigned short hnum, +int dif);/* From syncookies.c */ extern struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
init/Kconfig +11 -0
@@ -182,6 +182,17 @@ config CKRM_TYPE_TASKCLASS Say Y if unsure +config CKRM_TYPE_SOCKETCLASS + bool "Class Manager for socket groups" + depends on CKRM && RCFS_FS + default y + help + SOCKET provides the extensions for CKRM to track per socket + classes. This is the base to enable socket based resource + control for inbound connection control, bandwidth control etc. + + Say Y if unsure. + endmenu config SYSCTL
kernel/ckrm/ckrm_sockc.c new file +559 -0
559 lines not on this page · raw message
kernel/ckrm/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-y += ckrm_events.o ckrm.o ckrmutils.o obj-$(CONFIG_CKRM_TYPE_TASKCLASS) += ckrm_tc.o +obj-$(CONFIG_CKRM_TYPE_SOCKETCLASS) += ckrm_sockc.o
net/ipv4/tcp_ipv4.c +3 -1
@@ -448,7 +448,8 @@ static struct sock *__tcp_v4_lookup_list }/* Optimize the common listener case. */ -static inline struct sock *tcp_v4_lookup_listener (u32 daddr, +/* XXX: Was inline - need to use for CKRM, fix before next release */ +struct sock *tcp_v4_lookup_listener (u32 daddr,unsigned short hnum,int dif) {struct sock *sk =NULL ;
@@ -2645,6 +2646,7 @@ EXPORT_SYMBOL(tcp_prot);EXPORT_SYMBOL (tcp_put_port);EXPORT_SYMBOL (tcp_unhash);EXPORT_SYMBOL (tcp_v4_conn_request); +EXPORT_SYMBOL (tcp_v4_lookup_listener);EXPORT_SYMBOL (tcp_v4_connect);EXPORT_SYMBOL (tcp_v4_do_rcv);EXPORT_SYMBOL (tcp_v4_rebuild_header);
--
PATCH 7/21 CKRM: Numtasks Controller
In reply to [email protected]--
Content-Disposition: inline; filename=07-diff_numtasks
This patch provides a resource controller for controlling the number of tasks per class in CKRM.
include/linux/ckrm_tsk.h | 35 ++ init/Kconfig | 10 kernel/ckrm/Makefile | 3 kernel/ckrm/ckrm_numtasks.c | 522 +++++++++++++++++++++++++++++++++++++++ kernel/ckrm/ckrm_numtasks_stub.c | 53 +++ kernel/fork.c | 6 6 files changed, 628 insertions(+), 1 deletion(-)
include/linux/ckrm_tsk.h new file +35 -0
@@ -0,0 +1,35 @@ +/* ckrm_tsk.h - No. of tasks resource controller for CKRM +* +* Copyright (C) Chandra Seetharaman, IBM Corp. 2003 +* +* Provides No. of tasks resource controller for CKRM +* +* Latest version, more details at http://ckrm.sf.net +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef _LINUX_CKRM_TSK_H +#define _LINUX_CKRM_TSK_H + +#ifdef CONFIG_CKRM_TYPE_TASKCLASS +#include <linux/ckrm_rc.h> + +typedef int (*get_ref_t ) (struct ckrm_core_class *,int ); +typedef void (*put_ref_t ) (struct ckrm_core_class *); + +extern int numtasks_get_ref (struct ckrm_core_class *,int ); +extern void numtasks_put_ref (struct ckrm_core_class *); +extern void ckrm_numtasks_register (get_ref_t ,put_ref_t ); + +#else /* CONFIG_CKRM_TYPE_TASKCLASS */ + +#define numtasks_get_ref (core_class, ref) (1) +#define numtasks_put_ref (core_class) do {} while (0) + +#endif /* CONFIG_CKRM_TYPE_TASKCLASS */ +#endif /* _LINUX_CKRM_RES_H */
init/Kconfig +10 -0
@@ -193,6 +193,16 @@ config CKRM_TYPE_SOCKETCLASS Say Y if unsure. +config CKRM_RES_NUMTASKS + tristate "Number of Tasks Resource Manager" + depends on CKRM_TYPE_TASKCLASS + default y + help + Provides a Resource Controller for CKRM that allows limiting no of + tasks a task class can have. + + Say N if unsure, Y to use the feature. + endmenu config SYSCTL
kernel/ckrm/ckrm_numtasks.c new file +522 -0
522 lines not on this page · raw message
kernel/ckrm/ckrm_numtasks_stub.c new file +53 -0
53 lines not on this page · raw message
kernel/ckrm/Makefile +2 -1
@@ -3,5 +3,6 @@ # obj-y += ckrm_events.o ckrm.o ckrmutils.o -obj-$(CONFIG_CKRM_TYPE_TASKCLASS) += ckrm_tc.o +obj-$(CONFIG_CKRM_TYPE_TASKCLASS) += ckrm_tc.o ckrm_numtasks_stub.o obj-$(CONFIG_CKRM_TYPE_SOCKETCLASS) += ckrm_sockc.o +obj-$(CONFIG_CKRM_RES_NUMTASKS) += ckrm_numtasks.o
kernel/fork.c +6 -0
@@ -42,6 +42,8 @@#include <linux/rmap.h> #include <linux/acct.h> #include <linux/ckrm_events.h> +#include <linux/ckrm_tsk.h> +#include <linux/ckrm_tc.h> #include <asm/pgtable.h> #include <asm/pgalloc.h>
@@ -1211,6 +1213,9 @@ long do_fork(unsigned long clone_flags, clone_flags |=CLONE_PTRACE ; } +if (numtasks_get_ref (¤t->taskclass->core,0 ) ==0 ) { +return -ENOMEM ; + } p =copy_process (clone_flags, stack_start, regs, stack_size, parent_tidptr, child_tidptr, pid);/* * Do this prior waking up the new thread - the thread pointer
@@ -1250,6 +1255,7 @@ long do_fork(unsigned long clone_flags,ptrace_notify ((PTRACE_EVENT_VFORK_DONE <<8 ) |SIGTRAP ); } }else { +numtasks_put_ref (¤t->taskclass->core);free_pidmap (pid); pid =PTR_ERR (p); }
--
PATCH 8/21 CKRM: Documentation
In reply to [email protected]--
Content-Disposition: inline; filename=10-diff_docs
This patch adds all current documentation on CKRM.
TODO | 16 +++++++++ ckrm_basics | 66 +++++++++++++++++++++++++++++++++++++++ core_usage | 72 +++++++++++++++++++++++++++++++++++++++++++ crbce | 33 +++++++++++++++++++ installation | 70 ++++++++++++++++++++++++++++++++++++++++++ rbce_basics | 67 ++++++++++++++++++++++++++++++++++++++++ rbce_usage | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 422 insertions(+)
Documentation/ckrm/ckrm_basics new file +66 -0
@@ -0,0 +1,66 @@ +CKRM Basics +------------- +A brief review of CKRM concepts and terminology will help make installation +and testing easier. For more details, please visit http://ckrm.sf.net. + +Currently there are two class types, taskclass and socketclass for grouping, +regulating and monitoring tasks and sockets respectively. + +To avoid repeating instructions for each classtype, this document assumes a +task to be the kernel object being grouped. By and large, one can replace task +with socket and taskclass with socketclass. + +RCFS depicts a CKRM class as a directory. Hierarchy of classes can be +created in which children of a class share resources allotted to +the parent. Tasks can be classified to any class which is at any level. +There is no correlation between parent-child relationship of tasks and +the parent-child relationship of classes they belong to. + +Without a Classification Engine, class is inherited by a task. A privileged +user can reassigned a task to a class as described below, after which all +the child tasks under that task will be assigned to that class, unless the +user reassigns any of them. + +A Classification Engine, if one exists, will be used by CKRM to +classify a task to a class. The Rule based classification engine uses some +of the attributes of the task to classify a task. When a CE is present +class is not inherited by a task. + +Characteristics of a class can be accessed/changed through the following magic +files under the directory representing the class: + +shares: allows to change the shares of different resources managed by the + class +stats: allows to see the statistics associated with each resources managed + by the class +target: allows to assign a task to a class. If a CE is present, assigning + a task to a class through this interface will prevent CE from + reassigning the task to any class during reclassification. +members: allows to see which tasks has been assigned to a class +config: allow to view and modify configuration information of different + resources in a class. + +Resource allocations for a class is controlled by the parameters: + +guarantee: specifies how much of a resource is guranteed to a class. A + special value DONT_CARE(-2) mean that there is no specific + guarantee of a resource is specified, this class may not get + any resource if the system is runing short of resources +limit: specifies the maximum amount of resource that is allowed to be + allocated by a class. A special value DONT_CARE(-2) mean that + there is no specific limit is specified, this class can get all + the resources available. +total_guarantee: total guarantee that is allowed among the children of this + class. In other words, the sum of "guarantee"s of all children + of this class cannot exit this number. +max_limit: Maximum "limit" allowed for any of this class's children. In + other words, "limit" of any children of this class cannot exceed + this value. + +None of this parameters are absolute or have any units associated with +them. These are just numbers(that are relative to its parents') that are +used to calculate the absolute number of resource available for a specific +class. + +Note: The root class has an absolute number of resource units associated with it. +
Documentation/ckrm/core_usage new file +72 -0
72 lines not on this page · raw message
Documentation/ckrm/crbce new file +33 -0
@@ -0,0 +1,33 @@ +CRBCE +---------- + +crbce is a superset of rbce. In addition to providing automatic +classification, the crbce module +- monitors per-process delay data that is collected by the delay +accounting patch +- collects data on significant kernel events where reclassification +could occur e.g. fork/exec/setuid/setgid etc., and +- uses relayfs to supply both these datapoints to userspace + +To illustrate the utility of the data gathered by crbce, we provide a +userspace daemon called crbcedmn that prints the header info received +from the records sent by the crbce module. + +0. Ensure that a CKRM-enabled kernel with following options configured + has been compiled. At a minimum, core, rcfs, at least one classtype, + delay-accounting patch and relayfs. For testing, it is recommended + all classtypes and resource controllers be compiled as modules. + +1. Ensure that the Makefile's BUILD_CRBCE=1 and KDIR points to the + kernel of step 1 and call make. + This also builds the userspace daemon, crbcedmn. + +2..9 Same as rbce installation and testing instructions, + except replacing rbce.ko with crbce.ko + +10. Read the pseudo daemon help file + # ./crbcedmn -h + +11. Run the crbcedmn to display all records being processed + # ./crbcedmn +
Documentation/ckrm/installation new file +70 -0
70 lines not on this page · raw message
Documentation/ckrm/rbce_basics new file +67 -0
67 lines not on this page · raw message
Documentation/ckrm/rbce_usage new file +98 -0
98 lines not on this page · raw message
Documentation/ckrm/TODO new file +16 -0
@@ -0,0 +1,16 @@ +Current tasks in queue + +- Use __bitfield for enums +- Add listenaq controller +- Add RBCE/CRBCE +- Add memory controller +- Add I/O controller +- Add forkrate control to numtasks controller +- remove target file and move functionality to members file +- init_task is not classified under any class +- use netlink instead of relayfs for crbce +- convert refcount usages to kref_t +- add kerneldoc format headers to user consumable functions/macros +- convert ckrm_init() to use standard initcalls +- verify that the LGPL/GPL header/symbol usage is correct +-
--
PATCH 9/21 CKRM: Add missing read_unlock
In reply to [email protected]--
Content-Disposition: inline; filename=03a-missing_unlock
Function returns without unlocking the readlock in a case. This patch fixes it.
ckrm.c | 1 + 1 files changed, 1 insertion(+)
kernel/ckrm/ckrm.c +1 -0
@@ -106,6 +106,7 @@ void *ckrm_classobj(char *classname, intif (core->name && !strcmp (core->name, classname)) {/* FIXME: should grep reference. */ *classtype_id = ctype->type_id; +read_unlock (&ckrm_class_lock);return core; } }
--
PATCH 10/21 CKRM: Move Callbacks from listenaq to socketclass
In reply to [email protected]--
Content-Disposition: inline; filename=06a-ckrm_net_cb
Callbacks are not called from appropriate places in the socketclass patch. The patch was wrongly present in the listenaq controller. Moving from listenaq controller to socketclass patch.
tcp.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-)
net/ipv4/tcp.c +4 -1
@@ -263,6 +263,7 @@#include <net/xfrm.h> #include <net/ip.h> +#include <linux/ckrm_events.h> #include <asm/uaccess.h> #include <asm/ioctls.h>
@@ -496,7 +497,7 @@ int tcp_listen_start(struct sock *sk)sk_dst_reset (sk); sk->sk_prot->hash (sk); - +ckrm_cb_listen_start (sk);return 0 ; }
@@ -529,6 +530,8 @@ static void tcp_listen_stop (struct sockwrite_unlock_bh (&tp->syn_wait_lock); tp->accept_queue = tp->accept_queue_tail =NULL ; +ckrm_cb_listen_stop (sk); +if (lopt->qlen) {for (i =0 ; i <TCP_SYNQ_HSIZE ; i++) {while ((req = lopt->syn_table[i]) !=NULL ) {
--
PATCH 11/21 CKRM: Change ipaddr_port syntax
In reply to [email protected]--
Content-Disposition: inline; filename=06b-ckrm_sockc
Change the ipaddr_port syntax from "xxx.xxx.xxx.xxx\\YY" to "xxx.xxx.xxx.xxx:YY" to make it easy for cut-n-paste.
ckrm_sockc.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
kernel/ckrm/ckrm_sockc.c +5 -5
@@ -343,7 +343,7 @@ static int ckrm_sock_show_members(structclass_lock (core);list_for_each (lh, &core->objlist) { ns = container_of(lh, struct ckrm_net_struct, ckrm_link); -seq_printf (seq,"%d.%d.%d.%d\\%d\n" , +seq_printf (seq,"%d.%d.%d.%d:%d\n" ,NIPQUAD (ns->ns_daddrv4), ns->ns_dport); }class_unlock (core);
@@ -459,7 +459,7 @@ ckrm_sock_forced_reclassify(struct ckrm_return -EPERM ;if (id !=0 )return -EINVAL ; -printk ("ckrm_sock_class: reclassify all not net implemented\n" ); +printk ("socketclass: reclassify all not implemented yet\n" );return 0 ; }
@@ -478,15 +478,15 @@ ckrm_sock_forced_reclassify(struct ckrm_while (*p2 && (*p2 !='=' )) ++p2; p2++; - p2 =v4toi (p2,'\\' , &(v4addr)); + p2 =v4toi (p2,':' , &(v4addr)); ns.ns_daddrv4 =htonl (v4addr); ns.ns_family =AF_INET ; - p2 =v4toi (++p2,':' , &tmp); + p2 =v4toi (++p2,'/' , &tmp); ns.ns_dport = (__u16 ) tmp;if (*p2) p2 =v4toi (++p2,'\0' , &ns.ns_pid);ckrm_sock_forced_reclassify_ns (&ns, target); -break ; +return 0 ;case IPV6 :printk (KERN_INFO "rcfs: IPV6 not supported yet\n" );
--
PATCH 12/21 CKRM: Check to see if my guarantee is set to DONTCARE
In reply to [email protected]--
Content-Disposition: inline; filename=07a-numtasks_config
recalc and propagate was not checking for class's my_guarantee and my_limit againt DONT_CARE. This was leading to different wierd problems. This patch fixes it.
ckrm_numtasks.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
kernel/ckrm/ckrm_numtasks.c +6 -3
@@ -296,7 +296,8 @@ recalc_and_propagate(struct ckrm_numtaskstruct ckrm_shares *self = &res->shares;/* calculate cnt_guarantee and cnt_limit */ -if (parres->cnt_guarantee ==CKRM_SHARE_DONTCARE ) { +if ((parres->cnt_guarantee ==CKRM_SHARE_DONTCARE ) || + (self->my_guarantee ==CKRM_SHARE_DONTCARE )) { res->cnt_guarantee =CKRM_SHARE_DONTCARE ; }else if (par->total_guarantee) {u64 temp = (u64 ) self->my_guarantee * parres->cnt_guarantee;
@@ -306,7 +307,8 @@ recalc_and_propagate(struct ckrm_numtask res->cnt_guarantee =0 ; } -if (parres->cnt_limit ==CKRM_SHARE_DONTCARE ) { +if ((parres->cnt_limit ==CKRM_SHARE_DONTCARE ) || + (self->my_limit ==CKRM_SHARE_DONTCARE )) { res->cnt_limit =CKRM_SHARE_DONTCARE ; }else if (par->max_limit) {u64 temp = (u64 ) self->my_limit * parres->cnt_limit;
@@ -317,7 +319,8 @@ recalc_and_propagate(struct ckrm_numtask }/* Calculate unused units */ -if (res->cnt_guarantee ==CKRM_SHARE_DONTCARE ) { +if ((res->cnt_guarantee ==CKRM_SHARE_DONTCARE ) || + (self->my_guarantee ==CKRM_SHARE_DONTCARE )) { res->cnt_unused =CKRM_SHARE_DONTCARE ; }else if (self->total_guarantee) {u64 temp = (u64 ) self->unused_guarantee * res->cnt_guarantee;
--
PATCH 13/21 CKRM: Minor cosmetic cleanups in numtasks controller
In reply to [email protected]--
Content-Disposition: inline; filename=07c-numtasks_cleanup
Simple code cleanup. No functional changes.
ckrm_numtasks.c | 98 +++++++++++++++++--------------------------------------- 1 files changed, 30 insertions(+), 68 deletions(-)
kernel/ckrm/ckrm_numtasks.c +30 -68
@@ -99,17 +99,6 @@ static void numtasks_res_initcls_one(strreturn ; } -#if 0 -static void numtasks_res_initcls (void *my_res) -{ -struct ckrm_numtasks *res = my_res; - -/* Write a version which propagates values all the way down -and replace rcbs callback with that version */ - -} -#endif -static int numtasks_get_ref_local (struct ckrm_core_class *core,int force) {int rc, resid = numtasks_rcbs.resid;
@@ -144,29 +133,24 @@ static int numtasks_get_ref_local(struct res->borrow_failures++; res->tot_borrow_failures++; } - }else { + }else rc = force; - } }else if (res->over_guarantee) { res->over_guarantee =0 ; -if (res->max_limit_failures < res->limit_failures) { +if (res->max_limit_failures < res->limit_failures) res->max_limit_failures = res->limit_failures; - } -if (res->max_borrow_sucesses < res->borrow_sucesses) { +if (res->max_borrow_sucesses < res->borrow_sucesses) res->max_borrow_sucesses = res->borrow_sucesses; - } -if (res->max_borrow_failures < res->borrow_failures) { +if (res->max_borrow_failures < res->borrow_failures) res->max_borrow_failures = res->borrow_failures; - } res->limit_failures =0 ; res->borrow_sucesses =0 ; res->borrow_failures =0 ; } -if (!rc) { +if (!rc)atomic_dec (&res->cnt_cur_alloc); - }return rc; }
@@ -175,18 +159,12 @@ static void numtasks_put_ref_local(strucint resid = numtasks_rcbs.resid;struct ckrm_numtasks *res; -if ((resid ==-1 ) || (core ==NULL )) { +if ((resid ==-1 ) || (core ==NULL ))return ; - } res = ckrm_get_res_class(core, resid, struct ckrm_numtasks);if (res ==NULL )return ; -if (unlikely (atomic_read (&res->cnt_cur_alloc) ==0 )) { -printk (KERN_WARNING "numtasks_put_ref: Trying to decrement " -"counter below 0\n" ); -return ; - }atomic_dec (&res->cnt_cur_alloc);if (atomic_read (&res->cnt_borrowed) >0 ) {atomic_dec (&res->cnt_borrowed);
@@ -242,19 +220,10 @@ static void numtasks_res_free(void *my_r parres = ckrm_get_res_class(res->parent, resid, struct ckrm_numtasks); -if (unlikely (atomic_read (&res->cnt_cur_alloc) <0 )) { -printk (KERN_WARNING "numtasks_res: counter below 0\n" ); - } -if (unlikely (atomic_read (&res->cnt_cur_alloc) >0 || -atomic_read (&res->cnt_borrowed) >0 )) { -printk (KERN_WARNING "numtasks_res_free: resource still " -"alloc'd %p\n" , res); -if ((borrowed =atomic_read (&res->cnt_borrowed)) >0 ) { -for (i =0 ; i < borrowed; i++) { -numtasks_put_ref_local (parres->core); - } - } - } +if ((borrowed =atomic_read (&res->cnt_borrowed)) >0 ) +for (i =0 ; i < borrowed; i++) +numtasks_put_ref_local (parres->core); +/* return child's limit/guarantee to parent node */ spin_lock (&parres->cnt_lock);child_guarantee_changed (&parres->shares, res->shares.my_guarantee,0 );
@@ -264,14 +233,12 @@ static void numtasks_res_free(void *my_r maxlimit =0 ;while ((child =ckrm_get_next_child (parres->core, child)) !=NULL ) { childres = ckrm_get_res_class(child, resid, struct ckrm_numtasks); -if (maxlimit < childres->shares.my_limit) { +if (maxlimit < childres->shares.my_limit) maxlimit = childres->shares.my_limit; - } }ckrm_unlock_hier (parres->core); -if (parres->shares.cur_max_limit < maxlimit) { +if (parres->shares.cur_max_limit < maxlimit) parres->shares.cur_max_limit = maxlimit; - }spin_unlock (&parres->cnt_lock);kfree (res);
@@ -297,39 +264,37 @@ recalc_and_propagate(struct ckrm_numtask/* calculate cnt_guarantee and cnt_limit */ if ((parres->cnt_guarantee ==CKRM_SHARE_DONTCARE ) || - (self->my_guarantee ==CKRM_SHARE_DONTCARE )) { + (self->my_guarantee ==CKRM_SHARE_DONTCARE )) res->cnt_guarantee =CKRM_SHARE_DONTCARE ; - }else if (par->total_guarantee) { +else if (par->total_guarantee) {u64 temp = (u64 ) self->my_guarantee * parres->cnt_guarantee;do_div (temp, par->total_guarantee); res->cnt_guarantee = (int ) temp; - }else { + }else res->cnt_guarantee =0 ; - }if ((parres->cnt_limit ==CKRM_SHARE_DONTCARE ) || - (self->my_limit ==CKRM_SHARE_DONTCARE )) { + (self->my_limit ==CKRM_SHARE_DONTCARE )) res->cnt_limit =CKRM_SHARE_DONTCARE ; - }else if (par->max_limit) { +else if (par->max_limit) {u64 temp = (u64 ) self->my_limit * parres->cnt_limit;do_div (temp, par->max_limit); res->cnt_limit = (int ) temp; - }else { + }else res->cnt_limit =0 ; - }/* Calculate unused units */ if ((res->cnt_guarantee ==CKRM_SHARE_DONTCARE ) || - (self->my_guarantee ==CKRM_SHARE_DONTCARE )) { + (self->my_guarantee ==CKRM_SHARE_DONTCARE )) res->cnt_unused =CKRM_SHARE_DONTCARE ; - }else if (self->total_guarantee) { +else if (self->total_guarantee) {u64 temp = (u64 ) self->unused_guarantee * res->cnt_guarantee;do_div (temp, self->total_guarantee); res->cnt_unused = (int ) temp; - }else { + }else res->cnt_unused =0 ; - } } +/* propagate to children */ ckrm_lock_hier (res->core);while ((child =ckrm_get_next_child (res->core, child)) !=NULL ) {
@@ -368,21 +333,19 @@ static int numtasks_set_share_values(voiif ((rc ==0 ) && parres) {/* Calculate parent's unused units */ -if (parres->cnt_guarantee ==CKRM_SHARE_DONTCARE ) { +if (parres->cnt_guarantee ==CKRM_SHARE_DONTCARE ) parres->cnt_unused =CKRM_SHARE_DONTCARE ; - }else if (par->total_guarantee) { +else if (par->total_guarantee) {u64 temp = (u64 ) par->unused_guarantee * parres->cnt_guarantee;do_div (temp, par->total_guarantee); parres->cnt_unused = (int ) temp; - }else { + }else parres->cnt_unused =0 ; - }recalc_and_propagate (res, parres); }spin_unlock (&res->cnt_lock); -if (res->parent) { +if (res->parent)spin_unlock (&parres->cnt_lock); - }return rc; }
@@ -403,7 +366,7 @@ static int numtasks_get_stats(void *my_rif (!res)return -EINVAL ; -seq_printf (sfile,"Number of tasks resource:\n" ); +seq_printf (sfile,"---------Number of tasks stats start---------\n" );seq_printf (sfile,"Total Over limit failures: %d\n" , res->tot_limit_failures); seq_printf(sfile, "Total Over guarantee sucesses: %d\n",
@@ -417,6 +380,7 @@ static int numtasks_get_stats(void *my_r res->max_borrow_sucesses);seq_printf (sfile,"Maximum Over guarantee failures: %d\n" , res->max_borrow_failures); +seq_printf (sfile,"---------Number of tasks stats end---------\n" );#ifdef NUMTASKS_DEBUG seq_printf (sfile, "cur_alloc %d; borrowed %d; cnt_guar %d; cnt_limit %d "
@@ -468,9 +432,8 @@ static void numtasks_change_resclass(voi }numtasks_put_ref_local (oldres->core); } -if (newres) { +if (newres) (void )numtasks_get_ref_local (newres->core,1 ); - } }struct ckrm_res_ctlr numtasks_rcbs = {
@@ -512,9 +475,8 @@ int __init init_ckrm_numtasks_res(void) void __exit exit_ckrm_numtasks_res(void) { -if (numtasks_rcbs.resid !=-1 ) { +if (numtasks_rcbs.resid !=-1 )ckrm_numtasks_register (NULL ,NULL ); - }ckrm_unregister_res_ctlr (&numtasks_rcbs); numtasks_rcbs.resid =-1 ; }
--
PATCH 14/21 CKRM: undo removal of check in numtasks_put_ref_local
In reply to [email protected]--
Content-Disposition: inline; filename=07c2-numtasks-undo-delete
Removed without realizing it. Putting it back.
ckrm_numtasks.c | 3 +++ 1 files changed, 3 insertions(+)
kernel/ckrm/ckrm_numtasks.c +3 -0
@@ -165,6 +165,9 @@ static void numtasks_put_ref_local(struc res = ckrm_get_res_class(core, resid, struct ckrm_numtasks);if (res ==NULL )return ; + +if (atomic_read (&res->cnt_cur_alloc) ==0 ) +return ;atomic_dec (&res->cnt_cur_alloc);if (atomic_read (&res->cnt_borrowed) >0 ) {atomic_dec (&res->cnt_borrowed);
--
PATCH 15/21 CKRM: Rule Based Classification Engine, stub rcfs support
In reply to [email protected]--
Content-Disposition: inline; filename=09-01-rbce_fs
Part 1 of 5 patches to support Rule Based Classification Engine for CKRM. This patch provides the the basic rcfs interface for rbce. It just provides the interface with stub functions.
include/linux/rbce.h | 28 ++ init/Kconfig | 12 + kernel/ckrm/Makefile | 1 kernel/ckrm/rbce/Makefile | 6 kernel/ckrm/rbce/rbce_fs.c | 365 +++++++++++++++++++++++++++++++++++++++ kernel/ckrm/rbce/rbce_internal.h | 59 ++++++ kernel/ckrm/rbce/rbce_main.c | 97 ++++++++++ 7 files changed, 568 insertions(+)
include/linux/rbce.h new file +28 -0
@@ -0,0 +1,28 @@ +/* Rule-based Classification Engine (RBCE) module +* +* Copyright (C) Hubertus Franke, IBM Corp. 2003 +* (C) Chandra Seetharaman, IBM Corp. 2003 +* +* Module for loading of classification policies and providing +* a user API for Class-based Kernel Resource Management (CKRM) +* +* Latest version, more details at http://ckrm.sf.net +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2.1 of the GNU Lesser General Public License +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* +*/ + +#ifndef _LINUX_RBCE_H +#define _LINUX_RBCE_H + +#define RBCE_MOD_DESCR "Rule Based Classification Engine Module for CKRM" +#define RBCE_MOD_NAME "rbce" + +#endif /* _LINUX_RBCE_H */
init/Kconfig +12 -0
@@ -203,6 +203,18 @@ config CKRM_RES_NUMTASKS Say N if unsure, Y to use the feature. + +config CKRM_RBCE + tristate "Vanilla Rule-based Classification Engine (RBCE)" + depends on CKRM && RCFS_FS + default m + help + Provides an optional module to support creation of rules for automatic + classification of kernel objects. Rules are created/deleted/modified + through an rcfs interface. RBCE is not required for CKRM. + + If unsure, say N. + endmenu config SYSCTL
kernel/ckrm/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-y += ckrm_events.o ckrm.o ckrmutils. obj-$(CONFIG_CKRM_TYPE_TASKCLASS) += ckrm_tc.o ckrm_numtasks_stub.o obj-$(CONFIG_CKRM_TYPE_SOCKETCLASS) += ckrm_sockc.o obj-$(CONFIG_CKRM_RES_NUMTASKS) += ckrm_numtasks.o +obj-$(CONFIG_CKRM_RBCE) += rbce/
kernel/ckrm/rbce/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for RBCE +# + +obj-$(CONFIG_CKRM_RBCE) += rbce.o +rbce-objs := rbce_fs.o rbce_main.o
kernel/ckrm/rbce/rbce_fs.c new file +365 -0
365 lines not on this page · raw message
kernel/ckrm/rbce/rbce_internal.h new file +59 -0
59 lines not on this page · raw message
kernel/ckrm/rbce/rbce_main.c new file +97 -0
97 lines not on this page · raw message
--
PATCH 16/21 CKRM: Rule Based Classification Engine, basic rcfs support
In reply to [email protected]--
Content-Disposition: inline; filename=09-02-rbce_fs-main
Part 2 of 5 patches to support Rule Based Classification Engine for CKRM. This patch provides the functionality needed by the rcfs interface for ce provided in patch 1. No classification functionality yet.
Makefile | 2 rbce_internal.h | 161 +++++++++ rbce_main.c | 993 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- rbce_token.c | 241 +++++++++++++ 4 files changed, 1383 insertions(+), 14 deletions(-)
kernel/ckrm/rbce/Makefile +1 -1
@@ -3,4 +3,4 @@ # obj-$(CONFIG_CKRM_RBCE) += rbce.o -rbce-objs := rbce_fs.o rbce_main.o +rbce-objs := rbce_fs.o rbce_main.o rbce_token.o
kernel/ckrm/rbce/rbce_internal.h +160 -1
172 lines not on this page · raw message
kernel/ckrm/rbce/rbce_main.c +981 -12
1,013 lines not on this page · raw message
kernel/ckrm/rbce/rbce_token.c new file +241 -0
241 lines not on this page · raw message
--
PATCH 17/21 CKRM: Rule Based Classification Engine, bitvector support for classification info
In reply to [email protected]--
Content-Disposition: inline; filename=09-03-rbce_main-opt
Part 3 of 5 patches to support Rule Based Classification Engine for CKRM. This patch provides some optimization by maintaining the classification information in the vectors. No classification functionality yet.
rbce_bitvector.h | 146 +++++++++++++++++++++++++++++++++++++++++++++++ rbce_internal.h | 19 +++++- rbce_main.c | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 330 insertions(+), 3 deletions(-)
kernel/ckrm/rbce/rbce_bitvector.h new file +146 -0
@@ -0,0 +1,146 @@ +/* +* Copyright (C) Hubertus Franke, IBM Corp. 2003 +* +* Bitvector package +* +* Latest version, more details at http://ckrm.sf.net +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef _RBCE_BITVECTOR_H +#define _RBCE_BITVECTOR_H + +typedef struct { +int size;/* maxsize in longs */ +unsigned long bits[0 ];/* bit vector */ +}bitvector_t ; + +#define BITS_2_LONGS (sz) (((sz)+BITS_PER_LONG-1)/BITS_PER_LONG) +#define BITS_2_BYTES (sz) (((sz)+7)/8) + +#if 0 +#define CHECK_VEC (vec) (vec)/* check against NULL */ +#else +#define CHECK_VEC (vec) (1)/* assume no problem */ +#endif + +#define CHECK_VEC_VOID (vec) do { if (!CHECK_VEC(vec)) return; } while(0) +#define CHECK_VEC_RC (vec, val) \ +do { if (!CHECK_VEC(vec)) return (val); } while(0) + +inline static void bitvector_zero (bitvector_t * bitvec) +{ +int sz; + +CHECK_VEC_VOID (bitvec); + sz =BITS_2_BYTES (bitvec->size); +memset (bitvec->bits,0 , sz); +return ; +} + +inline static unsigned long bitvector_bytes (unsigned long size) +{ +return sizeof (bitvector_t) +BITS_2_BYTES (size); +} + +inline static void bitvector_init (bitvector_t * bitvec,unsigned long size) +{ + bitvec->size = size; +bitvector_zero (bitvec); +return ; +} + +inline static bitvector_t *bitvector_alloc (unsigned long size) +{ +bitvector_t *vec = + (bitvector_t *)kmalloc (bitvector_bytes (size),GFP_KERNEL ); +if (vec) { + vec->size = size; +bitvector_zero (vec); + } +return vec; +} + +inline static void bitvector_free (bitvector_t * bitvec) +{ +CHECK_VEC_VOID (bitvec); +kfree (bitvec); +return ; +} + +#define def_bitvec_op (name,mod1,op,mod2) \ +inline static int name(bitvector_t *res, bitvector_t *op1, \ + bitvector_t *op2) \ +{ \ + unsigned int i, size; \ + \ + CHECK_VEC_RC(res, 0); \ + CHECK_VEC_RC(op1, 0); \ + CHECK_VEC_RC(op2, 0); \ + size = res->size; \ + if (((size != (op1)->size) || (size != (op2)->size))) { \ + return 0; \ + } \ + size = BITS_2_LONGS(size); \ + for (i = 0; i < size; i++) { \ + (res)->bits[i] = (mod1 (op1)->bits[i]) op \ + (mod2 (op2)->bits[i]); \ + } \ + return 1; \ +} + +def_bitvec_op(bitvector_or,, |,); +def_bitvec_op(bitvector_and,, &,); +def_bitvec_op(bitvector_xor,, ^,); +def_bitvec_op(bitvector_or_not,, |, ~); +def_bitvec_op(bitvector_not_or, ~, |,); +def_bitvec_op(bitvector_and_not,, &, ~); +def_bitvec_op(bitvector_not_and, ~, &,); + +inline static void bitvector_set(int idx, bitvector_t * vec) +{ + set_bit(idx, vec->bits); + return; +} + +inline static void bitvector_clear(int idx, bitvector_t * vec) +{ +clear_bit (idx, vec->bits); +return ; +} + +inline static int bitvector_test(int idx, bitvector_t * vec) +{ + return test_bit(idx, vec->bits); +} + +#ifdef DEBUG +inline static void bitvector_print (int flag,bitvector_t * vec) +{ +unsigned int i; +int sz; +extern int rbcedebug; + +if ((rbcedebug & flag) ==0 ) { +return ; + } +if (vec ==NULL ) { +printk ("v<0>-NULL\n" ); +return ; + } +printk ("v<%d>-" , sz = vec->size); +for (i =0 ; i < sz; i++) { +printk ("%c" ,test_bit (i, vec->bits) ?'1' :'0' ); + } +return ; +} +#else +#define bitvector_print (x, y) +#endif + +#endif /* _RBCE_BITVECTOR_H */
kernel/ckrm/rbce/rbce_internal.h +16 -3
@@ -51,6 +51,8 @@ struct named_obj_hdr {char *name; }; +#include "rbce_bitvector.h" +#define GET_REF (x) ((x)->obj.referenced)#define INC_REF (x) (GET_REF(x)++)#define DEC_REF (x) (--GET_REF(x))
@@ -185,14 +187,25 @@ enum op_token { TOKEN_OP_STATE = (__force op_token_t) (TOKEN_OP_GREATER_THAN+6), }; -/* -* data structure rbce_private_data to hold the app_tag for a task. -* Expands later. +* data structure rbce_private_data holds the bit vector 'eval' which +* specifies if rules and terms of rules are evaluated against the task +* and if they were evaluated, bit vector 'true' holds the result of that +* evaluation. +* +* This data structure is maintained in a task, and the bitvectors are +* updated only when needed. +* +* Each rule and each term of a rule has a corresponding bit in the vector. * */ struct rbce_private_data { +int evaluate;/* whether to evaluate rules or not ? */ +int rules_version;/* rules_version at last evaluation */ +bitvector_t *eval; +bitvector_t *true;char *app_tag; +char data[0 ];/* bitvectors eval and true */ };#define RBCE_DATA (tsk) ((struct rbce_private_data*)((tsk)->ce_data))
kernel/ckrm/rbce/rbce_main.c +168 -0
215 lines not on this page · raw message
--
PATCH 18/21 CKRM: Rule Based Classification Engine, full CE
In reply to [email protected]--
Content-Disposition: inline; filename=09-04-rbce_opt-core
Part 4 of 5 patches to support Rule Based Classification Engine for CKRM. This patch connects RBCE with CKRM core. Full functionality of RBCE achieved with this patch.
Makefile | 2 rbce_core.c | 890 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ rbce_internal.h | 23 + rbce_main.c | 67 ++-- 4 files changed, 961 insertions(+), 21 deletions(-)
kernel/ckrm/rbce/Makefile +1 -1
@@ -3,4 +3,4 @@ # obj-$(CONFIG_CKRM_RBCE) += rbce.o -rbce-objs := rbce_fs.o rbce_main.o rbce_token.o +rbce-objs := rbce_fs.o rbce_main.o rbce_token.o rbce_core.o
kernel/ckrm/rbce/rbce_core.c new file +890 -0
890 lines not on this page · raw message
kernel/ckrm/rbce/rbce_internal.h +23 -0
@@ -41,6 +41,8 @@#include <asm/io.h> #include <asm/uaccess.h> +#include "rbce_bitvector.h" +/* * comman data structure used for identification of class and rules * in the RBCE namespace
@@ -205,14 +207,25 @@ struct rbce_private_data {bitvector_t *eval;bitvector_t *true;char *app_tag; +unsigned long bitmap_version;char data[0 ];/* bitvectors eval and true */ };#define RBCE_DATA (tsk) ((struct rbce_private_data*)((tsk)->ce_data))#define RBCE_DATAP (tsk) ((tsk)->ce_data) +/* Other rbce global stuff. */ +extern struct rbce_eng_callback rbce_rcfs_ecbs;extern int rbce_enabled; +extern struct list_head rules_list[]; +extern const int use_persistent_state; +extern int gl_num_rules; +extern int gl_bitmap_version; +extern int gl_allocated; +extern struct rbce_rule_term *gl_terms; +extern int gl_rules_version; +extern rwlock_t rbce_rwlock;extern int rbce_mkdir (struct inode *,struct dentry *,int );extern int rbce_rmdir (struct inode *,struct dentry *);
@@ -228,4 +241,14 @@ extern int rbce_rename_rule(const char *extern int rules_parse (char *,struct rbce_rule_term **,int *); +extern struct rbce_private_data *create_private_data (struct rbce_private_data + *,int ); +extern bitvector_t *get_gl_mask_vecs (int ); +extern struct rbce_class *find_class_name (const char *); +extern void put_class (struct rbce_class *); +extern void free_all_private_data (void ); + +extern void unregister_classtype_engines (void ); +extern int register_classtype_engines (void ); +#endif /* _RBCE_INTERNAL_H */
kernel/ckrm/rbce/rbce_main.c +47 -20
131 lines not on this page · raw message
--
PATCH 19/21 CKRM: Rule Based Classification Engine, more advanced classification engine
In reply to [email protected]--
Content-Disposition: inline; filename=09-05-rbce_core-crbce
Part 5 of 5 patches to support Rule Based Classification Engine for CKRM. This patch provides the enhanced RBCE, CRBCE. CRBCE allows the per-process delay data and additioanl user level monmitoring support.
include/linux/crbce.h | 164 +++++++++++ include/linux/netlink.h | 1 include/linux/rbce.h | 50 +++ init/Kconfig | 12 kernel/ckrm/rbce/Makefile | 6 kernel/ckrm/rbce/crbce_ext.c | 580 +++++++++++++++++++++++++++++++++++++++ kernel/ckrm/rbce/crbce_main.c | 2 kernel/ckrm/rbce/rbce_core.c | 45 ++- kernel/ckrm/rbce/rbce_internal.h | 10 kernel/ckrm/rbce/rbce_main.c | 24 + 10 files changed, 886 insertions(+), 8 deletions(-)
include/linux/crbce.h new file +164 -0
@@ -0,0 +1,164 @@ +/* +* crbce.h +* +* Copyright (C) Hubertus Franke, IBM Corp. 2003 +* Copyright (C) Chandra Seetharaman, IBM Corp. 2004 +* +* This files contains the type definition of the record +* created by the CRBCE CKRM classification engine +* +* +* Latest version, more details at http://ckrm.sf.net +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2.1 of the GNU Lesser General Public License +* as published by the Free Software Foundation. +* +* This program is distributed in the hope that it would be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +* +* +*/ + +#ifndef _LINUX_CRBCE_H +#define _LINUX_CRBCE_H + +#ifdef __KERNEL__ +#include <linux/autoconf.h> +#else +#define CONFIG_CKRM +#define CONFIG_CRBCE +#define CONFIG_DELAY_ACCT +#endif + +#include <linux/types.h> +#include <linux/ckrm_events.h> +#include <linux/ckrm_ce.h> + +#define CRBCE_MAX_CLASS_NAME_LEN 256 + +/**************************************************************** +* +* CRBCE EVENT SET is an extension to the standard CKRM_EVENTS +* +****************************************************************/ + +typedef int __bitwise crbce_event_t ; +enum crbce_event { + +/* we use the standard CKRM_EVENT_<..> +* to identify reclassification cause actions +* and extend by additional ones we need +*/ + +/* up event flow */ + +CRBCE_REC_EXIT = (__force crbce_event_t) (CKRM_NUM_EVENTS +1 ), +CRBCE_REC_DATA_DELIMITER = (__force crbce_event_t) (CRBCE_REC_EXIT +2 ), +CRBCE_REC_SAMPLE = (__force crbce_event_t) (CRBCE_REC_EXIT +3 ), +CRBCE_REC_TASKINFO = (__force crbce_event_t) (CRBCE_REC_EXIT +4 ), +CRBCE_REC_SYS_INFO = (__force crbce_event_t) (CRBCE_REC_EXIT +5 ), +CRBCE_REC_CLASS_INFO = (__force crbce_event_t) (CRBCE_REC_EXIT +6 ), +CRBCE_REC_KERNEL_CMD_DONE = (__force crbce_event_t) (CRBCE_REC_EXIT +7 ), +CRBCE_REC_UKCC_FULL = (__force crbce_event_t) (CRBCE_REC_EXIT +8 ), + +/* down command issueance */ +CRBCE_REC_KERNEL_CMD = (__force crbce_event_t) (CRBCE_REC_EXIT +9 ), + +CRBCE_NUM_EVENTS = (__force crbce_event_t) (CRBCE_REC_EXIT +10 ) +}; + +struct task_sample_info { +uint32_t cpu_running; +uint32_t cpu_waiting; +uint32_t io_delayed; +uint32_t memio_delayed; +}; + +/********************************************* +* KERNEL -> USER records * +*********************************************/ + +/* we have records with either a time stamp or not */ +struct crbce_hdr { +int type; +pid_t pid; +}; + +struct crbce_hdr_ts { +int type; +pid_t pid; +uint32_t jiffies; +uint64_t cls; +}; + +/* individual records */ + +struct crbce_rec_fork { +struct crbce_hdr_ts hdr; +pid_t ppid; +}; + +struct crbce_rec_data_delim { +struct crbce_hdr_ts hdr; +int is_stop;/* 0 start, 1 stop */ +}; + +struct crbce_rec_task_data { +struct crbce_hdr_ts hdr; +struct task_sample_info sample; +struct task_delay_info delay; +}; + +struct crbce_ukcc_full { +struct crbce_hdr_ts hdr; +}; + +struct crbce_class_info { +struct crbce_hdr_ts hdr; +int action; +int namelen; +char name[CRBCE_MAX_CLASS_NAME_LEN ]; +}; + +/********************************************* +* USER -> KERNEL records * +*********************************************/ + +typedef int __bitwise crbce_kernel_cmd_t ; +enum crbce_kernel_cmd { +CRBCE_CMD_START = (__force crbce_kernel_cmd_t )1 , +CRBCE_CMD_STOP = (__force crbce_kernel_cmd_t )2 , +CRBCE_CMD_SET_TIMER = (__force crbce_kernel_cmd_t )3 , +CRBCE_CMD_SEND_DATA = (__force crbce_kernel_cmd_t )4 , +}; + +struct crbce_command { +int type;/* we need this for the K->U reflection */ +int cmd; +uint32_t len;/* added in the kernel for reflection */ +}; + +#define set_cmd_hdr (rec,tok) \ + ((rec).hdr.type=CRBCE_REC_KERNEL_CMD,(rec).hdr.cmd=(tok)) + +struct crbce_cmd_done { +struct crbce_command hdr; +int rc; +}; + +struct crbce_cmd { +struct crbce_command hdr; +}; + +struct crbce_cmd_send_data { +struct crbce_command hdr; +int delta_mode; +}; + +struct crbce_cmd_settimer { +struct crbce_command hdr; +uint32_t interval;/* in msec .. 0 means stop */ +}; +#endif
include/linux/netlink.h +1 -0
@@ -14,6 +14,7 @@#define NETLINK_SELINUX 7/* SELinux event notifications */ #define NETLINK_ARPD 8#define NETLINK_AUDIT 9/* auditing */ +#define NETLINK_CKRM 10/* CKRM */ #define NETLINK_ROUTE6 11/* af_inet6 route comm channel */ #define NETLINK_IP6_FW 13#define NETLINK_DNRTMSG 14/* DECnet routing messages */
init/Kconfig +12 -0
@@ -215,6 +215,18 @@ config CKRM_RBCE If unsure, say N. +config CKRM_CRBCE + tristate "Enhanced Rule-based Classification Engine (RBCE)" + depends on CKRM && RCFS_FS && DELAY_ACCT + default m + help + Provides an optional module to support creation of rules for automatic + classification of kernel objects, just like RBCE above. In addition, + CRBCE provides per-process delay data (requires DELAY_ACCT configured) + enabled) and makes information on significant kernel events available + to userspace tools through relayfs (requires RELAYFS_FS configured). + + If unsure, say N. endmenu config SYSCTL
kernel/ckrm/rbce/Makefile +6 -0
@@ -4,3 +4,9 @@ obj-$(CONFIG_CKRM_RBCE) += rbce.o rbce-objs := rbce_fs.o rbce_main.o rbce_token.o rbce_core.o + +obj-$(CONFIG_CKRM_CRBCE) += crbce.o +crbce-objs := rbce_fs.o crbce_main.o rbce_token.o rbce_core.o crbce_ext.o + +CFLAGS_crbce_main.o += -DCRBCE_EXTENSION +CFLAGS_crbce_ext.o += -DCRBCE_EXTENSION
kernel/ckrm/rbce/crbce_ext.c new file +580 -0
580 lines not on this page · raw message
kernel/ckrm/rbce/crbce_main.c new file +2 -0
@@ -0,0 +1,2 @@ +/* Easiest way to transmit a symbolic link as a patch */ +#include "rbce_main.c"
kernel/ckrm/rbce/rbce_core.c +41 -4
107 lines not on this page · raw message
kernel/ckrm/rbce/rbce_internal.h +10 -0
@@ -202,6 +202,7 @@ enum op_token {* */ struct rbce_private_data { +struct rbce_ext_private_data ext_data;int evaluate;/* whether to evaluate rules or not ? */ int rules_version;/* rules_version at last evaluation */ bitvector_t *eval;
@@ -219,6 +220,7 @@ struct rbce_private_data {extern struct rbce_eng_callback rbce_rcfs_ecbs;extern int rbce_enabled;extern struct list_head rules_list[]; +extern struct list_head class_list;extern const int use_persistent_state;extern int gl_num_rules;extern int gl_bitmap_version;
@@ -251,4 +253,12 @@ extern void free_all_private_data(void);extern void unregister_classtype_engines (void );extern int register_classtype_engines (void ); +extern struct rbce_class *create_rbce_class (const char *,int ,void *); +extern void rbce_tc_manual (struct task_struct *); +extern void notify_class_action (struct rbce_class *,int ); +extern void send_exit_notification (struct task_struct *); +extern void rbce_tc_ext_notify (int ,void *,struct task_struct *); +extern int init_rbce_ext_pre (void ); +extern int init_rbce_ext_post (void ); +extern void exit_rbce_ext (void );#endif /* _RBCE_INTERNAL_H */
kernel/ckrm/rbce/rbce_main.c +20 -4
@@ -56,7 +56,7 @@ int termop_2_vecidx[RBCE_RULE_INVALID] =extern int errno; -static LIST_HEAD (class_list); +LIST_HEAD (class_list);struct list_head rules_list[CKRM_MAX_CLASSTYPES ];static int gl_action, gl_num_terms;static int gl_released;
@@ -1205,11 +1205,16 @@ int init_rbce(void)INIT_LIST_HEAD (&rules_list[i]); } - rc =register_classtype_engines (); + rc =init_rbce_ext_pre (); line = __LINE__;if (rc) goto out; + rc =register_classtype_engines (); + line = __LINE__; +if (rc) + goto out_unreg_ckrm; +/* register any other class type engine here */ rc =rcfs_register_engine (&rbce_rcfs_ecbs); line = __LINE__;
@@ -1219,13 +1224,22 @@ int init_rbce(void)if (rcfs_mounted) { rc =rbce_create_config (); line = __LINE__; -if (!rc) - goto out; +if (rc) + goto out_unreg_rcfs; } + rc =init_rbce_ext_post (); + line = __LINE__; +if (rc) + goto out_unreg_rcfs; +return 0 ; + +out_unreg_rcfs:rcfs_unregister_engine (&rbce_rcfs_ecbs); out_unreg_classtype:unregister_classtype_engines (); +out_unreg_ckrm: +exit_rbce_ext (); out:printk (KERN_ERR "%s: error installing rc=%d line=%d\n" , __FUNCTION__, rc, line);
@@ -1237,6 +1251,8 @@ void exit_rbce(void)int i;printk (KERN_INFO "Removing \'%s\' module\n" , modname); +exit_rbce_ext (); +/* Print warnings if lists are not empty, which is a bug */ if (!list_empty (&class_list)) {printk (KERN_WARNING "exit_rbce: Class list is not empty\n" );
include/linux/rbce.h +50 -0
57 lines not on this page · raw message
--
PATCH 20/21 CKRM: Clean up typo in printk message
In reply to [email protected]--
Content-Disposition: inline; filename=ckrm-printf-cleanup
Description: Simple typo, but makes code look incomplete.
ckrm.c | 2 +- 1 files changed, 1 insertion(+), 1 deletion(-)
kernel/ckrm/ckrm.c +1 -1
@@ -598,7 +598,7 @@ ckrm_register_res_ctlr(struct ckrm_class*/ read_lock (&ckrm_class_lock);list_for_each_entry (core, &clstype->classes, clslist) { -printk ("CKRM .. create res clsobj for resouce <%s>" +printk (KERN_NOTICE "CKRM .. create res clsobj for resource <%s>" "class <%s> par=%p\n" , rcbs->res_name, core->name, core->hnode.parent);ckrm_alloc_res_class (core, core->hnode.parent, resid);
--
PATCH 21/21 CKRM: Fix for compiler warnings
In reply to [email protected]--
Content-Disposition: inline; filename=compiler-warning-fix
The attached patch fixes warnings seen when event callback table is initialized.
kernel/ckrm/ckrm_sockc.c | 6 ++++-- kernel/ckrm/ckrm_tc.c | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-)
kernel/ckrm/ckrm_tc.c +13 -8
@@ -253,14 +253,17 @@ do { \ce_release (&ct_taskclass); \ }while (0 ) -static void cb_taskclass_newtask(struct task_struct *tsk) +static void cb_taskclass_newtask(void *tsk1) { +struct task_struct *tsk = (struct task_struct *)tsk1; + tsk->taskclass =NULL ;INIT_LIST_HEAD (&tsk->taskclass_link); } -static void cb_taskclass_fork (struct task_struct *tsk) +static void cb_taskclass_fork (void *tsk1) { +struct task_struct *tsk = (struct task_struct *)tsk1;struct ckrm_task_class *cls =NULL ;pr_debug ("%p:%d:%s\n" , tsk, tsk->pid, tsk->comm);
@@ -281,26 +284,28 @@ static void cb_taskclass_fork(struct tasce_release (&ct_taskclass); } -static void cb_taskclass_exit (struct task_struct *tsk) +static void cb_taskclass_exit (void *tsk1) { +struct task_struct *tsk = (struct task_struct *)tsk1; +CE_CLASSIFY_NORET (&ct_taskclass,CKRM_EVENT_EXIT , tsk);ckrm_set_taskclass (tsk, (void *)-1 ,NULL ,CKRM_EVENT_EXIT ); } -static void cb_taskclass_exec (const char *filename) +static void cb_taskclass_exec (void *filename) {pr_debug ("%p:%d:%s <%s>\n" , current, current->pid, current->comm, - filename); + (const char *)filename);CE_CLASSIFY_TASK_PROTECT (CKRM_EVENT_EXEC , current); } -static void cb_taskclass_uid (void ) +static void cb_taskclass_uid (void *arg) {pr_debug ("%p:%d:%s\n" , current, current->pid, current->comm);CE_CLASSIFY_TASK_PROTECT (CKRM_EVENT_UID , current); } -static void cb_taskclass_gid (void ) +static void cb_taskclass_gid (void *arg) {pr_debug ("%p:%d:%s\n" , current, current->pid, current->comm);CE_CLASSIFY_TASK_PROTECT (CKRM_EVENT_GID , current);
@@ -313,7 +318,7 @@ static struct ckrm_event_spec taskclass_ {CKRM_EVENT_EXIT, { cb_taskclass_exit, NULL }}, {CKRM_EVENT_UID, { cb_taskclass_uid, NULL }}, {CKRM_EVENT_GID, { cb_taskclass_gid, NULL }}, - {-1, { -1, NULL }} + {-1, { NULL, NULL }} };/*
kernel/ckrm/ckrm_sockc.c +4 -2
@@ -172,8 +172,9 @@ static void ckrm_sock_add_resctrl(struct* Functions called from classification points * **************************************************************************/ -static void cb_sockclass_listen_start (struct sock *sk) +static void cb_sockclass_listen_start (void *sk1) { +struct sock *sk = (struct sock *)sk1;struct ckrm_net_struct *ns =NULL ;struct ckrm_sock_class *newcls =NULL ;struct ckrm_res_ctlr *rcbs;
@@ -243,8 +244,9 @@ static void cb_sockclass_listen_start(streturn ; } -static void cb_sockclass_listen_stop (struct sock *sk) +static void cb_sockclass_listen_stop (void *sk1) { +struct sock *sk = (struct sock *)sk1;struct ckrm_net_struct *ns =NULL ;struct ckrm_sock_class *newcls =NULL ;
--
Re: [patch 21/21] CKRM: Fix for compiler warnings
kernel/ckrm/ckrm_tc.c do { \ · line 259
Quoted 5 lines · On 05/05/05 11:07 -0700, [email protected] wrote:
kernel/ckrm/ckrm_tc.c +3
-1-static void cb_taskclass_newtask (struct task_struct *tsk) +static void cb_taskclass_newtask (void *tsk1) { +struct task_struct *tsk = (struct task_struct *)tsk1; +
I see this often in this code, so I'll mention it:
There's no need to cast void pointers to other pointers.
Domen