trivial: run style formatter

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
This commit is contained in:
Gerwin Klein 2020-12-06 20:21:17 +11:00
parent 1d81cf6e6a
commit 31c597c8ca
6 changed files with 62 additions and 55 deletions

View File

@ -41,7 +41,7 @@ typedef struct device {
#define SUB_NETWORK "\"dhcp\"," #define SUB_NETWORK "\"dhcp\","
#endif #endif
#define NETWORK "\"net\" : {,\"if\":\""CONFIG_RUMPRUN_NETWORK_IFNAME"\", \"type\":\"inet\",\"method\": "SUB_NETWORK"}" #define NETWORK "\"net\" : {,\"if\":\""CONFIG_RUMPRUN_NETWORK_IFNAME"\", \"type\":\"inet\",\"method\": "SUB_NETWORK"}"
#else #else
#define NETWORK "" #define NETWORK ""
#endif #endif

View File

@ -12,8 +12,7 @@
#define IO_PORT_MIN 0xcf8 #define IO_PORT_MIN 0xcf8
#define IO_PORT_MAX 0xcff #define IO_PORT_MAX 0xcff
/* copy the caps required to set up the sel4platsupport default timer */ /* copy the caps required to set up the sel4platsupport default timer */
void void arch_copy_IOPort_cap(init_data_t *init, rump_env_t *env, sel4utils_process_t *test_process)
arch_copy_IOPort_cap(init_data_t *init, rump_env_t *env, sel4utils_process_t *test_process)
{ {
cspacepath_t path; cspacepath_t path;
seL4_Error error = vka_cspace_alloc_path(&env->vka, &path); seL4_Error error = vka_cspace_alloc_path(&env->vka, &path);
@ -53,6 +52,6 @@ void __attribute__((optimize("O0"))) hog_thread(void *_arg1, void *_arg2, void *
{ {
while (true) { while (true) {
COMPILER_MEMORY_FENCE(); COMPILER_MEMORY_FENCE();
asm volatile ("nop"); asm volatile("nop");
} }
} }

View File

@ -11,13 +11,16 @@
struct mmio mmio0s[] = {{0xf7f00000, 17}, {0xf7f39000, 12}}; struct mmio mmio0s[] = {{0xf7f00000, 17}, {0xf7f39000, 12}};
struct mmio mmio1s[] = {{0xf7dc0000, 17}}; struct mmio mmio1s[] = {{0xf7dc0000, 17}};
static device_t devices[] = {{"wm0", 20, ARRAY_SIZE(mmio0s), mmio0s, {0,25,0}}, static device_t devices[] = {{"wm0", 20, ARRAY_SIZE(mmio0s), mmio0s, {0, 25, 0}},
{"wm1", 16, ARRAY_SIZE(mmio1s), mmio1s, {3,0,0}}}; {"wm1", 16, ARRAY_SIZE(mmio1s), mmio1s, {3, 0, 0}}
};
device_t *get_devices(void) { device_t *get_devices(void)
{
return devices; return devices;
} }
int get_num_devices(void) { int get_num_devices(void)
{
return ARRAY_SIZE(devices); return ARRAY_SIZE(devices);
} }

View File

@ -10,12 +10,14 @@
struct mmio mmio0s[] = {{0xfebc0000, 17}}; struct mmio mmio0s[] = {{0xfebc0000, 17}};
static device_t devices[] = {{"wm0", 11, ARRAY_SIZE(mmio0s), mmio0s, {0,3,0}}}; static device_t devices[] = {{"wm0", 11, ARRAY_SIZE(mmio0s), mmio0s, {0, 3, 0}}};
device_t *get_devices(void) { device_t *get_devices(void)
{
return devices; return devices;
} }
int get_num_devices(void) { int get_num_devices(void)
{
return ARRAY_SIZE(devices); return ARRAY_SIZE(devices);
} }

View File

@ -18,8 +18,7 @@
/* Print out a summary of what has been tracked */ /* Print out a summary of what has been tracked */
#ifdef CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER #ifdef CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER
static inline void static inline void seL4_BenchmarkTrackDumpSummary_pri(benchmark_track_kernel_entry_t *logBuffer, uint32_t logSize)
seL4_BenchmarkTrackDumpSummary_pri(benchmark_track_kernel_entry_t *logBuffer, uint32_t logSize)
{ {
uint32_t index = 0; uint32_t index = 0;
uint32_t syscall_entries[8]; uint32_t syscall_entries[8];
@ -50,7 +49,7 @@ seL4_BenchmarkTrackDumpSummary_pri(benchmark_track_kernel_entry_t *logBuffer, ui
} }
if (logBuffer[index].entry.path == Entry_Syscall) { if (logBuffer[index].entry.path == Entry_Syscall) {
int syscall_no = logBuffer[index].entry.syscall_no; int syscall_no = logBuffer[index].entry.syscall_no;
if (syscall_no == 7 ) { if (syscall_no == 7) {
cap_entries[logBuffer[index].entry.cap_type]++; cap_entries[logBuffer[index].entry.cap_type]++;
cap_time[logBuffer[index].entry.cap_type] += logBuffer[index].duration; cap_time[logBuffer[index].entry.cap_type] += logBuffer[index].duration;
if (logBuffer[index].entry.cap_type == 2) { if (logBuffer[index].entry.cap_type == 2) {
@ -135,13 +134,13 @@ void handle_char(rump_env_t *env, int c)
/* Stop recording kernel entries */ /* Stop recording kernel entries */
logIndexFinalized = seL4_BenchmarkFinalizeLog(); logIndexFinalized = seL4_BenchmarkFinalizeLog();
#endif /* CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER */ #endif /* CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER */
printf("tot: %"PRIu64"\n idle: %"PRIu64"\n", cpucount2 - cpucount, ccount-start_idle_count); printf("tot: %"PRIu64"\n idle: %"PRIu64"\n", cpucount2 - cpucount, ccount - start_idle_count);
break; break;
case 'c': case 'c':
#ifdef CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER #ifdef CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER
benchmark_track_kernel_entry_t *ksLog = (benchmark_track_kernel_entry_t *) log_buffer; benchmark_track_kernel_entry_t *ksLog = (benchmark_track_kernel_entry_t *) log_buffer;
printf("dumping log: %"PRId32", %zd %zd\n", logIndexFinalized, printf("dumping log: %"PRId32", %zd %zd\n", logIndexFinalized,
sizeof(benchmark_track_kernel_entry_t), sizeof(kernel_entry_t)); sizeof(benchmark_track_kernel_entry_t), sizeof(kernel_entry_t));
seL4_BenchmarkTrackDumpSummary_pri(ksLog, logIndexFinalized);//ksLogIndexFinalized); seL4_BenchmarkTrackDumpSummary_pri(ksLog, logIndexFinalized);//ksLogIndexFinalized);
#endif /* CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER */ #endif /* CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER */
break; break;

View File

@ -3,7 +3,7 @@
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#define _NETBSD_SOURCE #define _NETBSD_SOURCE
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -13,55 +13,59 @@
int num_cores; int num_cores;
int set_thread_affinity(int thread_id) { int set_thread_affinity(int thread_id)
int core_id = thread_id % num_cores; {
int core_id = thread_id % num_cores;
/* Create NetBSD cpuset */ /* Create NetBSD cpuset */
cpuset_t *cpuset = cpuset_create(); cpuset_t *cpuset = cpuset_create();
cpuset_zero(cpuset); cpuset_zero(cpuset);
cpuset_set(core_id, cpuset); cpuset_set(core_id, cpuset);
pthread_t current_thread = pthread_self(); pthread_t current_thread = pthread_self();
return pthread_setaffinity_np(current_thread, cpuset_size(cpuset), cpuset); return pthread_setaffinity_np(current_thread, cpuset_size(cpuset), cpuset);
} }
/* A task that takes some time to complete. The id identifies distinct /* A task that takes some time to complete. The id identifies distinct
tasks for printed messages. */ tasks for printed messages. */
double task(int id) { double task(int id)
printf("Task %d started\n", id); {
int i; printf("Task %d started\n", id);
double result = 0.0; int i;
for (i = 0; i < 10000000; i++) { double result = 0.0;
result = result + cos(i) * sin(i); for (i = 0; i < 10000000; i++) {
} result = result + cos(i) * sin(i);
return result; }
return result;
} }
/* Same as 'task', but meant to be called from different threads. */ /* Same as 'task', but meant to be called from different threads. */
void *start_thread(void *t) { void *start_thread(void *t)
int id = (int) t; {
set_thread_affinity(id); int id = (int) t;
printf("Thread %ld started\n", id); set_thread_affinity(id);
double result = task(id); printf("Thread %ld started\n", id);
printf("Thread %ld done result %e\n", id, result); double result = task(id);
pthread_exit(0); printf("Thread %ld done result %e\n", id, result);
pthread_exit(0);
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[])
if (argc != 3) { {
return -1; if (argc != 3) {
} return -1;
int num_threads = atoi(argv[1]);
num_cores = atoi(argv[2]);
pthread_t thread[num_threads];
for (int i = 0; i < num_threads; i++) {
printf("Creating thread %ld\n", i);
int error = pthread_create(&thread[i], NULL, start_thread, (void *)i);
if (error) {
return -1;
} }
}
pthread_exit(NULL); int num_threads = atoi(argv[1]);
num_cores = atoi(argv[2]);
pthread_t thread[num_threads];
for (int i = 0; i < num_threads; i++) {
printf("Creating thread %ld\n", i);
int error = pthread_create(&thread[i], NULL, start_thread, (void *)i);
if (error) {
return -1;
}
}
pthread_exit(NULL);
} }