From b4c2ce302942068ceb3bf480e08601b2ab25154c Mon Sep 17 00:00:00 2001 From: "nick.j.sanders" Date: Tue, 27 Oct 2009 05:56:42 +0000 Subject: [PATCH] Update to stressapptest 1.0.1. Fix non-x86 build. Fix lock initialization. Standardize on posix_memalign. Do not require -A. Add STRESSAPPTEST_OS_BSD config for future BSD support. Improved read error/data corruption handling. --- configure | 134 ++++++++++++++++++++++++++++------ configure.ac | 42 ++++++++++- src/finelock_queue.cc | 11 ++- src/os.cc | 26 +++++-- src/os.h | 36 +++++---- src/sattypes.h | 2 + src/stressapptest_config.h.in | 9 +++ src/worker.cc | 75 +++++++++++-------- 8 files changed, 257 insertions(+), 78 deletions(-) diff --git a/configure b/configure index 1dcc6f3..1619c7c 100755 --- a/configure +++ b/configure @@ -1,8 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for stressapptest 1.0.0_autoconf. +# Generated by GNU Autoconf 2.61 for stressapptest 1.0.1_autoconf. # -# Report bugs to . +# Report bugs to . # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -574,9 +574,9 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='stressapptest' PACKAGE_TARNAME='stressapptest' -PACKAGE_VERSION='1.0.0_autoconf' -PACKAGE_STRING='stressapptest 1.0.0_autoconf' -PACKAGE_BUGREPORT='opensource@gmail.com' +PACKAGE_VERSION='1.0.1_autoconf' +PACKAGE_STRING='stressapptest 1.0.1_autoconf' +PACKAGE_BUGREPORT='opensource@google.com' ac_unique_file="src/" # Factoring default headers for most tests. @@ -1228,7 +1228,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures stressapptest 1.0.0_autoconf to adapt to many kinds of systems. +\`configure' configures stressapptest 1.0.1_autoconf to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1299,7 +1299,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of stressapptest 1.0.0_autoconf:";; + short | recursive ) echo "Configuration of stressapptest 1.0.1_autoconf:";; esac cat <<\_ACEOF @@ -1324,7 +1324,7 @@ Some influential environment variables: Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to . +Report bugs to . _ACEOF ac_status=$? fi @@ -1385,7 +1385,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -stressapptest configure 1.0.0_autoconf +stressapptest configure 1.0.1_autoconf generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1399,7 +1399,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by stressapptest $as_me 1.0.0_autoconf, which was +It was created by stressapptest $as_me 1.0.1_autoconf, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -1753,8 +1753,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -# Checking for target cpu and setting custom configuration -# for the different platforms ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then @@ -1869,6 +1867,54 @@ IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} + { (exit 1); exit 1; }; } + +{ echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6; } +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +# Checking for target cpu and setting custom configuration +# for the different platforms { echo "$as_me:$LINENO: checking target system type" >&5 echo $ECHO_N "checking target system type... $ECHO_C" >&6; } if test "${ac_cv_target+set}" = set; then @@ -1936,6 +1982,49 @@ _ACEOF ;; esac +_os=`uname` +## The following allows like systems to share settings. This is not meant to +## imply that these OS are the same thing. From OpenOffice dmake configure.in +case "$_os" in + "Linux") + OS_VERSION=linux + +cat >>confdefs.h <<\_ACEOF +#define STRESSAPPTEST_OS_LINUX +_ACEOF + + ;; + "Darwin") + OS_VERSION=macosx + +cat >>confdefs.h <<\_ACEOF +#define STRESSAPPTEST_OS_DARWIN +_ACEOF + + ;; + "FreeBSD") + OS_VERSION=bsd + +cat >>confdefs.h <<\_ACEOF +#define STRESSAPPTEST_OS_BSD +_ACEOF + + ;; + "NetBSD") + OS_VERSION=bsd + +cat >>confdefs.h <<\_ACEOF +#define STRESSAPPTEST_OS_BSD +_ACEOF + + ;; + *) + { { echo "$as_me:$LINENO: error: $_os operating system is not suitable to build dmake!" >&5 +echo "$as_me: error: $_os operating system is not suitable to build dmake!" >&2;} + { (exit 1); exit 1; }; } + ;; +esac + am__api_version='1.10' # Find a good install program. We prefer a C program (faster), @@ -2242,7 +2331,7 @@ fi # Define the identity of the package. PACKAGE='stressapptest' - VERSION='1.0.0_autoconf' + VERSION='1.0.1_autoconf' cat >>confdefs.h <<_ACEOF @@ -2393,6 +2482,9 @@ ac_config_headers="$ac_config_headers src/stressapptest_config.h" # Checks for programs. +# Don't generate CXXFLAGS defaults: if CXXFLAGS are unset +# AC_PROG_CXX will override them with unwanted defaults. +CXXFLAGS="$CXXFLAGS" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4991,9 +5083,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >& { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ----------------------------------- ## -## Report this to opensource@gmail.com ## -## ----------------------------------- ## +## ------------------------------------ ## +## Report this to opensource@google.com ## +## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; @@ -6140,9 +6232,9 @@ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >& { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX -## ----------------------------------- ## -## Report this to opensource@gmail.com ## -## ----------------------------------- ## +## ------------------------------------ ## +## Report this to opensource@google.com ## +## ------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; @@ -7304,7 +7396,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by stressapptest $as_me 1.0.0_autoconf, which was +This file was extended by stressapptest $as_me 1.0.1_autoconf, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7357,7 +7449,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -stressapptest config.status 1.0.0_autoconf +stressapptest config.status 1.0.1_autoconf configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index 026fa07..a7bdb86 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,8 @@ AC_PREREQ(2.61) -AC_INIT(stressapptest, 1.0.0_autoconf, opensource@gmail.com) +AC_INIT(stressapptest, 1.0.1_autoconf, opensource@google.com) +AC_CANONICAL_HOST +AC_CANONICAL_BUILD # Checking for target cpu and setting custom configuration # for the different platforms AC_CANONICAL_TARGET @@ -19,11 +21,43 @@ case x"$target_cpu" in ;; esac +_os=`uname` +## The following allows like systems to share settings. This is not meant to +## imply that these OS are the same thing. From OpenOffice dmake configure.in +case "$_os" in + "Linux") + OS_VERSION=linux + AC_DEFINE([STRESSAPPTEST_OS_LINUX],[], + [Defined if the target OS is Linux]) + ;; + "Darwin") + OS_VERSION=macosx + AC_DEFINE([STRESSAPPTEST_OS_DARWIN],[], + [Defined if the target OS is OSX]) + ;; + "FreeBSD") + OS_VERSION=bsd + AC_DEFINE([STRESSAPPTEST_OS_BSD],[], + [Defined if the target OS is BSD based]) + ;; + "NetBSD") + OS_VERSION=bsd + AC_DEFINE([STRESSAPPTEST_OS_BSD],[], + [Defined if the target OS is BSD based]) + ;; + *) + AC_MSG_ERROR([$_os operating system is not suitable to build dmake!]) + ;; +esac + AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_CONFIG_SRCDIR([src/]) AC_CONFIG_HEADER([src/stressapptest_config.h]) # Checks for programs. +# Don't generate CXXFLAGS defaults: if CXXFLAGS are unset +# AC_PROG_CXX will override them with unwanted defaults. +CXXFLAGS="$CXXFLAGS" AC_PROG_CXX AC_PROG_CC @@ -41,7 +75,7 @@ AC_MSG_CHECKING([current timestamp]) AC_MSG_RESULT([$timestamp]) AC_DEFINE_UNQUOTED([STRESSAPPTEST_TIMESTAMP], - "$username @ $hostname on $timestamp", + "$username @ $hostname on $timestamp", [Timestamp when ./configure was executed]) #Default cxxflags @@ -72,7 +106,7 @@ AC_MSG_CHECKING([which argument is required to compile pthreads]) pthread_header="#include" pthread_body="pthread_create(0,0,0,0)" # Check if compile with no extra argument -AC_LINK_IFELSE([AC_LANG_PROGRAM($pthread_header, $pthread_body)], +AC_LINK_IFELSE([AC_LANG_PROGRAM($pthread_header, $pthread_body)], pthread_arg="") if test x"$pthread_arg" = x"not_available"; then @@ -81,7 +115,7 @@ if test x"$pthread_arg" = x"not_available"; then bkp_LDFLAGS="$LDFLAGS" for altheader in -pthread; do LDFLAGS="$bkp_LDFLAGS $altheader" - AC_LINK_IFELSE([AC_LANG_PROGRAM($pthread_header, $pthread_body)], + AC_LINK_IFELSE([AC_LANG_PROGRAM($pthread_header, $pthread_body)], pthread_arg="$altheader") LDFLAGS="$bkp_LDFLAGS" done diff --git a/src/finelock_queue.cc b/src/finelock_queue.cc index 27cc37d..569903a 100644 --- a/src/finelock_queue.cc +++ b/src/finelock_queue.cc @@ -45,8 +45,15 @@ FineLockPEQueue::FineLockPEQueue( queue_metric_ = kTouch; { // Init all the page locks. - for (int64 i = 0; i < q_size_; i++) - pthread_mutex_init(&(pagelocks_[i]), NULL); + for (int64 i = 0; i < q_size_; i++) { + pthread_mutex_init(&(pagelocks_[i]), NULL); + // Pages start out owned (locked) by Sat::InitializePages. + // A locked state indicates that the page state is unknown, + // and the lock should not be aquired. As InitializePages creates + // the page records, they will be inserted and unlocked, at which point + // they are ready to be aquired and filled by worker threads. + sat_assert(pthread_mutex_lock(&(pagelocks_[i])) == 0); + } } { // Init the random number generator. diff --git a/src/os.cc b/src/os.cc index 5c8c8e0..89947b7 100644 --- a/src/os.cc +++ b/src/os.cc @@ -1,10 +1,19 @@ // Copyright 2006 Google Inc. All Rights Reserved. -// Author: nsanders -// -// os.cc : os and machine specific implementation -// Copyright 2006 Google Inc. -// for open source release under GPL +// Author: nsanders, menderico + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 + +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// os.cc : os and machine specific implementation // This file includes an abstracted interface // for linux-distro specific and HW specific // interfaces. @@ -85,8 +94,13 @@ bool OsLayer::Initialize() { // Machine type detected. Can we implement all these functions correctly? bool OsLayer::IsSupported() { + if (kOpenSource) { + // There are no explicitly supported systems in open source version. + return true; + } + // This is the default empty implementation. - // SAT won't really run correctly. + // SAT won't report full error information. return false; } diff --git a/src/os.h b/src/os.h index 6ace58c..5faa84d 100644 --- a/src/os.h +++ b/src/os.h @@ -104,7 +104,7 @@ class OsLayer { inline static void FastFlush(void *vaddr) { #ifdef STRESSAPPTEST_CPU_PPC asm volatile("dcbf 0,%0; sync" : : "r" (vaddr)); -#else +#elif defined(STRESSAPPTEST_CPU_X86_64) || defined(STRESSAPPTEST_CPU_I686) // Put mfence before and after clflush to make sure: // 1. The write before the clflush is committed to memory bus; // 2. The read after the clflush is hitting the memory bus. @@ -117,6 +117,8 @@ class OsLayer { asm volatile("mfence"); asm volatile("clflush (%0)" :: "r" (vaddr)); asm volatile("mfence"); +#else + #warning "Unsupported CPU type: Unable to force cache flushes." #endif } @@ -125,24 +127,26 @@ class OsLayer { inline static uint64 GetTimestamp(void) { uint64 tsc; #ifdef STRESSAPPTEST_CPU_PPC - uint32 tbl, tbu, temp; - __asm __volatile( - "1:\n" - "mftbu %2\n" - "mftb %0\n" - "mftbu %1\n" - "cmpw %2,%1\n" - "bne 1b\n" - : "=r"(tbl), "=r"(tbu), "=r"(temp) - : - : "cc"); - - tsc = (static_cast(tbu) << 32) | static_cast(tbl); -#else + uint32 tbl, tbu, temp; + __asm __volatile( + "1:\n" + "mftbu %2\n" + "mftb %0\n" + "mftbu %1\n" + "cmpw %2,%1\n" + "bne 1b\n" + : "=r"(tbl), "=r"(tbu), "=r"(temp) + : + : "cc"); + + tsc = (static_cast(tbu) << 32) | static_cast(tbl); +#elif defined(STRESSAPPTEST_CPU_X86_64) || defined(STRESSAPPTEST_CPU_I686) datacast_t data; __asm __volatile("rdtsc" : "=a" (data.l32.l), "=d"(data.l32.h)); tsc = data.l64; - +#else + #warning "Unsupported CPU type: your build may not function correctly" + tsc = 0; #endif return (tsc); } diff --git a/src/sattypes.h b/src/sattypes.h index 2a58862..47fa79f 100644 --- a/src/sattypes.h +++ b/src/sattypes.h @@ -51,7 +51,9 @@ inline const char* BuildChangelist() { return "open source release"; } +static const bool kOpenSource = true; #else +static const bool kOpenSource = false; #include "googlesattypes.h" #endif // Workaround to allow 32/64 bit conversion diff --git a/src/stressapptest_config.h.in b/src/stressapptest_config.h.in index efb8b2c..7680a29 100644 --- a/src/stressapptest_config.h.in +++ b/src/stressapptest_config.h.in @@ -151,6 +151,15 @@ /* Defined if the target CPU is x86_64 */ #undef STRESSAPPTEST_CPU_X86_64 +/* Defined if the target OS is BSD based */ +#undef STRESSAPPTEST_OS_BSD + +/* Defined if the target OS is OSX */ +#undef STRESSAPPTEST_OS_DARWIN + +/* Defined if the target OS is Linux */ +#undef STRESSAPPTEST_OS_LINUX + /* Timestamp when ./configure was executed */ #undef STRESSAPPTEST_TIMESTAMP diff --git a/src/worker.cc b/src/worker.cc index 6a00db2..39322d2 100644 --- a/src/worker.cc +++ b/src/worker.cc @@ -16,7 +16,6 @@ // stress the system #include -#include #include #include #include @@ -40,6 +39,7 @@ #include #include #include // for gettid + // For size of block device #include #include @@ -64,7 +64,7 @@ // Syscalls // Why ubuntu, do you hate gettid so bad? #if !defined(__NR_gettid) -# define __NR_gettid 224 + #define __NR_gettid 224 #endif #define gettid() syscall(__NR_gettid) @@ -100,10 +100,11 @@ namespace { // Get HW core ID from cpuid instruction. inline int apicid(void) { int cpu; -#ifdef STRESSAPPTEST_CPU_PPC - cpu = 0; -#else +#if defined(STRESSAPPTEST_CPU_X86_64) || defined(STRESSAPPTEST_CPU_I686) __asm __volatile("cpuid" : "=b" (cpu) : "a" (1) : "cx", "dx"); +#else + #warning "Unsupported CPU type: unable to determine core ID." + cpu = 0; #endif return (cpu >> 24); } @@ -268,6 +269,7 @@ FileThread::FileThread() { pass_ = 0; page_io_ = true; crc_page_ = -1; + local_page_ = NULL; } // If file thread used bounce buffer in memory, account for the extra @@ -611,7 +613,7 @@ void WorkerThread::ProcessError(struct ErrorRecord *error, (error->vaddr), 1); logprintf(priority, - "%s: miscompare on CPU %d(%x) at %p(0x%llx:%s): " + "%s: miscompare on CPU %d(0x%x) at %p(0x%llx:%s): " "read:0x%016llx, reread:0x%016llx expected:0x%016llx\n", message, apic_id, @@ -975,13 +977,13 @@ void WorkerThread::ProcessTagError(struct ErrorRecord *error, // Report parseable error. if (priority < 5) { logprintf(priority, - "%s: Tag from %p(0x%llx:%s) (%s) miscompare on CPU %d(%x) at " - "%p(0x%llx:%s): " + "%s: Tag from %p(0x%llx:%s) (%s) " + "miscompare on CPU %d(0x%x) at %p(0x%llx:%s): " "read:0x%016llx, reread:0x%016llx expected:0x%016llx\n", message, error->tagvaddr, error->tagpaddr, tag_dimm_string, - read_error?"read error":"write error", + read_error ? "read error" : "write error", apic_id, cpumask, error->vaddr, @@ -1199,10 +1201,19 @@ int WorkerThread::CrcCopyPage(struct page_entry *dstpe, blocksize, currentblock * blocksize, 0); if (errorcount == 0) { - logprintf(0, "Process Error: CrcCopyPage CRC mismatch %s != %s, " + int apic_id = apicid(); + uint32 cpumask = CurrentCpus(); + logprintf(0, "Process Error: CPU %d(0x%x) CrcCopyPage " + "CRC mismatch %s != %s, " "but no miscompares found on second pass.\n", + apic_id, cpumask, crc.ToHexString().c_str(), expectedcrc->ToHexString().c_str()); + struct ErrorRecord er; + er.actual = sourcemem[0]; + er.expected = 0x0; + er.vaddr = sourcemem; + ProcessError(&er, 0, "Hardware Error"); } } } @@ -1486,8 +1497,6 @@ int CopyThread::Work() { return 1; } - - // Memory invert work loop. Execute until marked done. int InvertThread::Work() { struct page_entry src; @@ -1749,8 +1758,6 @@ bool FileThread::SectorValidatePage(const struct PageRec &page, return true; } - - // Get memory for an incoming data transfer.. bool FileThread::PagePrepare() { // We can only do direct IO to SAT pages if it is normal mem. @@ -1758,9 +1765,11 @@ bool FileThread::PagePrepare() { // Init a local buffer if we need it. if (!page_io_) { - local_page_ = static_cast(memalign(512, sat_->page_length())); - if (!local_page_) { - logprintf(0, "Process Error: disk thread memalign returned 0\n"); + int result = posix_memalign(&local_page_, 512, sat_->page_length()); + if (result) { + logprintf(0, "Process Error: disk thread posix_memalign " + "returned %d (fail)\n", + result); status_ += 1; return false; } @@ -2311,14 +2320,16 @@ int NetworkSlaveThread::Work() { return 0; // Loop until done. - int result = 1; int64 loops = 0; // Init a local buffer for storing data. - void *local_page = static_cast(memalign(512, sat_->page_length())); - if (!local_page) { - logprintf(0, "Process Error: Net Slave thread memalign returned 0\n"); + void *local_page = NULL; + int result = posix_memalign(&local_page, 512, sat_->page_length()); + if (result) { + logprintf(0, "Process Error: net slave posix_memalign " + "returned %d (fail)\n", + result); status_ += 1; - return 0; + return false; } struct page_entry page; @@ -2339,7 +2350,8 @@ int NetworkSlaveThread::Work() { } pages_copied_ = loops; - status_ = result; + // No results provided from this type of thread. + status_ = 1; // Clean up. CloseSocket(sock); @@ -2348,7 +2360,7 @@ int NetworkSlaveThread::Work() { "Log: Completed %d: network slave thread status %d, " "%d pages copied\n", thread_num_, status_, pages_copied_); - return result; + return status_; } // Thread work loop. Execute until marked finished. @@ -2475,6 +2487,8 @@ DiskThread::DiskThread(DiskBlockTable *block_table) { aio_ctx_ = 0; block_table_ = block_table; update_block_table_ = 1; + + block_buffer_ = NULL; } DiskThread::~DiskThread() { @@ -3027,13 +3041,16 @@ int DiskThread::Work() { // Allocate a block buffer aligned to 512 bytes since the kernel requires it // when using direst IO. - block_buffer_ = memalign(kBufferAlignment, write_block_size_); - if (block_buffer_ == NULL) { + + int result = posix_memalign(&block_buffer_, kBufferAlignment, + sat_->page_length()); + if (result) { CloseDevice(fd); logprintf(0, "Process Error: Unable to allocate memory for buffers " - "for disk %s (thread %d).\n", - device_name_.c_str(), thread_num_); - return 0; + "for disk %s (thread %d) posix memalign returned %d.\n", + device_name_.c_str(), thread_num_, result); + status_ += 1; + return false; } if (io_setup(5, &aio_ctx_)) { -- 2.30.2