Index: src/worker.cc =================================================================== --- src/worker.cc (revision 24) +++ src/worker.cc (working copy) @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include // These are necessary, but on by default // #define __USE_GNU @@ -38,13 +41,12 @@ #include #include #include -#include // for gettid +#include // For size of block device #include -#include // For asynchronous I/O -#include +#include #include @@ -410,9 +412,9 @@ // mask = 3 (11b): cpu0, 1 // mask = 13 (1101b): cpu0, 2, 3 uint32 WorkerThread::AvailableCpus() { - cpu_set_t curr_cpus; + cpuset_t curr_cpus; CPU_ZERO(&curr_cpus); - sched_getaffinity(getppid(), sizeof(curr_cpus), &curr_cpus); + cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, getppid(), sizeof(curr_cpus), &curr_cpus); return cpuset_to_uint32(&curr_cpus); } @@ -422,9 +424,9 @@ // mask = 3 (11b): cpu0, 1 // mask = 13 (1101b): cpu0, 2, 3 uint32 WorkerThread::CurrentCpus() { - cpu_set_t curr_cpus; + cpuset_t curr_cpus; CPU_ZERO(&curr_cpus); - sched_getaffinity(0, sizeof(curr_cpus), &curr_cpus); + cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(curr_cpus), &curr_cpus); return cpuset_to_uint32(&curr_cpus); } @@ -449,9 +451,9 @@ thread_mask, process_mask); return false; } - cpu_set_t cpuset; + cpuset_t cpuset; cpuset_from_uint32(thread_mask, &cpuset); - return (sched_setaffinity(gettid(), sizeof(cpuset), &cpuset) == 0); + return (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, gettid(), sizeof(cpuset), &cpuset) == 0); } @@ -2484,7 +2486,7 @@ device_sectors_ = 0; non_destructive_ = 0; - aio_ctx_ = 0; + //aio_ctx_ = 0; block_table_ = block_table; update_block_table_ = 1; @@ -2618,7 +2620,7 @@ bool DiskThread::OpenDevice(int *pfile) { int fd = open(device_name_.c_str(), - O_RDWR | O_SYNC | O_DIRECT | O_LARGEFILE, + O_RDWR | O_SYNC | O_DIRECT, 0); if (fd < 0) { logprintf(0, "Process Error: Failed to open device %s (thread %d)!!\n", @@ -2644,7 +2646,7 @@ if (S_ISBLK(device_stat.st_mode)) { uint64 block_size = 0; - if (ioctl(fd, BLKGETSIZE64, &block_size) == -1) { + if (ioctl(fd, DIOCGMEDIASIZE, &block_size) == -1) { logprintf(0, "Process Error: Unable to ioctl disk %s (thread %d).\n", device_name_.c_str(), thread_num_); return false; @@ -2797,12 +2799,13 @@ // Do an asynchronous disk I/O operation. bool DiskThread::AsyncDiskIO(IoOp op, int fd, void *buf, int64 size, int64 offset, int64 timeout) { + return false; // Use the Linux native asynchronous I/O interface for reading/writing. // A read/write consists of three basic steps: // 1. create an io context. // 2. prepare and submit an io request to the context // 3. wait for an event on the context. - +/* struct { const int opcode; const char *op_str; @@ -2812,7 +2815,7 @@ { IOCB_CMD_PWRITE, "write", "disk-write-error" } }; - struct iocb cb; + struct aiocb cb; memset(&cb, 0, sizeof(cb)); cb.aio_fildes = fd; @@ -2821,8 +2824,13 @@ cb.aio_nbytes = size; cb.aio_offset = offset; - struct iocb *cbs[] = { &cb }; - if (io_submit(aio_ctx_, 1, cbs) != 1) { + int aioret; + if (op == ASYNC_IO_READ) + aioret = aio_read(&cb); + else + aioret = aio_write(&cb); + + if (aioret != 0) { logprintf(0, "Process Error: Unable to submit async %s " "on disk %s (thread %d).\n", operations[op].op_str, device_name_.c_str(), @@ -2856,8 +2864,8 @@ // Since io_cancel is always failing, destroying and recreating an I/O // context is a workaround for canceling an in-progress I/O operation. // TODO(amistry): Find out why io_cancel isn't working and make it work. - io_cancel(aio_ctx_, &cb, &event); - io_destroy(aio_ctx_); + aio_cancel(aio_ctx_, &cb, &event); + aio_destroy(aio_ctx_); aio_ctx_ = 0; if (io_setup(5, &aio_ctx_)) { logprintf(0, "Process Error: Unable to create aio context on disk %s" @@ -2897,7 +2905,7 @@ return false; } - return true; + return true;*/ } // Write a block to disk. @@ -3053,7 +3061,8 @@ return false; } - if (io_setup(5, &aio_ctx_)) { + //if (io_setup(5, &aio_ctx_)) { + if (1) { logprintf(0, "Process Error: Unable to create aio context for disk %s" " (thread %d).\n", device_name_.c_str(), thread_num_); @@ -3064,7 +3073,7 @@ status_ = 1; - io_destroy(aio_ctx_); + //io_destroy(aio_ctx_); CloseDevice(fd); free(block_buffer_); Index: src/worker.h =================================================================== --- src/worker.h (revision 24) +++ src/worker.h (working copy) @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include @@ -727,7 +727,7 @@ // not verified. void *block_buffer_; // Pointer to aligned block buffer. - aio_context_t aio_ctx_; // Asynchronous I/O context for Linux native AIO. + //aio_context_t aio_ctx_;; // Asynchronous I/O context for Linux native AIO. DiskBlockTable *block_table_; // Disk Block Table, shared by all disk // threads that read / write at the same Index: src/sattypes.h =================================================================== --- src/sattypes.h (revision 24) +++ src/sattypes.h (working copy) @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -95,7 +97,7 @@ #endif // Make using CPUSET non-super-painful. -static inline uint32 cpuset_to_uint32(cpu_set_t *cpuset) { +static inline uint32 cpuset_to_uint32(cpuset_t *cpuset) { uint32 value = 0; for (int index = 0; index < CPU_SETSIZE; index++) { if (CPU_ISSET(index, cpuset)) { @@ -110,7 +112,7 @@ return value; } -static inline void cpuset_from_uint32(uint32 mask, cpu_set_t *cpuset) { +static inline void cpuset_from_uint32(uint32 mask, cpuset_t *cpuset) { CPU_ZERO(cpuset); for (int index = 0; index < 32; index++) { if (mask & (1 << index)) @@ -143,7 +145,8 @@ // error_num: an errno error code inline string ErrorString(int error_num) { char buf[256]; - return string(strerror_r(error_num, buf, sizeof buf)); + strerror_r(error_num, buf, sizeof buf); + return string(buf); } // Define handy constants here Index: src/os.cc =================================================================== --- src/os.cc (revision 24) +++ src/os.cc (working copy) @@ -22,8 +22,6 @@ #include #include -#include -#include #include #include #include @@ -170,7 +168,7 @@ } // Report which cores are associated with a given region. -cpu_set_t *OsLayer::FindCoreMask(int32 region) { +cpuset_t *OsLayer::FindCoreMask(int32 region) { sat_assert(region >= 0); region %= num_nodes_; if (!cpu_sets_valid_[region]) { @@ -232,7 +230,7 @@ return totalmemsize_; int64 pages = sysconf(_SC_PHYS_PAGES); - int64 avpages = sysconf(_SC_AVPHYS_PAGES); + int64 avpages = 0; // sysconf(_SC_AVPHYS_PAGES) not supported on FreeBSD int64 pagesize = sysconf(_SC_PAGESIZE); int64 physsize = pages * pagesize; int64 avphyssize = avpages * pagesize; @@ -341,11 +339,10 @@ if (!use_hugepages_) { // Use memalign to ensure that blocks are aligned enough for disk direct IO. - buf = static_cast(memalign(4096, length)); - if (buf) + if (posix_memalign(&buf, 4096, length) == 0) logprintf(0, "Log: Using memaligned allocation at %p.\n", buf); else - logprintf(0, "Process Error: memalign returned 0\n"); + logprintf(0, "Process Error: posix_memalign failed\n"); } testmem_ = buf; Index: src/os.h =================================================================== --- src/os.h (revision 24) +++ src/os.h (working copy) @@ -74,7 +74,7 @@ // This may mean different things on different platforms. virtual int32 FindRegion(uint64 paddr); // Find cpu cores associated with a region. Either NUMA or arbitrary. - virtual cpu_set_t *FindCoreMask(int32 region); + virtual cpuset_t *FindCoreMask(int32 region); // Returns the HD device that contains this file. virtual string FindFileDevice(string filename); @@ -244,7 +244,7 @@ time_t time_initialized_; // Start time of test. - vector cpu_sets_; // Cache for cpu masks. + vector cpu_sets_; // Cache for cpu masks. vector cpu_sets_valid_; // If the cpu mask cache is valid. // Get file descriptor for dev msr. Index: src/sat.cc =================================================================== --- src/sat.cc (revision 24) +++ src/sat.cc (working copy) @@ -77,7 +77,7 @@ // Open logfile. if (use_logfile_) { logfile_ = open(logfilename_, - O_WRONLY | O_CREAT | O_DSYNC, + O_WRONLY | O_CREAT | O_SYNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (logfile_ < 0) { printf("Fatal Error: cannot open file %s for logging\n", @@ -1088,7 +1088,7 @@ if ((region_count_ > 1) && (region_mode_)) { int32 region = region_find(i % region_count_); - cpu_set_t *cpuset = os_->FindCoreMask(region); + cpuset_t *cpuset = os_->FindCoreMask(region); sat_assert(cpuset); int32 cpu_mask = cpuset_to_uint32(cpuset); if (region_mode_ == kLocalNuma) { @@ -1692,8 +1692,8 @@ sigaddset(&new_blocked_signals, SIGTERM); sigset_t prev_blocked_signals; pthread_sigmask(SIG_BLOCK, &new_blocked_signals, &prev_blocked_signals); - sighandler_t prev_sigint_handler = signal(SIGINT, SatHandleBreak); - sighandler_t prev_sigterm_handler = signal(SIGTERM, SatHandleBreak); + sig_t prev_sigint_handler = signal(SIGINT, SatHandleBreak); + sig_t prev_sigterm_handler = signal(SIGTERM, SatHandleBreak); // Kick off all the worker threads. logprintf(12, "Log: Launching worker threads\n");