[haiku-commits] haiku: hrev53510 - in src/system/kernel: . disk_device_manager

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 21 Sep 2019 16:44:48 -0400 (EDT)

hrev53510 adds 3 changesets to branch 'master'
old head: 863eb82bcae34284e8c9e5db58925c90ceb479b4
new head: 453027c1c327ad78f6217e78e0068724c0220e42
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=453027c1c327+%5E863eb82bcae3

----------------------------------------------------------------------------

0af21102efc7: kernel: Fix compiling the debug heap on x86_64.

e6ee730269b8: kernel/disk_device_manager: Use addr_t in UserDataWriter.
  
  This code was not touched since 2005, and even then, that was just
  a file rename. So it seems it simply predates addr_t.

453027c1c327: kernel/scheduler: Add missing initializations to 
ThreadData::_InitBase().
  
  fQuantumStart and fLastInterruptTime were not set to 0 here, so they
  would default to the "malloc-cleared" data and then always overflow
  the first time the interrupt time was tracked. I can't find any
  reason that was supposed to be the behavior, so just set them to 0.
  
  Also reorder the field initializations to be the same as the class
  definition, which should allow some store merging optimizations.
  
  Spotted by KUBSAN.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 24 insertions(+), 24 deletions(-)
.../kernel/disk_device_manager/UserDataWriter.cpp  | 16 ++++++----------
src/system/kernel/heap.cpp                         | 14 +++++++-------
src/system/kernel/scheduler/scheduler_thread.cpp   | 18 +++++++++++-------

############################################################################

Commit:      0af21102efc7cd6a40eeb26a2da6e739c25818f4
URL:         https://git.haiku-os.org/haiku/commit/?id=0af21102efc7
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Sep 21 18:59:52 2019 UTC

