On 3 December 2014 at 17:24, Ivan T. Ivanov iivanov@mm-sol.com wrote:
On Wed, 2014-12-03 at 15:08 +0800, Pi-Cheng Chen wrote:
On 2 December 2014 at 19:04, Vincent Guittot guittot@linaro.org> wrote:
On 2 December 2014 at 08:21, pi-cheng.chen chen@linaro.org> wrote:
Add 2 new kind of event for running a memory or a io bounded load. "mem" name for a load is memory bounded, and "iorun" name for a load is io bounded. The default file to be written to create the load is /dev/null and the device/file could be specified with "io_device" key in "global" section.
Hi pi-cheng
What's the unit of the mem and iorun ? As an example, "mem" : 2000 will do a copy of 2000 Bytes ? KBytes ?
Hi Vincent,
Thanks for reviewing. The unit of mem and iorun here is the size to be copied/written in byte. As an example, "mem" : 2000 will do a 2000 bytes copy.
E.g. "tasks" : { "thread0" : { "sleep" : 1000, "run" : 100, "mem" : 1000, "sleep" 10000, "iorun" : 1000 } }, "global" : { "io_device" : "/dev/ttyS0" }
Signed-off-by: pi-cheng.chen chen@linaro.org>
src/rt-app.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++ src/rt-app.h | 2 ++ src/rt-app_parse_config.c | 23 +++++++++++++++ src/rt-app_types.h | 4 +++ 4 files changed, 103 insertions(+)
diff --git a/src/rt-app.c b/src/rt-app.c index 3cd601d..13f72e4 100644 --- a/src/rt-app.c +++ b/src/rt-app.c @@ -33,6 +33,8 @@ static volatile int continue_running; static pthread_t *threads; static int nthreads; static int p_load; +static char *buffer[2]; +static int io_fd; rtapp_options_t opts;
static ftrace_data_t ft_data = { @@ -110,6 +112,45 @@ static inline loadwait(unsigned long exec) return load_count; }
+static void ioload(unsigned long count) +{
ssize_t ret;
char *buf = buffer[0];
while (count != 0) {
ret = write(io_fd, buffer, count);
count can be higher than buffer size
so you have defined a MEM_BUFFER_SIZE for mem transfer but not for iorun ?
I forgot to do such check for iorun. Will do it.
if (ret == -1) {
perror("write");
return;
}
count -= ret;
buf += ret;
}
+}
+static void memload(unsigned long count) +{
static unsigned long current = 0;
while (count > 0) {
unsigned long size;
if (count > MEM_BUFFER_SIZE)
size = MEM_BUFFER_SIZE;
else
size = count;
if (size > (MEM_BUFFER_SIZE - current))
size = MEM_BUFFER_SIZE - current;
memcpy(buffer[0], buffer[1], size);
I wonder if a memset would be better
Sure. Will do it.
count -= size;
current += size;
if (current >= MEM_BUFFER_SIZE)
current -= MEM_BUFFER_SIZE;
The size of MEM_BUFFER_SIZE will deeply impact how we will trash the cache and how the memory access (up to the ddr) will be the bottleneck. This should be at least configurable in the global section
I was thinking is there a generic way the get the cache size of the CPU, but I failed to do so. So I just set it as a size bigger than the size of cache on my laptop, which is 3MB. Yes I should make it configurable in the global section.
Ok, so buffer size could be specified in json file. But why there should be limitation like MEM_BUFFER_SIZE, could we just leave buffer size decision to user?
Hi Ivan,
MEM_BUFFER_SIZE should be replaced with the buffer size specified in "global" section in JSON file in next version. The reason why we have this limitation here is to prevent buffer overflow from happening. IOW, the size of memory to be write in a event (specified with "mem" key) might be larger than the memory buffer allocated to create the load (will be specified in "global" section).
There is no guarantee that CPU will touch the buffers with memcpy. It depends how memcpy is implemented. Could we use straight buf1[x] = buf2[x] or something more fancy?
How do you think about memset suggested by Vincent?
Thanks Pi-Cheng
Thanks, Ivan