Skip to content

Commit bc95c24

Browse files
committed
I think log_size auto mode has been implemented
1 parent 20c2282 commit bc95c24

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/rt-app_parse_config.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ parse_global(struct json_object *global, rtapp_options_t *opts)
12571257
else if (!strcmp(tmp_str, "file"))
12581258
opts->logsize = -2;
12591259
else if (!strcmp(tmp_str, "auto"))
1260-
opts->logsize = -2; /* Automatic buffer size computation is not supported yet so we fall back on file system mode */
1260+
opts->logsize = -1;
12611261
log_debug("Log buffer set to %s mode", tmp_str);
12621262

12631263
/*
@@ -1333,6 +1333,32 @@ get_opts_from_json_object(struct json_object *root, rtapp_options_t *opts)
13331333
json_object_put(tasks);
13341334
log_info(PFX "Free json objects");
13351335

1336+
/*
1337+
* In order to compute the log's buffer size is required to find the minimum
1338+
* period among all periodic tasks, if there are some. Once the period has
1339+
* been found it is possible to compute how many bytes are required for the
1340+
* logging buffer of such task, which is the worst case scenario.
1341+
*/
1342+
if (opts->logsize == -1) {
1343+
unsigned long min = __LONG_MAX__;
1344+
// Find minimum period among all tasks
1345+
for(size_t i = 0; i < opts->num_tasks; ++i) {
1346+
unsigned long period = opts->threads_data[i].sched_data->period;
1347+
min = (period < min) ? period : min;
1348+
}
1349+
1350+
/* If there are not periodic task should be sufficent just one instance
1351+
* of timing_point_t */
1352+
if (!min)
1353+
opts->logsize = sizeof(timing_point_t);
1354+
else {
1355+
unsigned long instances = (unsigned long) opts->duration * 1000000000 / min;
1356+
unsigned long bytes = instances * sizeof(timing_point_t);
1357+
opts->logsize = bytes;
1358+
}
1359+
1360+
log_notice("Log buffer size fixed to %fMB per threads", (float) opts->logsize / (1 << 20));
1361+
}
13361362
}
13371363

13381364
void

0 commit comments

Comments
 (0)