From: Colin Ian King <colin.king(a)canonical.com>
clang's scan-build detected the following error "Undefined or
garbage value returned to caller" because ret is not intialised.
Signed-off-by: Colin Ian King <colin.king(a)canonical.com>
---
idlestat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/idlestat.c b/idlestat.c
index 4d773f4..ede98a0 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -1229,7 +1229,7 @@ static int idlestat_file_for_each_line(const char *path, void *data,
int (*handler)(const char *, void *))
{
FILE *f;
- int ret;
+ int ret = 0;
if (!handler)
return -1;
--
2.5.0
rt-app considers all key starting by "run" in the "phases" object as a run
event. But rt-app also allows to not create a "phases" object if there is only
one phase. In this latter case, the events are directly put at the "thread"
object level where the deadline parameters are also set. In such configuration,
the "runtime" key that is used for the runtime parameter of a deadline thread
is also filtered as a "run" event whereas it should not.
In order to remove any potential mix between deadline parameters and events,
we rename the deadline parameters in the .json file: "dl-period",
"dl-deadline", "dl-runtime".
For backward compatibility reason, rt-app will continue to check the presence
of "period", "deadline" and "runtime" keys at the thread level iff new keys
have not been found.
"dl-period", "dl-runtime" and "dl-deadline" are used by to set sched_setattr's
paramters which use nanosecond unit. All other rt-app parameters uses
microsecond unit which makes the description of a deadline thread quite
confusing as described in the example below:
"thread0" : {
"policy" : "SCHED_DEADLINE",
"dl-period" : 100000000,
"dl-deadline" : 20000000,
"dl-runtime" : 10000000,
"run" : 10000,
"timer" : { "ref" : "unique", "period" : 100000 }
},
In addition, deadline scheduler doesn't accept a runtime smaller than 1 usec
(at least in the v4.3 kernel). So we can align all the parameters of the json
file to usec unit in order to have consistant values in the description of a
thread.
The usec unit only applies to "dl-period", "dl-runtime" and "dl-deadline" but
"period", "deadline" and "runtime" still use ns to keep backward
compatibility.
Signed-off-by: Vincent Guittot <vincent.guittot(a)linaro.org>
---
doc/tutorial.txt | 12 ++++++------
src/rt-app.c | 2 +-
src/rt-app_parse_config.c | 12 +++++++++---
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/doc/tutorial.txt b/doc/tutorial.txt
index c1be953..6dc9a44 100644
--- a/doc/tutorial.txt
+++ b/doc/tutorial.txt
@@ -163,14 +163,14 @@ is used if not defined
must be aligned with the range allowed by the policy. The default priority is
0 for sched_other class and 10 for other classes
-* runtime : Integer: Define the runtime budget for deadline scheduling class.
-Default value is 0.
+* dl-runtime : Integer: Define the runtime budget for deadline scheduling class.
+Default value is 0. The unit is usec.
-* period : Integer. Define the period duration for deadline scheduling class.
-Default value is runtime.
+* dl-period : Integer. Define the period duration for deadline scheduling class.
+Default value is runtime. The unit is usec.
-* deadline : Integer. Define the deadline parameter for deadline scheduling
-class. Default value is period.
+* dl-deadline : Integer. Define the deadline parameter for deadline scheduling
+class. Default value is period. The unit is usec.
* cpus: Array of Integer. Define the CPU affinity of the thread. Default
value is all CPUs of the system. An example : "cpus" : [0, 2, 3]
diff --git a/src/rt-app.c b/src/rt-app.c
index 5379ced..fef12d8 100644
--- a/src/rt-app.c
+++ b/src/rt-app.c
@@ -479,7 +479,7 @@ void *thread_body(void *arg)
attr.sched_policy = SCHED_DEADLINE;
attr.sched_priority = 0;
attr.sched_runtime = data->runtime;
- attr.sched_deadline = data->deadline;
+ attr.sched_deadline = data->deadline;
attr.sched_period = data->period;
log_notice("[%d] period: %lu, exec: %lu, deadline: %lu",
diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c
index ef802f1..af18910 100644
--- a/src/rt-app_parse_config.c
+++ b/src/rt-app_parse_config.c
@@ -659,9 +659,15 @@ parse_thread_data(char *name, struct json_object *obj, int index,
prior_def);
/* deadline params */
- data->runtime = get_int_value_from(obj, "runtime", TRUE, 0);
- data->period = get_int_value_from(obj, "period", TRUE, data->runtime);
- data->deadline = get_int_value_from(obj, "period", TRUE, data->period);
+ data->runtime = get_int_value_from(obj, "dl-runtime", TRUE, 0) * 1000;
+ if (!data->runtime)
+ data->runtime = get_int_value_from(obj, "runtime", TRUE, 0);
+ data->period = get_int_value_from(obj, "dl-period", TRUE, 0) * 1000;
+ if (!data->period)
+ data->period = get_int_value_from(obj, "period", TRUE, data->runtime);
+ data->deadline = get_int_value_from(obj, "dl-deadline", TRUE, 0) * 1000;
+ if (!data->period)
+ data->deadline = get_int_value_from(obj, "deadline", TRUE, data->period);
/* cpuset */
cpuset_obj = get_in_object(obj, "cpus", TRUE);
--
1.9.1
If a sigterm is raised once we have installed our own handler but threads
are not already created, we deadlock in the shutdown function.
So, we don't wait anymore for thread until all threads has been created
which is not a big issue because we don't really care of gathering all
logs and traces before exiting rt-app in this case as the use case has
not started yet.
Reported-by: Daniel Lezcano <daniel.lezcano(a)linaro.org>
Signed-off-by: Vincent Guittot <vincent.guittot(a)linaro.org>
---
change since v1:
- add sig_atomic_t for variables used in signal handler
src/rt-app.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/rt-app.c b/src/rt-app.c
index f14f228..5379ced 100644
--- a/src/rt-app.c
+++ b/src/rt-app.c
@@ -29,9 +29,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <sys/resource.h>
static int errno;
-static volatile int continue_running;
+static volatile sig_atomic_t continue_running;
static pthread_t *threads;
static int nthreads;
+static volatile sig_atomic_t running_threads;
static int p_load;
rtapp_options_t opts;
@@ -353,6 +354,10 @@ static void
shutdown(int sig)
{
int i;
+
+ if(!continue_running)
+ return;
+
/* notify threads, join them, then exit */
continue_running = 0;
@@ -364,7 +369,7 @@ shutdown(int sig)
}
/* wait up all waiting threads */
- for (i = 0; i < nthreads; i++)
+ for (i = 0; i < running_threads; i++)
{
pthread_join(threads[i], NULL);
}
@@ -634,6 +639,7 @@ int main(int argc, char* argv[])
/* allocated threads */
nthreads = opts.nthreads;
threads = malloc(nthreads * sizeof(pthread_t));
+ running_threads = 0;
/* install a signal handler for proper shutdown */
signal(SIGQUIT, shutdown);
@@ -664,6 +670,7 @@ int main(int argc, char* argv[])
log_ftrace(ft_data.marker_fd, "main creates threads\n");
}
+ /* Init global running_variable */
continue_running = 1;
/* Needs to calibrate 'calib_cpu' core */
@@ -835,6 +842,7 @@ int main(int argc, char* argv[])
(void*) tdata))
goto exit_err;
}
+ running_threads = nthreads;
if (opts.duration > 0) {
sleep(opts.duration);
--
1.9.1
If a sigterm is raised once we have installed our own handler but threads
are not already created, we deadlock in the shutdown function.
So, we don't wait anymore for thread until all threads has been created
which is not a big issue because we don't really care of gathering all
logs and traces before exiting rt-app in this case as the use case has
not started yet.
Reported-by: Daniel Lezcano <daniel.lezcano(a)linaro.org>
Signed-off-by: Vincent Guittot <vincent.guittot(a)linaro.org>
---
src/rt-app.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/rt-app.c b/src/rt-app.c
index f14f228..bbc8594 100644
--- a/src/rt-app.c
+++ b/src/rt-app.c
@@ -32,6 +32,7 @@ static int errno;
static volatile int continue_running;
static pthread_t *threads;
static int nthreads;
+static int running_threads;
static int p_load;
rtapp_options_t opts;
@@ -353,6 +354,10 @@ static void
shutdown(int sig)
{
int i;
+
+ if(!continue_running)
+ return;
+
/* notify threads, join them, then exit */
continue_running = 0;
@@ -364,7 +369,7 @@ shutdown(int sig)
}
/* wait up all waiting threads */
- for (i = 0; i < nthreads; i++)
+ for (i = 0; i < running_threads; i++)
{
pthread_join(threads[i], NULL);
}
@@ -634,6 +639,7 @@ int main(int argc, char* argv[])
/* allocated threads */
nthreads = opts.nthreads;
threads = malloc(nthreads * sizeof(pthread_t));
+ running_threads = 0;
/* install a signal handler for proper shutdown */
signal(SIGQUIT, shutdown);
@@ -664,6 +670,7 @@ int main(int argc, char* argv[])
log_ftrace(ft_data.marker_fd, "main creates threads\n");
}
+ /* Init global running_variable */
continue_running = 1;
/* Needs to calibrate 'calib_cpu' core */
@@ -835,6 +842,7 @@ int main(int argc, char* argv[])
(void*) tdata))
goto exit_err;
}
+ running_threads = nthreads;
if (opts.duration > 0) {
sleep(opts.duration);
--
1.9.1
Hi All,
I faced a couple of issues with rt-app:
1) rt-app rt-app/doc/examples/video-short.jso
I have the following error:
[rt-app] <error> [json] Error while parsing input JSON
2) rt-app rt-app/doc/examples/browser-short.js
When hitting the Ctrl+C while in the:
[rt-app] <notice> Calibrate ns per loop
That leads to:
[513468.106751] Unhandled fault: alignment fault (0x92000021) at
0x0000007f9d0fa7ec
Bus error
-- Daniel
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
From: Geunsik Lim <geunsik.lim(a)samsung.com>
when we execute 'make' command, we meet error message as follows.
./rt-app/src/rt-app_parse_config.c:773:
undefined reference to `is_error'
Let's append <json/bits.h> header file into rt-app_parse_config.c
Signed-off-by: Geunsik Lim <geunsik.lim(a)samsung.com>
---
src/rt-app_parse_config.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c
index 96e5517..f4ecb61 100644
--- a/src/rt-app_parse_config.c
+++ b/src/rt-app_parse_config.c
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
+#include <json/bits.h>
#include "rt-app_parse_config.h"
#define PFX "[json] "
--
1.7.9.5
-Several minor fixes in the tutorial file
-Remove some compilation warnings
-Reorder and gather the init of data by feature
-Close the log file before exiting the thread body
Signed-off-by: Vincent Guittot <vincent.guittot(a)linaro.org>
---
doc/tutorial.txt | 8 ++++----
src/rt-app.c | 3 ++-
src/rt-app_parse_config.c | 21 +++++++++++----------
3 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/doc/tutorial.txt b/doc/tutorial.txt
index 8341b2e..b2b0971 100644
--- a/doc/tutorial.txt
+++ b/doc/tutorial.txt
@@ -39,8 +39,8 @@ run indefinitly until all threads kill themselves (as an example if a finite
number of loop has been defined in their running pattern) or if a signal
is received to stop the use case.
-* calibration : Text or Integer: A text defines the CPU that will be used to
-calibrate the ns per loop value. "CPU0" is the default value (see run event
+* calibration : String or Integer: A String defines the CPU that will be used
+to calibrate the ns per loop value. "CPU0" is the default value (see run event
section for details about ns per loop value). A integer skips the calibration
step and uses the integer value as ns per loop.
@@ -55,10 +55,10 @@ ensures that your RT thread will not be stalled until a page is moved from swap
to RAM. The lock of the page is only possible for non CFS tasks. Default value
is False.
-* logdir : Text. Path to store the various log files. The default path is
+* logdir : String. Path to store the various log files. The default path is
the current directory (./).
-* log_basename : Text. Prefix used for all log files of the use case.
+* log_basename : String. Prefix used for all log files of the use case.
"rt-app-" is used by default.
* log_size : String or Integer. A Integer defines a fix size in MB of the
diff --git a/src/rt-app.c b/src/rt-app.c
index 805cc35..f14f228 100644
--- a/src/rt-app.c
+++ b/src/rt-app.c
@@ -613,7 +613,7 @@ void *thread_body(void *arg)
log_ftrace(ft_data.marker_fd, "[%d] exiting", data->ind);
log_notice("[%d] Exiting.", data->ind);
-// fclose(data->log_handler);
+ fclose(data->log_handler);
pthread_exit(NULL);
}
@@ -767,6 +767,7 @@ int main(int argc, char* argv[])
"\"%s-%s-%d.log\" u ($5/1000):3 w l"
" title \"thread [%s] (%s)\"",
opts.logbasename, opts.threads_data[i].name,
+ opts.threads_data[i].ind,
opts.threads_data[i].name,
opts.threads_data[i].sched_policy_descr);
diff --git a/src/rt-app_parse_config.c b/src/rt-app_parse_config.c
index 98374cd..f4ac5cf 100644
--- a/src/rt-app_parse_config.c
+++ b/src/rt-app_parse_config.c
@@ -334,7 +334,8 @@ parse_thread_event_data(char *name, struct json_object *obj,
{
rtapp_resource_t *rdata, *ddata;
char unique_name[22];
- const char *ref, *tmp;
+ const char *ref;
+ char *tmp;
int i;
if (!strncmp(name, "run", strlen("run")) ||
@@ -434,23 +435,23 @@ parse_thread_event_data(char *name, struct json_object *obj,
else
data->type = rtapp_sig_and_wait;
- ref = get_string_value_from(obj, "ref", TRUE, "unknown");
- i = get_resource_index(ref, rtapp_wait, opts);
+ tmp = get_string_value_from(obj, "ref", TRUE, "unknown");
+ i = get_resource_index(tmp, rtapp_wait, opts);
/*
* get_string_value_from allocate the string so with have to free it
* once useless
*/
- free(ref);
+ free(tmp);
data->res = i;
- ref = get_string_value_from(obj, "mutex", TRUE, "unknown");
- i = get_resource_index(ref, rtapp_mutex, opts);
+ tmp = get_string_value_from(obj, "mutex", TRUE, "unknown");
+ i = get_resource_index(tmp, rtapp_mutex, opts);
/*
* get_string_value_from allocate the string so with have to free it
* once useless
*/
- free(ref);
+ free(tmp);
data->dep = i;
@@ -754,14 +755,14 @@ parse_global(struct json_object *global, rtapp_options_t *opts)
log_info(PFX " No global section Found: Use default value");
opts->duration = -1;
opts->gnuplot = 0;
- opts->policy = other;
+ opts->policy = other;
opts->calib_cpu = 0;
opts->calib_ns_per_loop = 0;
opts->logdir = strdup("./");
- opts->lock_pages = 1;
opts->logbasename = strdup("rt-app");
opts->logsize = 0;
opts->ftrace = 0;
+ opts->lock_pages = 1;
opts->pi_enabled = 0;
opts->io_device = strdup("/dev/null");
opts->mem_buffer_size = DEFAULT_MEM_BUF_SIZE;
@@ -844,10 +845,10 @@ parse_global(struct json_object *global, rtapp_options_t *opts)
}
opts->logdir = get_string_value_from(global, "logdir", TRUE, "./");
- opts->lock_pages = get_bool_value_from(global, "lock_pages", TRUE, 1);
opts->logbasename = get_string_value_from(global, "log_basename",
TRUE, "rt-app");
opts->ftrace = get_bool_value_from(global, "ftrace", TRUE, 0);
+ opts->lock_pages = get_bool_value_from(global, "lock_pages", TRUE, 1);
opts->pi_enabled = get_bool_value_from(global, "pi_enabled", TRUE, 0);
opts->io_device = get_string_value_from(global, "io_device", TRUE,
"/dev/null");
--
1.9.1