From: Andreev S.V Date: Mon, 26 Nov 2012 11:00:16 +0000 (+0400) Subject: New sampling meta architecture introduced! X-Git-Tag: Tizen_SDK_2.3~738^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=00c21fec8bb13ec5b5af4deb38e506a4b88f4574;p=kernel%2Fswap-modules.git New sampling meta architecture introduced! --- diff --git a/driver/device_driver.c b/driver/device_driver.c index ce99575..26a2fa0 100644 --- a/driver/device_driver.c +++ b/driver/device_driver.c @@ -60,6 +60,8 @@ static struct file_operations device_fops = { .release = device_release }; +typedef void (* dbi_module_callback)(); + int device_init (void) { int nReserved = 0; @@ -182,6 +184,7 @@ static ssize_t device_write(struct file *filp, const char *buff, size_t len, lof EPRINTF("Operation <> not supported!"); return -1; } + #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) static int device_ioctl (struct inode *inode UNUSED, struct file *file UNUSED, unsigned int cmd, unsigned long arg) #else @@ -493,13 +496,37 @@ static long device_ioctl (struct file *file UNUSED, unsigned int cmd, unsigned l break; } case EC_IOCTL_ATTACH: - result = ec_user_attach (); + { + unsigned long dbi_flags; + struct dbi_modules_handlers *local_mh; + struct dbi_modules_handlers_info *local_mhi; + int j; + dbi_module_callback dmc_start; + + // call "start"-callback for all modules according module priority + local_mh = get_dbi_modules_handlers(); + spin_lock_irqsave(&local_mh->lock, dbi_flags); + for (j = 0; j <= MAX_PRIORITY; j++) { + list_for_each_entry_rcu(local_mhi, &local_mh->modules_handlers, dbi_list_head) { + if (local_mhi->dbi_module_priority_start == j) { + if (local_mhi->dbi_module_callback_start != NULL) { + printk("Started module callback (start) %s\n", local_mhi->dbi_module->name); + dmc_start = (dbi_module_callback )local_mhi->dbi_module_callback_start; + dmc_start(); + } + } + } + } + spin_unlock_irqrestore(&local_mh->lock, dbi_flags); + + result = ec_user_attach (); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 17) - DPRINTF("EC_IOCTL_ATTACH calling notification chain"); - blocking_notifier_call_chain(&swap_notifier_list, EC_IOCTL_ATTACH, (void*)NULL); + DPRINTF("EC_IOCTL_ATTACH calling notification chain"); + blocking_notifier_call_chain(&swap_notifier_list, EC_IOCTL_ATTACH, (void*)NULL); #endif - DPRINTF("Attach Probes"); - break; + DPRINTF("Attach Probes"); + break; + } case EC_IOCTL_ACTIVATE: result = ec_user_activate (); DPRINTF("Activate Probes"); @@ -511,6 +538,8 @@ static long device_ioctl (struct file *file UNUSED, unsigned int cmd, unsigned l struct dbi_modules_handlers *local_mh; struct dbi_modules_handlers_info *local_mhi; unsigned int local_module_refcount = 0; + int j; + dbi_module_callback dmc_stop; #ifdef OVERHEAD_DEBUG printk("\nswap_sum_time = %ld in kprobe_handler()\n", swap_sum_time); @@ -518,6 +547,7 @@ static long device_ioctl (struct file *file UNUSED, unsigned int cmd, unsigned l swap_sum_time = 0; swap_sum_hit = 0; #endif + local_mh = get_dbi_modules_handlers(); if(ec_user_stop() != 0) { result = -1; goto sad_cleanup; @@ -534,8 +564,21 @@ static long device_ioctl (struct file *file UNUSED, unsigned int cmd, unsigned l DPRINTF("EC_IOCTL_STOP_AND_DETACH calling notification chain"); blocking_notifier_call_chain(&swap_notifier_list, EC_IOCTL_STOP_AND_DETACH, (void*)&gl_nNotifyTgid); #endif + // call "stop"-callback for all modules according module priority + spin_lock_irqsave(&local_mh->lock, dbi_flags); + for (j = 0; j <= MAX_PRIORITY; j++) { + list_for_each_entry_rcu(local_mhi, &local_mh->modules_handlers, dbi_list_head) { + if (local_mhi->dbi_module_priority_stop == j) { + if (local_mhi->dbi_module_callback_stop != NULL) { + printk("Started module callback (stop) %s\n", local_mhi->dbi_module->name); + dmc_stop = (dbi_module_callback )local_mhi->dbi_module_callback_stop; + dmc_stop(); + } + } + } + } + spin_unlock_irqrestore(&local_mh->lock, dbi_flags); sad_cleanup: - local_mh = get_dbi_modules_handlers(); spin_lock_irqsave(&local_mh->lock, dbi_flags); list_for_each_entry_rcu(local_mhi, &local_mh->modules_handlers, dbi_list_head) { local_module_refcount = module_refcount(local_mhi->dbi_module); diff --git a/driver/device_driver.h b/driver/device_driver.h index cc8d49f..ab01f78 100644 --- a/driver/device_driver.h +++ b/driver/device_driver.h @@ -21,9 +21,10 @@ #include "ec_probe.h" // probe_id_t #include "stdswap_defs.h" -#define DEFAULT_DEVICE_NAME "swap_drv" -#define DEFAULT_DEVICE_MAJOR 250 -#define EVENTS_AGGREGATION_USEC (5 * 1000000UL) +#define DEFAULT_DEVICE_NAME "swap_drv" +#define DEFAULT_DEVICE_MAJOR 250 +#define EVENTS_AGGREGATION_USEC (5 * 1000000UL) +#define MAX_PRIORITY 255 extern int device_init (void); extern void device_down (void); diff --git a/driver/handlers_core.h b/driver/handlers_core.h index 60da9e7..02d3c40 100644 --- a/driver/handlers_core.h +++ b/driver/handlers_core.h @@ -33,6 +33,10 @@ struct dbi_modules_handlers_info { struct handler_map *dbi_handlers; int dbi_nr_handlers; struct list_head dbi_list_head; + void * dbi_module_callback_start; + void * dbi_module_callback_stop; + int dbi_module_priority_start; + int dbi_module_priority_stop; }; extern int dbi_register_handlers_module(struct dbi_modules_handlers_info *dbi_mhi);