Can any one test my program to verify the problem? Regards, Kirby Zhou from SOHU-RD +86-10-6272-8261
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Kirby Zhou Sent: Sunday, August 08, 2010 6:54 PM To: 'Red Hat Enterprise Linux 6 (Santiago) Beta releases discussion mailing-list'; [email protected] Subject: Re: [rhelv6-beta-list] A simple program runs under KVM faster than under nake PC. A More simplified version: ]# g++ testaes2.cpp -lcrypto -lz RHEL6 nake [r...@djt_10_47 ~]# time ./a.out 1 10000 crc:a4580383 real 0m5.481s user 0m5.479s sys 0m0.001s RHEL6 KVM [r...@djt_10_199 ~]# time ./a.out 1 10000 crc:a4580383 real 0m2.959s user 0m2.950s sys 0m0.008s RHEL5 nake [...@djt_10_48 ~]# time ./a.out 1 10000 crc:a4580383 real 0m5.533s user 0m5.488s sys 0m0.000s RHEL5 Xen [...@djt_10_190 ~]# time ./a.out 1 10000 crc:a4580383 real 0m5.550s user 0m5.504s sys 0m0.000s RHEL5 KVM [...@djt_10_192 ~]# time ./a.out 1 10000 crc:a4580383 real 0m2.930s user 0m2.925s sys 0m0.003s ]# cat testaes2.cpp #define _XOPEN_SOURCE 500 #define __STDC_FORMAT_MACROS 1 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include <sys/types.h> #include <malloc.h> #include <stdint.h> #include <inttypes.h> #include <getopt.h> #include <vector> #include <algorithm> #include <zlib.h> #include <openssl/aes.h> #include <dlfcn.h> #define PAGE_SIZE 4096 void print_usage() { fprintf(stderr, "usage:\n"); fprintf(stderr, " [options] <loop_number> <total_request>\n"); fprintf(stderr, "\n"); } struct TestCaseDesc { unsigned thr_number; unsigned long long total_io; }; struct routine_context { int id; const TestCaseDesc* testcase; }; static uint32_t do_cpu(const TestCaseDesc& testcase, const off64_t io_off, size_t io_size, void* const buf, void* const jobbuf, uint32_t crc32_iv) { // fill data const uintmax_t tmp = io_off / 257; for (size_t i = 0; i < io_size; i+= sizeof(uintmax_t) ) { ((uintmax_t*)buf)[i/sizeof(uintmax_t)] = (i + tmp) & 0xf00fff; } AES_KEY key = {}; uint8_t iv[AES_BLOCK_SIZE] = {}; AES_set_encrypt_key((const uint8_t*)"hollyshitgodfather", 128, &key); AES_cbc_encrypt((const uint8_t*)buf, (uint8_t*)jobbuf, io_size, &key, iv, AES_ENCRYPT); uint32_t c = crc32(crc32_iv, (const uint8_t*)jobbuf, io_size); return c; } void* io_routine(void* _arg) { routine_context* arg = (routine_context*) _arg; const TestCaseDesc testcase = *arg->testcase; const size_t io_size = 32768; void* const buf = memalign(PAGE_SIZE, io_size); void* const jobbuf = memalign(PAGE_SIZE, io_size*2); uint32_t crc32_c = 0; for (int i=arg->id; i<testcase.total_io; i+=testcase.thr_number) { off64_t io_off = i*io_size; crc32_c = do_cpu(testcase, io_off, io_size, buf, jobbuf, crc32_c); } fprintf(stdout, "crc:%08x\n", crc32_c); } void process_arguments(int argc, char* argv[], TestCaseDesc* result) { TestCaseDesc testcase = { }; int c; bool opt_flag[256] = { }; char* perr_strto = NULL; while ( -1 != (c = getopt(argc, argv, "")) ) { opt_flag[c] = true; switch (c) { default: fprintf(stderr, "Invalid: -%c %s\n", c, optarg); print_usage(); exit(1); } if (perr_strto && *perr_strto) { fprintf(stderr, "Invalid number: %s\n", optarg); print_usage(); exit(1); } } if (argc - optind != 2) { print_usage(); exit(1); } testcase.thr_number = strtoul(argv[optind++], NULL, 0); testcase.total_io = strtoull(argv[optind++], NULL, 0); *result = testcase; } int main(int argc, char* argv[]) { TestCaseDesc testcase = { }; process_arguments(argc, argv, &testcase); routine_context* context = new routine_context[testcase.thr_number]; for (int i = 0; i < testcase.thr_number; ++i) { context[i].testcase = &testcase; context[i].id = i; } for (int i = 0; i < testcase.thr_number; ++i) { io_routine(&context[i]); } } Regards Kirby Zhou From: [email protected] [mailto:[email protected]] On Behalf Of Kirby Zhou Sent: Sunday, August 08, 2010 6:05 PM To: 'Red Hat Enterprise Linux 6 (Santiago) Beta releases discussion mailing-list'; [email protected] Subject: [rhelv6-beta-list] A simple program runs under KVM faster than under nake PC. Both RHEL5/RHEL6 encounter the same situation. Is there any potential bug? _______________________________________________ rhelv6-beta-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/rhelv6-beta-list _______________________________________________ rhelv5-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/rhelv5-list