kernel: Fix compiling the debug heap on x86_64.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/heap.cpp b/src/system/kernel/heap.cpp
index 9a6ab41571..c1aadaa136 100644
--- a/src/system/kernel/heap.cpp
+++ b/src/system/kernel/heap.cpp
@@ -601,7 +601,7 @@ dump_allocations(int argc, char **argv)
                                                        && (address == 0 || 
base == address)) {
                                                        // interesting...
                                                        if (!statsOnly) {
-                                                               kprintf("team: 
% 6ld; thread: % 6ld; "
+                                                               kprintf("team: 
% 6" B_PRId32 "; thread: % 6" B_PRId32 "; "
                                                                        
"address: 0x%08lx; size: %lu bytes; "
                                                                        
"caller: %#lx\n", info->team, info->thread,
                                                                        base, 
info->size, info->caller);
@@ -631,7 +631,7 @@ dump_allocations(int argc, char **argv)
                                                && (address == 0 || base == 
address)) {
                                                // interesting...
                                                if (!statsOnly) {
-                                                       kprintf("team: % 6ld; 
thread: % 6ld;"
+                                                       kprintf("team: % 6" 
B_PRId32 "; thread: % 6" B_PRId32 ";"
                                                                " address: 
0x%08lx; size: %lu bytes;"
                                                                " caller: 
%#lx\n", info->team, info->thread,
                                                                base, 
info->size, info->caller);
@@ -650,8 +650,8 @@ dump_allocations(int argc, char **argv)
                }
        }
 
-       kprintf("total allocations: %lu; total bytes: %lu\n", totalCount,
-               totalSize);
+       kprintf("total allocations: %" B_PRIu32 "; total bytes: %" B_PRIuSIZE 
"\n",
+               totalCount, totalSize);
        return 0;
 }
 
@@ -815,14 +815,14 @@ dump_allocations_per_caller(int argc, char **argv)
        qsort(sCallerInfoTable, sCallerInfoCount, sizeof(caller_info),
                sortBySize ? &caller_info_compare_size : 
&caller_info_compare_count);
 
-       kprintf("%ld different callers, sorted by %s...\n\n", sCallerInfoCount,
-               sortBySize ? "size" : "count");
+       kprintf("%" B_PRId32 " different callers, sorted by %s...\n\n",
+               sCallerInfoCount, sortBySize ? "size" : "count");
 
        kprintf("     count        size      caller\n");
        kprintf("----------------------------------\n");
        for (int32 i = 0; i < sCallerInfoCount; i++) {
                caller_info& info = sCallerInfoTable[i];
-               kprintf("%10ld  %10ld  %#08lx", info.count, info.size, 
info.caller);
+               kprintf("%10" B_PRId32 "  %10" B_PRId32 "  %#08lx", info.count, 
info.size, info.caller);
 
                const char *symbol;
                const char *imageName;

############################################################################

Commit:      e6ee730269b80084f147ee2082c3e7f8be5998ef
URL:         https://git.haiku-os.org/haiku/commit/?id=e6ee730269b8
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Sep 21 20:13:51 2019 UTC

kernel/disk_device_manager: Use addr_t in UserDataWriter.

This code was not touched since 2005, and even then, that was just
a file rename. So it seems it simply predates addr_t.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/disk_device_manager/UserDataWriter.cpp 
b/src/system/kernel/disk_device_manager/UserDataWriter.cpp
index 9dd757ea45..4b76ffd758 100644
--- a/src/system/kernel/disk_device_manager/UserDataWriter.cpp
+++ b/src/system/kernel/disk_device_manager/UserDataWriter.cpp
@@ -6,12 +6,8 @@
 
 #include "UserDataWriter.h"
 
-using namespace std;
-
-typedef uint8  *addr;
-
 // RelocationEntryList
-struct UserDataWriter::RelocationEntryList : Vector<addr*> {};
+struct UserDataWriter::RelocationEntryList : Vector<addr_t*> {};
 
 // constructor
 UserDataWriter::UserDataWriter()
@@ -128,9 +124,9 @@ UserDataWriter::AllocatedSize() const
 status_t
 UserDataWriter::AddRelocationEntry(void *address)
 {
-       if (fRelocationEntries && (addr)address >= (addr)fBuffer
-               && (addr)address < (addr)fBuffer + fBufferSize - sizeof(void*)) 
{
-               return fRelocationEntries->PushBack((addr*)address);
+       if (fRelocationEntries && (addr_t)address >= (addr_t)fBuffer
+               && (addr_t)address < (addr_t)fBuffer + fBufferSize - 
sizeof(void*)) {
+               return fRelocationEntries->PushBack((addr_t*)address);
        }
        return B_ERROR;
 }
@@ -143,9 +139,9 @@ UserDataWriter::Relocate(void *address)
                return B_BAD_VALUE;
        int32 count = fRelocationEntries->Count();
        for (int32 i = 0; i < count; i++) {
-               addr *entry = fRelocationEntries->ElementAt(i);
+               addr_t *entry = fRelocationEntries->ElementAt(i);
                if (*entry)
-                       *entry += (addr)address - (addr)fBuffer;
+                       *entry += (addr_t)address - (addr_t)fBuffer;
        }
        return B_OK;
 }

############################################################################

Revision:    hrev53510
Commit:      453027c1c327ad78f6217e78e0068724c0220e42
URL:         https://git.haiku-os.org/haiku/commit/?id=453027c1c327
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Sep 21 20:30:43 2019 UTC

kernel/scheduler: Add missing initializations to ThreadData::_InitBase().

fQuantumStart and fLastInterruptTime were not set to 0 here, so they
would default to the "malloc-cleared" data and then always overflow
the first time the interrupt time was tracked. I can't find any
reason that was supposed to be the behavior, so just set them to 0.

Also reorder the field initializations to be the same as the class
definition, which should allow some store merging optimizations.

Spotted by KUBSAN.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/scheduler/scheduler_thread.cpp 
b/src/system/kernel/scheduler/scheduler_thread.cpp
index af21c84a7e..bd525013a2 100644
--- a/src/system/kernel/scheduler/scheduler_thread.cpp
+++ b/src/system/kernel/scheduler/scheduler_thread.cpp
@@ -18,23 +18,27 @@ static bigtime_t 
sMaximumQuantumLengths[kMaximumQuantumLengthsCount];
 void
 ThreadData::_InitBase()
 {
+       fStolenTime = 0;
+       fQuantumStart = 0;
+       fLastInterruptTime = 0;
+
+       fWentSleep = 0;
+       fWentSleepActive = 0;
+
+       fEnqueued = false;
+       fReady = false;
+
        fPriorityPenalty = 0;
        fAdditionalPenalty = 0;
+
        fEffectivePriority = GetPriority();
        fBaseQuantum = sQuantumLengths[GetEffectivePriority()];
 
        fTimeUsed = 0;
-       fStolenTime = 0;
 
        fMeasureAvailableActiveTime = 0;
        fLastMeasureAvailableTime = 0;
        fMeasureAvailableTime = 0;
-
-       fWentSleep = 0;
-       fWentSleepActive = 0;
-
-       fEnqueued = false;
-       fReady = false;
 }
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev53510 - in src/system/kernel: . disk_device_manager - waddlesplash