]> git.proxmox.com Git - mirror_kronosnet.git/commitdiff
[test] add ability to knet_bench to specify a fixed packet size for perf test
authorFabio M. Di Nitto <fdinitto@redhat.com>
Tue, 15 Oct 2019 05:16:22 +0000 (07:16 +0200)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Tue, 15 Oct 2019 10:29:05 +0000 (12:29 +0200)
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
libknet/tests/knet_bench.c

index a60169f9de36a2eca72a4594497cfa346f806c03..14dcb55bb8977e27dd2650a0e0659f7816fd2c0d 100644 (file)
@@ -66,6 +66,8 @@ static int test_type = TEST_PING;
 static uint64_t perf_by_size_size = 1 * ONE_GIGABYTE;
 static uint64_t perf_by_time_secs = 10;
 
+static uint32_t force_packet_size = 0;
+
 struct node {
        int nodeid;
        int links;
@@ -108,6 +110,7 @@ static void print_help(void)
        printf(" -s                                        nodeid that will generate traffic for benchmarks\n");
        printf(" -S [size|seconds]                         when used in combination with -T perf-by-size it indicates how many GB of traffic to generate for the test. (default: 1GB)\n");
        printf("                                           when used in combination with -T perf-by-time it indicates how many Seconds of traffic to generate for the test. (default: 10 seconds)\n");
+       printf(" -x                                        force packet size for perf-by-time or perf-by-size\n");
        printf(" -C                                        repeat the test continously (default: off)\n");
        printf(" -X[XX]                                    show stats at the end of the run (default: 1)\n");
        printf("                                           1: show handle stats, 2: show summary link stats\n");
@@ -249,7 +252,7 @@ static void setup_knet(int argc, char *argv[])
 
        memset(nodes, 0, sizeof(nodes));
 
-       while ((rv = getopt(argc, argv, "aCT:S:s:ldfom:wb:t:n:c:p:X::P:z:h")) != EOF) {
+       while ((rv = getopt(argc, argv, "aCT:S:s:ldfom:wb:t:n:c:p:x:X::P:z:h")) != EOF) {
                switch(rv) {
                        case 'h':
                                print_help();
@@ -405,6 +408,13 @@ static void setup_knet(int argc, char *argv[])
                                perf_by_size_size = (uint64_t)atoi(optarg) * ONE_GIGABYTE;
                                perf_by_time_secs = (uint64_t)atoi(optarg);
                                break;
+                       case 'x':
+                               force_packet_size = (uint32_t)atoi(optarg);
+                               if ((force_packet_size < 1) || (force_packet_size > 65536)) {
+                                       printf("Unsupported packet size %u (accepted 1 - 65536)\n", force_packet_size);
+                                       exit(FAIL);
+                               }
+                               break;
                        case 'C':
                                continous = 1;
                                break;
@@ -873,7 +883,7 @@ static int setup_send_buffers_common(struct knet_mmsghdr *msg, struct iovec *iov
                        printf("TXT: Unable to malloc!\n");
                        return -1;
                }
-               memset(tx_buf[i], 0, KNET_MAX_PACKET_SIZE);
+               memset(tx_buf[i], i, KNET_MAX_PACKET_SIZE);
                iov_out[i].iov_base = (void *)tx_buf[i];
                memset(&msg[i].msg_hdr, 0, sizeof(struct msghdr));
                msg[i].msg_hdr.msg_iov = &iov_out[i];
@@ -897,6 +907,9 @@ static void send_perf_data_by_size(void)
        setup_send_buffers_common(msg, iov_out, tx_buf);
 
        while (packetsize <= KNET_MAX_PACKET_SIZE) {
+               if (force_packet_size) {
+                       packetsize = force_packet_size;
+               }
                for (i = 0; i < PCKT_FRAG_MAX; i++) {
                        iov_out[i].iov_len = packetsize;
                }
@@ -925,7 +938,7 @@ static void send_perf_data_by_size(void)
 
                knet_send(knet_h, ctrl_message, TEST_STOP, channel);
 
-               if (packetsize == KNET_MAX_PACKET_SIZE) {
+               if ((packetsize == KNET_MAX_PACKET_SIZE) || (force_packet_size)) {
                        break;
                }
 
@@ -1177,6 +1190,9 @@ static void send_perf_data_by_time(void)
        memset(&clock_end, 0, sizeof(clock_start));
 
        while (packetsize <= KNET_MAX_PACKET_SIZE) {
+               if (force_packet_size) {
+                       packetsize = force_packet_size;
+               }
                for (i = 0; i < PCKT_FRAG_MAX; i++) {
                        iov_out[i].iov_len = packetsize;
                }
@@ -1207,7 +1223,7 @@ static void send_perf_data_by_time(void)
 
                knet_send(knet_h, ctrl_message, TEST_STOP, channel);
 
-               if (packetsize == KNET_MAX_PACKET_SIZE) {
+               if ((packetsize == KNET_MAX_PACKET_SIZE) || (force_packet_size)) {
                        break;
                }