Commit f657a6f5 authored by Charlie Jacobsen's avatar Charlie Jacobsen
Browse files

lcd: Add empty_msg test.

parent 3a029e34
......@@ -137,6 +137,7 @@ AC_CONFIG_FILES(
src/platform/kernel/tests/Makefile
src/platform/kernel/tests/Kbuild
src/platform/kernel/tests/rpc/Kbuild
src/platform/kernel/tests/empty_msg/Kbuild
)
AC_OUTPUT
obj-m += rpc/
\ No newline at end of file
obj-m += rpc/
obj-m += empty_msg/
\ No newline at end of file
......@@ -2,3 +2,4 @@
# D=install dir (something/lib)
install-tests:
cp $(LIBFIPC_TESTS_KBUILD)/rpc/libfipc_test_rpc.ko $(D)
cp $(LIBFIPC_TESTS_KBUILD)/rpc/libfipc_test_empty_msg.ko $(D)
# @FIPC_AUTOCONF_NOTICE@
# Magic line so we can do out-of-source build
src = @abs_top_srcdir@/src/platform/kernel/tests/empty_msg
obj-m = libfipc_test_empty_msg.o
# Path are relative to root test/ dir
libfipc_test_empty_msg-y += main.o callee.o caller.o
libfipc_test_empty_msg-y += ../$(LIBFIPC_PATH) # libfipc.a is relative to tests/
ccflags-y += $(CFLAGS) $(AM_CPPFLAGS)
empty message test
==================
Overview
--------
This tests libfipc between two cores, in a caller-callee interaction.
One core, the caller, sends an empty message to the other core, the callee,
who responds with an empty message (only the message status changes).
Setup
-----
This example was ran on an Intel Xeon E5530 2.4 GHz machines. Make sure
you turn off TurboBoost in the BIOS, and make sure you turn up the
processor frequencies to 2.4 GHz.
We saw averages of 430 cycles for the null invocation round trip times
between cpu1 and cpu3.
To run this example, after building the .ko, just insmod it. The round trip
times will be printed to the kernel logs.
/*
* callee.c
*
* Code for the "callee side" of the channel
*
* Copyright: University of Utah
*/
#include <linux/kernel.h>
#include <libfipc.h>
#include "empty_msg.h"
#include "../test_helpers.h"
static inline int do_one_msg(struct fipc_ring_channel *chan)
{
int ret;
struct fipc_message *request;
struct fipc_message *response;
/*
* Receive empty request
*/
ret = test_fipc_blocking_recv_start(chan, &request);
if (ret)
goto fail1;
ret = fipc_recv_msg_end(chan, request);
if (ret)
goto fail2;
/*
* Send empty response
*/
ret = test_fipc_blocking_send_start(chan, &response);
if (ret)
goto fail3;
ret = fipc_send_msg_end(chan, response);
if (ret)
goto fail4;
return 0;
fail4:
fail3:
fail2:
fail1:
return ret;
}
int callee(void *_callee_channel_header)
{
struct fipc_ring_channel *chan = _callee_channel_header;
unsigned long transaction_id;
unsigned long start, end;
int ret = 0;
/*
* Turn off interrupts so that we truly take over the core
*/
local_irq_disable();
/*
* Do recv/send
*/
pr_err("Roundtrip Times (in cycles):\n");
for (transaction_id = 0;
transaction_id < TRANSACTIONS;
transaction_id++) {
start = test_fipc_start_stopwatch();
ret = do_one_msg(chan);
end = test_fipc_stop_stopwatch();
if (ret) {
pr_err("error in send/recv, ret = %d, exiting...\n",
ret);
goto out;
}
pr_err("\t%lu\n", end - start);
}
pr_err("Complete\n");
/*
* Re-enable interrupts
*/
local_irq_enable();
out:
return ret;
}
/*
* caller.c
*
* The "caller side" of the channel
*
* Copyright: University of Utah
*/
#include <linux/random.h>
#include "empty_msg.h"
#include "../test_helpers.h"
static inline int do_one_msg(struct fipc_ring_channel *chan)
{
int ret;
struct fipc_message *request;
struct fipc_message *response;
/*
* Send empty message
*/
ret = test_fipc_blocking_send_start(chan, &request);
if (ret)
goto fail1;
ret = fipc_send_msg_end(chan, request);
if (ret)
goto fail2;
/*
* Receive empty response
*/
ret = test_fipc_blocking_recv_start(chan, &response);
if (ret)
goto fail3;
ret = fipc_recv_msg_end(chan, response);
if (ret)
goto fail4;
return 0;
fail4:
fail3:
fail2:
fail1:
return ret;
}
int caller(void *_caller_channel_header)
{
struct fipc_ring_channel *chan = _caller_channel_header;
unsigned long transaction_id;
unsigned long start, end;
int ret = 0;
/*
* Turn off interrupts so that we truly take over the core
*/
local_irq_disable();
/*
* Do send/recv
*/
pr_err("Roundtrip Times (in cycles):\n");
for (transaction_id = 0;
transaction_id < TRANSACTIONS;
transaction_id++) {
start = test_fipc_start_stopwatch();
ret = do_one_msg(chan);
end = test_fipc_stop_stopwatch();
if (ret) {
pr_err("error in send/recv, ret = %d, exiting...\n",
ret);
goto out;
}
pr_err("\t%lu\n", end - start);
}
pr_err("Complete\n");
/*
* Re-enable interrupts
*/
local_irq_enable();
out:
return ret;
}
/*
* empty_msg.h
*
* Internal defs
*
* Copyright: University of Utah
*/
#ifndef LIBFIPC_EMPTY_MSG_TEST_H
#define LIBFIPC_EMPTY_MSG_TEST_H
#include <libfipc.h>
/* thread main functions */
int callee(void *_callee_channel_header);
int caller(void *_caller_channel_header);
#endif /* LIBFIPC_EMPTY_MSG_TEST_H */
/*
* main.c
*
* Contains init/exit for empty_msg test
*
* See README.txt for more details.
*/
#include <libfipc.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include "../test_helpers.h"
#include "empty_msg.h"
#define CALLER_CPU 1
#define CALLEE_CPU 3
/* channel buffers contain just one message slot */
#define CHANNEL_ORDER ilog2(sizeof(struct fipc_message))
MODULE_LICENSE("GPL");
static int setup_and_run_test(void)
{
int ret;
struct fipc_ring_channel *caller_header, *callee_header;
struct task_struct *caller_thread, *callee_thread;
/*
* Initialize fipc
*/
ret = fipc_init();
if (ret) {
pr_err("Error init'ing libfipc, ret = %d\n", ret);
goto fail0;
}
/*
* Set up channel
*/
ret = test_fipc_create_channel(CHANNEL_ORDER, &caller_header,
&callee_header);
if (ret) {
pr_err("Error creating channel, ret = %d\n", ret);
goto fail1;
}
/*
* Set up threads
*/
caller_thread = test_fipc_spawn_thread_with_channel(caller_header,
caller,
CALLER_CPU);
if (!caller_thread) {
pr_err("Error setting up caller thread\n");
goto fail2;
}
callee_thread = test_fipc_spawn_thread_with_channel(callee_header,
callee,
CALLEE_CPU);
if (!callee_thread) {
pr_err("Error setting up callee thread\n");
goto fail3;
}
/*
* Wake them up; they will run until they exit.
*/
wake_up_process(caller_thread);
wake_up_process(callee_thread);
/* wait for a second so we don't prematurely kill caller/callee */
msleep(1000);
/*
* Wait for them to complete, so we can tear things down
*/
ret = test_fipc_wait_for_thread(caller_thread);
if (ret)
pr_err("Caller returned non-zero exit status %d\n", ret);
ret = test_fipc_wait_for_thread(callee_thread);
if (ret)
pr_err("Callee returned non-zero exit status %d\n", ret);
/*
* Tear things down
*/
test_fipc_free_channel(CHANNEL_ORDER, caller_header, callee_header);
fipc_fini();
return 0;
fail3:
test_fipc_release_thread(caller_thread);
fail2:
test_fipc_free_channel(CHANNEL_ORDER, caller_header, callee_header);
fail1:
fipc_fini();
fail0:
return ret;
}
static int __init empty_msg_init(void)
{
int ret = 0;
ret = setup_and_run_test();
return ret;
}
static void __exit empty_msg_rmmod(void)
{
return;
}
module_init(empty_msg_init);
module_exit(empty_msg_rmmod);
rpc test
========
Overview
--------
This tests libfipc between two cores, in a caller-callee interaction.
One core, the caller, sends a message to the other core, the callee,
with a function identifier and arguments. The callee core invokes
the corresponding function with the arguments and passes back the
return value to the caller in another message.
The caller does an null_invocation rpc TRANSACTIONS/2 times. This function
just returns a value and does no arithmetic on the callee side.
The caller does an add_6_nums rpc TRANASCTIONS/2 times. This function adds
6 numbers, but it does so by calling other functions (add_3_nums, add_nums).
Setup
-----
This example was ran on an Intel Xeon E5530 2.4 GHz machines. Make sure
you turn off TurboBoost in the BIOS, and make sure you turn up the
processor frequencies to 2.4 GHz.
We saw averages of 430 cycles for the null invocation round trip times
between cpu1 and cpu3.
To run this example, after building the .ko, just insmod it. The round trip
times will be printed to the kernel logs.
......@@ -2,6 +2,8 @@
* main.c
*
* Contains init/exit for rpc test
*
* See README.txt for more details.
*/
#include <libfipc.h>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment