From 7cf33c65a6ac01366c44d74e910aa12f7c548ccf Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 13 Aug 2014 17:48:02 +0400 Subject: [PATCH] [IMPROVE] sampler: remove writer dependency Change-Id: I768e7b3a44c968c64277f2e4b5f7372de565c6e9 Signed-off-by: Vyacheslav Cherkashin --- parser/features.c | 11 ++++++++++- sampler/swap_sampler_module.c | 11 +++++------ sampler/swap_sampler_module.h | 6 +++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/parser/features.c b/parser/features.c index 4b264e6..fae53ea 100644 --- a/parser/features.c +++ b/parser/features.c @@ -36,6 +36,8 @@ #include "features.h" #include "msg_parser.h" +#include +#include #include #include @@ -281,6 +283,13 @@ int unset_context_switch(void) return ret; } + +static void sampler_cb(struct pt_regs *regs) +{ + if (check_event(current)) + sample_msg(regs); +} + /** * @brief Set sampling feature on. * @@ -291,7 +300,7 @@ int set_func_sampling(struct conf_data *conf) { int ret; - ret = swap_sampler_start(conf->data_msg_period); + ret = swap_sampler_start(conf->data_msg_period, sampler_cb); return ret; } diff --git a/sampler/swap_sampler_module.c b/sampler/swap_sampler_module.c index 9867ccf..8bd7e3c 100644 --- a/sampler/swap_sampler_module.c +++ b/sampler/swap_sampler_module.c @@ -35,9 +35,6 @@ #include #include -#include -#include - #include "swap_sampler_module.h" #include "swap_sampler_errors.h" #include "kernel_operations.h" @@ -45,11 +42,11 @@ static BLOCKING_NOTIFIER_HEAD(swap_sampler_notifier_list); +static swap_sample_cb_t sampler_cb; static restart_ret swap_timer_restart(swap_timer *timer) { - if (check_event(current)) - sample_msg(task_pt_regs(current)); + sampler_cb(task_pt_regs(current)); return sampler_timers_restart(timer); } @@ -127,7 +124,7 @@ static int sampler_run = 0; * @param timer_quantum Timer quantum for sampling. * @return 0 on success, error code on error. */ -int swap_sampler_start(unsigned int timer_quantum) +int swap_sampler_start(unsigned int timer_quantum, swap_sample_cb_t cb) { int ret = -EINVAL; @@ -137,6 +134,8 @@ int swap_sampler_start(unsigned int timer_quantum) goto unlock; } + sampler_cb = cb; + ret = do_swap_sampler_start(timer_quantum); if (ret == 0) sampler_run = 1; diff --git a/sampler/swap_sampler_module.h b/sampler/swap_sampler_module.h index e3663df..7c0ef7d 100644 --- a/sampler/swap_sampler_module.h +++ b/sampler/swap_sampler_module.h @@ -33,8 +33,12 @@ #ifndef __SWAP_SAMPLER_MODULE_H__ #define __SWAP_SAMPLER_MODULE_H__ + +typedef void (*swap_sample_cb_t)(struct pt_regs *); + + /* Starts the SWAP Sampler */ -int swap_sampler_start(unsigned int timer_quantum); +int swap_sampler_start(unsigned int timer_quantum, swap_sample_cb_t cb); /* Stops the SWAP Sampler */ int swap_sampler_stop(void); -- 2.7.4