0

[update] PROBLEM SOLVED ! THE PROBLEM IS HARDWARE MODULE. I FIXED AFTER RESTARTING IT.

I wrote a C++ software with the purpose is to readout data from a hardware module to PC via Gigabit-Ethernet PCIe card (which is mounted in the PC). The library for this interface is quite special, thus, I used the library developed by a specialist of JAXA.

My software is like this

/*
 * tutorial_RMAPLayer.cc
 *
 *  Created on: Jan 10, 2012
 *      Author: yuasa
 */

#include "SpaceWireRMAPLibrary/SpaceWire.hh"
#include "SpaceWireRMAPLibrary/RMAP.hh"

double readTimeoutDuration = 1000;//1000ms
double writeTimeoutDuration = 1000;//1000ms

int main(int argc, char* argv[]) {
  //RMAPInitiator::timelib libcheck;
    using namespace std;
/* Open the SpaceWire interface */
cout << "Opening SpaceWireIF...";
SpaceWireIF* spwif = new SpaceWireIFOverIPClient("192.168.1.205", 10030);
try {
    spwif->open();
} catch (...) {
    cerr << "Connection timed out." << endl;
    exit(-1);
}
cout << "done" << endl;

/* Construct and start RMAP Engine */
RMAPEngine* rmapEngine = new RMAPEngine(spwif);
rmapEngine->start();

/* Construct an RMAP Initiator instance */
RMAPInitiator* rmapInitiator = new RMAPInitiator(rmapEngine);
rmapInitiator->setInitiatorLogicalAddress(0xFE);

/////////////////////////////////////////////////////////////////////////////////////

/* Manually sets RMAPTargetNode information */

RMAPTargetNode* rmapTargetNode1 = new RMAPTargetNode();
rmapTargetNode1->setTargetLogicalAddress(0xfe);
rmapTargetNode1->setDefaultKey(0x02);
std::vector<uint8_t> targetSpaceWireAddress;
targetSpaceWireAddress.push_back(0x09);
//targetSpaceWireAddress.push_back(0x0a);
//targetSpaceWireAddress.push_back(0x05);
rmapTargetNode1->setTargetSpaceWireAddress(targetSpaceWireAddress);
std::vector<uint8_t> replyAddress;
replyAddress.push_back(0x01);
//replyAddress.push_back(0x03);
//replyAddress.push_back(0x0f);
rmapTargetNode1->setReplyAddress(replyAddress);
cout << rmapTargetNode1->toString() << endl;

/* RMAP Read/Write with address/length */
try {
    uint32_t readLength = atoi(argv[1]);
    uint32_t readAddress = 0x2000000;
    std::vector<uint8_t> readDataVector(readLength);
    cout << "finish declaration" << endl;
    rmapInitiator->read(rmapTargetNode1, readAddress, readLength, &(readDataVector.at(0)), readTimeoutDuration);

    delete rmapTargetNode1;

    cout << "RMAP Read/Write Example1 done" << endl;
} catch (RMAPInitiatorException e) {
    cerr << "RMAPInitiatorException " << e.toString() << endl;
    cerr << "Continue to next example" << endl;
} catch (RMAPReplyException e) {
    cerr << "RMAPReplyException " << e.toString() << endl;
    cerr << "Continue to next example" << endl;
} catch (RMAPEngineException e) {
    cerr << "RMAPEngineException " << e.toString() << endl;
    cerr << "Continue to next example" << endl;
} catch (...) {
    cerr << "Unkown error" << endl;
    exit(-1);
}

This software can read data out with different package size by changing the variable readLength in the c++ code (readLength has unit of Bytes).

Here is my problem: 3 days ago, the computer has some problem, I reinstalled the Linux (Scientific Linux 6.6). The speeds of this software before and after re-installation are so different. In detail, the 1000 Bytes packet before is 1.6 MB/sec but now it is 0.6 MB/sec.

I used strace to figure out the problem, and I found that the [futex] caused main problem. Below is the result I used strace. I found that the line of futex (8th line from the bottom) caused the big overhead of my software (1283 micro seconds !).

execve("./sampleApp", ["./sampleApp", "1000"], [/* 40 vars */]) = 0 <0.000758>
brk(0)                                  = 0x23b2000 <0.000034>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60d801000 <0.000038>
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory) <0.000066>
open("/opt/rh/devtoolset-2/root/usr/lib64/tls/x86_64/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000060>1
stat("/opt/rh/devtoolset-2/root/usr/lib64/tls/x86_64", 0x7ffd3811b500) = -1 ENOENT (No such file or directory) <0.000046>
open("/opt/rh/devtoolset-2/root/usr/lib64/tls/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000048>
stat("/opt/rh/devtoolset-2/root/usr/lib64/tls", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 <0.000047>
open("/opt/rh/devtoolset-2/root/usr/lib64/x86_64/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000046>
stat("/opt/rh/devtoolset-2/root/usr/lib64/x86_64", 0x7ffd3811b500) = -1 ENOENT (No such file or directory) <0.000053>
open("/opt/rh/devtoolset-2/root/usr/lib64/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000053>
stat("/opt/rh/devtoolset-2/root/usr/lib64", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0 <0.000049>
open("/opt/rh/devtoolset-2/root/usr/lib/tls/x86_64/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000053>
stat("/opt/rh/devtoolset-2/root/usr/lib/tls/x86_64", 0x7ffd3811b500) = -1 ENOENT (No such file or directory) <0.000048>
open("/opt/rh/devtoolset-2/root/usr/lib/tls/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000050>
stat("/opt/rh/devtoolset-2/root/usr/lib/tls", 0x7ffd3811b500) = -1 ENOENT (No such file or directory) <0.000049>
open("/opt/rh/devtoolset-2/root/usr/lib/x86_64/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000055>
stat("/opt/rh/devtoolset-2/root/usr/lib/x86_64", 0x7ffd3811b500) = -1 ENOENT (No such file or directory) <0.000050>
open("/opt/rh/devtoolset-2/root/usr/lib/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000052>
stat("/opt/rh/devtoolset-2/root/usr/lib", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0 <0.000048>
open("/etc/ld.so.cache", O_RDONLY)      = 3 <0.000050>
fstat(3, {st_mode=S_IFREG|0644, st_size=61960, ...}) = 0 <0.000039>
mmap(NULL, 61960, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fd60d7f1000 <0.000043>
close(3)                                = 0 <0.000030>
open("/lib64/librt.so.1", O_RDONLY)     = 3 <0.000055>
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@! \3652\0\0\0"..., 832) = 832 <0.000041>
fstat(3, {st_mode=S_IFREG|0755, st_size=47112, ...}) = 0 <0.000038>
mmap(0x32f5200000, 2128816, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x32f5200000 <0.000043>
mprotect(0x32f5207000, 2093056, PROT_NONE) = 0 <0.000047>
mmap(0x32f5406000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x32f5406000 <0.000052>
close(3)                                = 0 <0.000037>
open("/opt/rh/devtoolset-2/root/usr/lib64/tls/libxerces-c-3.0.so", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000076>
open("/opt/rh/devtoolset-2/root/usr/lib64/libxerces-c-3.0.so", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000051>
open("/opt/rh/devtoolset-2/root/usr/lib/libxerces-c-3.0.so", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000050>
open("/usr/lib64/libxerces-c-3.0.so", O_RDONLY) = 3 <0.000051>
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\251\23\0\0\0\0\0"..., 832) = 832 <0.000040>
fstat(3, {st_mode=S_IFREG|0755, st_size=3803616, ...}) = 0 <0.000038>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60d7f0000 <0.000040>
mmap(NULL, 5900296, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fd60d24f000 <0.000042>
mprotect(0x7fd60d5b2000, 2093056, PROT_NONE) = 0 <0.000048>
mmap(0x7fd60d7b1000, 258048, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x362000) = 0x7fd60d7b1000 <0.000047>
close(3)                                = 0 <0.000055>
open("/opt/rh/devtoolset-2/root/usr/lib64/tls/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000099>
open("/opt/rh/devtoolset-2/root/usr/lib64/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000054>
open("/opt/rh/devtoolset-2/root/usr/lib/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000052>
open("/lib64/libpthread.so.0", O_RDONLY) = 3 <0.000054>
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340]\240\3642\0\0\0"..., 832) = 832 <0.000040>
fstat(3, {st_mode=S_IFREG|0755, st_size=145896, ...}) = 0 <0.000042>
mmap(0x32f4a00000, 2212848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x32f4a00000 <0.000042>
mprotect(0x32f4a17000, 2097152, PROT_NONE) = 0 <0.000061>
mmap(0x32f4c17000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x32f4c17000 <0.000072>
mmap(0x32f4c19000, 13296, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x32f4c19000 <0.000047>
close(3)                                = 0 <0.000036>
open("/opt/rh/devtoolset-2/root/usr/lib64/tls/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000106>
open("/opt/rh/devtoolset-2/root/usr/lib64/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000049>
open("/opt/rh/devtoolset-2/root/usr/lib/libstdc++.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000073>
open("/usr/lib64/libstdc++.so.6", O_RDONLY) = 3 <0.000061>
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360ce\0003\0\0\0"..., 832) = 832 <0.000036>
fstat(3, {st_mode=S_IFREG|0755, st_size=989840, ...}) = 0 <0.000034>
mmap(0x3300600000, 3166648, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3300600000 <0.000039>
mprotect(0x33006e8000, 2097152, PROT_NONE) = 0 <0.000042>
mmap(0x33008e8000, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe8000) = 0x33008e8000 <0.000049>
mmap(0x33008f1000, 82360, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x33008f1000 <0.000060>
close(3)                                = 0 <0.000040>
open("/opt/rh/devtoolset-2/root/usr/lib64/tls/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000062>
open("/opt/rh/devtoolset-2/root/usr/lib64/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000051>
open("/opt/rh/devtoolset-2/root/usr/lib/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000050>
open("/lib64/libm.so.6", O_RDONLY)      = 3 <0.000055>
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p>\240\3652\0\0\0"..., 832) = 832 <0.000040>
fstat(3, {st_mode=S_IFREG|0755, st_size=599392, ...}) = 0 <0.000037>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60d24e000 <0.000057>
mmap(0x32f5a00000, 2633912, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x32f5a00000 <0.000057>
mprotect(0x32f5a83000, 2093056, PROT_NONE) = 0 <0.000045>
mmap(0x32f5c82000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x82000) = 0x32f5c82000 <0.000046>
close(3)                                = 0 <0.000037>
open("/opt/rh/devtoolset-2/root/usr/lib64/tls/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000055>
open("/opt/rh/devtoolset-2/root/usr/lib64/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000051>
open("/opt/rh/devtoolset-2/root/usr/lib/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000050>
open("/lib64/libgcc_s.so.1", O_RDONLY)  = 3 <0.000068>
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20)\240\3772\0\0\0"..., 832) = 832 <0.000039>
fstat(3, {st_mode=S_IFREG|0755, st_size=93320, ...}) = 0 <0.000037>
mmap(0x32ffa00000, 2186584, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x32ffa00000 <0.000043>
mprotect(0x32ffa16000, 2093056, PROT_NONE) = 0 <0.000044>
mmap(0x32ffc15000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x32ffc15000 <0.000046>
close(3)                                = 0 <0.000037>
open("/opt/rh/devtoolset-2/root/usr/lib64/tls/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000062>
open("/opt/rh/devtoolset-2/root/usr/lib64/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000049>
open("/opt/rh/devtoolset-2/root/usr/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000050>
open("/lib64/libc.so.6", O_RDONLY)      = 3 <0.000052>
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p\356a\3642\0\0\0"..., 832) = 832 <0.000039>
fstat(3, {st_mode=S_IFREG|0755, st_size=1926760, ...}) = 0 <0.000038>
mmap(0x32f4600000, 3750152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x32f4600000 <0.000042>
mprotect(0x32f478a000, 2097152, PROT_NONE) = 0 <0.000048>
mmap(0x32f498a000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18a000) = 0x32f498a000 <0.000061>
mmap(0x32f498f000, 18696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x32f498f000 <0.000045>
close(3)                                = 0 <0.000036>
open("/opt/rh/devtoolset-2/root/usr/lib64/tls/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000055>
open("/opt/rh/devtoolset-2/root/usr/lib64/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000052>
open("/opt/rh/devtoolset-2/root/usr/lib/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000051>
open("/lib64/libnsl.so.1", O_RDONLY)    = 3 <0.000053>
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p@\340\0053\0\0\0"..., 832) = 832 <0.000038>
fstat(3, {st_mode=S_IFREG|0755, st_size=116368, ...}) = 0 <0.000037>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60d24d000 <0.000042>
mmap(0x3305e00000, 2198192, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x3305e00000 <0.000043>
mprotect(0x3305e16000, 2093056, PROT_NONE) = 0 <0.000043>
mmap(0x3306015000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x3306015000 <0.000048>
mmap(0x3306017000, 6832, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x3306017000 <0.000045>
close(3)                                = 0 <0.000029>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60d24c000 <0.000040>
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60d24a000 <0.000038>
arch_prctl(ARCH_SET_FS, 0x7fd60d24a720) = 0 <0.000036>
mprotect(0x3306015000, 4096, PROT_READ) = 0 <0.000045>
mprotect(0x32f498a000, 16384, PROT_READ) = 0 <0.000043>
mprotect(0x32f5c82000, 4096, PROT_READ) = 0 <0.000045>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60d249000 <0.000045>
mprotect(0x33008e8000, 28672, PROT_READ) = 0 <0.000048>
mprotect(0x32f4c17000, 4096, PROT_READ) = 0 <0.000046>
mprotect(0x32f5406000, 4096, PROT_READ) = 0 <0.000088>
mprotect(0x32f441f000, 4096, PROT_READ) = 0 <0.000052>
munmap(0x7fd60d7f1000, 61960)           = 0 <0.000094>
set_tid_address(0x7fd60d24a9f0)         = 12598 <0.000035>
set_robust_list(0x7fd60d24aa00, 24)     = 0 <0.000034>
futex(0x7ffd3811bdfc, FUTEX_WAKE_PRIVATE, 1) = 0 <0.000037>
futex(0x7ffd3811bdfc, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, 7fd60d24a720) = -1 EAGAIN (Resource temporarily unavailable) <0.000036>
rt_sigaction(SIGRTMIN, {0x32f4a05c60, [], SA_RESTORER|SA_SIGINFO, 0x32f4a0f710}, NULL, 8) = 0 <0.000036>
rt_sigaction(SIGRT_1, {0x32f4a05cf0, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x32f4a0f710}, NULL, 8) = 0 <0.000034>
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0 <0.000035>
getrlimit(RLIMIT_STACK, {rlim_cur=10240*1024, rlim_max=RLIM64_INFINITY}) = 0 <0.000036>
futex(0x33008f1d08, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000045>
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 2), ...}) = 0 <0.000039>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60d800000 <0.000046>
brk(0)                                  = 0x23b2000 <0.000035>
brk(0x23d3000)                          = 0x23d3000 <0.000039>
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3 <0.000098>
open("/etc/resolv.conf", O_RDONLY)      = 4 <0.000066>
fstat(4, {st_mode=S_IFREG|0644, st_size=88, ...}) = 0 <0.000036>
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60d7ff000 <0.000038>
read(4, "# Generated by NetworkManager\nse"..., 4096) = 88 <0.000053>
read(4, "", 4096)                       = 0 <0.000035>
close(4)                                = 0 <0.000039>
munmap(0x7fd60d7ff000, 4096)            = 0 <0.000065>
fcntl(3, F_GETFL)                       = 0x2 (flags O_RDWR) <0.000036>
fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK)    = 0 <0.000035>
connect(3, {sa_family=AF_INET, sin_port=htons(10030), sin_addr=inet_addr("192.168.1.205")}, 16) = -1 EINPROGRESS (Operation now in progress) <0.000181>
select(4, NULL, [3], NULL, {1, 0})      = 1 (out [3], left {0, 996039}) <0.004019>
getpeername(3, {sa_family=AF_INET, sin_port=htons(10030), sin_addr=inet_addr("192.168.1.205")}, [16]) = 0 <0.000049>
fcntl(3, F_SETFL, O_RDWR)               = 0 <0.000043>
setsockopt(3, SOL_SOCKET, SO_RCVTIMEO, "\0\0\0\0\0\0\0\0 \241\7\0\0\0\0\0", 16) = 0 <0.000045>
setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0 <0.000044>
mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60c848000 <0.000060>
mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd60be47000 <0.000043>
write(1, "Opening SpaceWireIF...done\n", 27) = 27 <0.000060>
brk(0x23f4000)                          = 0x23f4000 <0.000046>
brk(0x2415000)                          = 0x2415000 <0.000049>
brk(0x2436000)                          = 0x2436000 <0.000043>
brk(0x2457000)                          = 0x2457000 <0.000044>
brk(0x2478000)                          = 0x2478000 <0.000044>
brk(0x2499000)                          = 0x2499000 <0.000058>
brk(0x24ba000)                          = 0x24ba000 <0.000043>
brk(0x24db000)                          = 0x24db000 <0.000042>
brk(0x24fc000)                          = 0x24fc000 <0.000043>
brk(0x251d000)                          = 0x251d000 <0.000044>
brk(0x253e000)                          = 0x253e000 <0.000044>
brk(0x255f000)                          = 0x255f000 <0.000043>
brk(0x2580000)                          = 0x2580000 <0.000044>
brk(0x25a1000)                          = 0x25a1000 <0.000043>
brk(0x25c2000)                          = 0x25c2000 <0.000044>
mmap(NULL, 10489856, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fd60b446000 <0.000052>
mprotect(0x7fd60b446000, 4096, PROT_NONE) = 0 <0.000055>
clone(child_stack=0x7fd60be45fd0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fd60be469d0, tls=0x7fd60be46700, child_tidptr=0x7fd60be469d0) = 12599 <0.000098>
write(1, "ID                        : \nTar"..., 162) = 162 <0.000085>
write(1, "\n", 1)                       = 1 <0.000064>
write(1, "finish declaration\n", 19)    = 19 <0.000044>
write(1, "rx start\n", 9)               = 9 <0.000044>
write(1, "rx set parameters\n", 18)     = 18 <0.000045>
sendto(3, "\0\0\0\0\0\0\0\0\0\0\0\25", 12, 0, NULL, 0) = 12 <0.000079>
sendto(3, "\t\376\1M\2\0\0\0\1\376\0\0\0\2\0\0\0\0\3\3506", 21, 0, NULL, 0) = 21 <0.000144>
write(1, "rx initiate TID\n", 16)       = 16 <0.000048>
futex(0x25b2cac, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, {1438329719, 587231000}, ffffffff) = 0 <0.001283>
futex(0x25b2c70, FUTEX_WAKE_PRIVATE, 1) = 0 <0.000043>
write(1, "rx receive\n", 11)            = 11 <0.000055>
write(1, "rx copy\n", 8)                = 8 <0.000041>
write(1, "rx end\n", 7)                 = 7 <0.000041>
write(1, "RMAP Read/Write Example1 done\n", 30) = 30 <0.000041>
exit_group(0)                           = ?
+++ exited with 0 +++

The software is quite complicated (to me, at least), it consists of generate thread, TID, ... before reading process. In this report of strace you will see: at nearly the end (about last 10 lines) there are some cout of finish declaration, rx start, rx set parameters, rx initiate TID, rx receive, rx copy, rx end, which I mark (in the software and library) to know where the reading process begins.

Here is the futex line that I mentioned

futex(0x25b2cac, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, {1438329719, 587231000}, ffffffff) = 0 <0.001283>e

In total, the reading process spends 1500 micro-seconds, compared with the reading time before 600 micro-seconds (2.5 times larger).

I also compared the result with a C library data readout, the C library is 1.8 MB/sec. Thus, I think have no mistake with the driver of Gigabit-Ethernet PCIe card.

I searched much on the internet but still no solutions. How can reduce this overhead ? Or how can I identify which function in the library caused this futex-overhead ?

Thanks in advance. I am in a hurry to finish this step. Thus I really really wish for a soon solution....

EDIT: I make some several more tests. I found that with the packet size <= (less or equal to) 100 Bytes, the speed is not changed compared to before. But from 200 Bytes, it is much slower. I also think about MTU but the setting for MTU is not changed (before and after re-installation). EDIT (2015/08/02): the strace reports the futex in my software, but I cannot find any futex command in my library.

  • Its not clear what you are asking. – 463035818_is_not_an_ai Jul 31 '15 at 09:25
  • sorry, problem with the internet. It is now edited – Bui Tuan Khai Jul 31 '15 at 09:45
  • one more thing, I used the C library and read out data with the same arrangement as mentioned above, and the speed is 1.8MB/sec. Thus, I think I have know problem with the hardware driver. the problem is somewhere related to the C++ ..... – Bui Tuan Khai Jul 31 '15 at 09:56
  • More clearly, the data readout (TCP/IP) consists of several steps: construct packet, send request for reading, wait for the read data comes, copy data to the desired address. Before, my reading process spends about 600 micro-seconds in total, but now it is 1500 micro-seconds in total, too big different. I must reduce the reading time, thus I check by using strace command, and I found the overhead comes from the "futex(0x25b2cac, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, {1438329719, 587231000}, ffffffff) = 0 <0.001283>". – Bui Tuan Khai Jul 31 '15 at 10:10
  • Using google-fu I found someone had a similar problem, which may be what affects you too. See https://www.axigen.com/forum/showthread.php?t=9619 – Surt Jul 31 '15 at 10:18
  • Dear Surt, thank you for your advice. I tried. it does not work .... – Bui Tuan Khai Jul 31 '15 at 10:45
  • Please format this illigible mess, and tell us where in this code `futex()’` is being called from. – user207421 Aug 02 '15 at 08:28
  • Dear EJP, futex() is not called in the either library nor my software. I think it comes from the pthread_cond_wait function. And which part in my publishing makes you confused ? THank you very much – Bui Tuan Khai Aug 02 '15 at 09:50

0 Answers0