hrev51883 adds 1 changeset to branch 'master'
old head: 1fb59be1d127c26e46e886b0d905b36cc6c096c1
new head: 03df8bfcf2b58bf114cf876eccdd5242448926ce
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=03df8bfcf2b5+%5E1fb59be1d127
----------------------------------------------------------------------------
03df8bfcf2b5: kernel: vm: reduce stack usage in swap_init_post_modules().
* avoid a struct copy in PartitionScorer.
* reduce stack usage in get_mount_point().
Change-Id: I60a3161ba39e9a50eaae972b7ff5b4a26d6292fa
[ Jérôme Duval <jerome.duval@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev51883
Commit: 03df8bfcf2b58bf114cf876eccdd5242448926ce
URL: https://git.haiku-os.org/haiku/commit/?id=03df8bfcf2b5
Author: Jérôme Duval <jerome.duval@xxxxxxxxx>
Date: Sat Apr 7 09:36:22 2018 UTC
Committer: Rene Gollent <rene@xxxxxxxxxxx>
Commit-Date: Wed Apr 18 12:37:02 2018 UTC
----------------------------------------------------------------------------
1 file changed, 18 insertions(+), 7 deletions(-)
src/system/kernel/vm/VMAnonymousCache.cpp | 25 ++++++++++++++++++-------
----------------------------------------------------------------------------
diff --git a/src/system/kernel/vm/VMAnonymousCache.cpp
b/src/system/kernel/vm/VMAnonymousCache.cpp
index 46c1c530c3..51c5aded1d 100644
--- a/src/system/kernel/vm/VMAnonymousCache.cpp
+++ b/src/system/kernel/vm/VMAnonymousCache.cpp
@@ -27,6 +27,7 @@
#include <FindDirectory.h>
#include <KernelExport.h>
#include <NodeMonitor.h>
+#include <StackOrHeapArray.h>
#include <arch_config.h>
#include <boot_device.h>
@@ -1238,7 +1239,7 @@ public:
private:
int32 fBestScore;
- VolumeInfo fVolumeInfo;
+ VolumeInfo& fVolumeInfo;
};
@@ -1248,14 +1249,24 @@ get_mount_point(KPartition* partition, KPath*
mountPoint)
if (!mountPoint || !partition->ContainsFileSystem())
return B_BAD_VALUE;
+ int nameLength = 0;
const char* volumeName = partition->ContentName();
- if (!volumeName || strlen(volumeName) == 0)
+ if (volumeName != NULL)
+ nameLength = strlen(volumeName);
+ if (nameLength == 0) {
volumeName = partition->Name();
- if (!volumeName || strlen(volumeName) == 0)
- volumeName = "unnamed volume";
+ if (volumeName != NULL)
+ nameLength = strlen(volumeName);
+ if (nameLength == 0) {
+ volumeName = "unnamed volume";
+ nameLength = strlen(volumeName);
+ }
+ }
- char basePath[B_PATH_NAME_LENGTH];
- int32 len = snprintf(basePath, sizeof(basePath), "/%s", volumeName);
+ BStackOrHeapArray<char, 128> basePath(nameLength + 1);
+ if (!basePath.IsValid())
+ return B_NO_MEMORY;
+ int32 len = snprintf(basePath, nameLength + 1, "/%s", volumeName);
for (int32 i = 1; i < len; i++)
if (basePath[i] == '/')
basePath[i] = '-';
@@ -1267,7 +1278,7 @@ get_mount_point(KPartition* partition, KPath* mountPoint)
for (int i = 1; ; i++) {
if (stat(path, &dummy) != 0)
break;
- snprintf(path, pathLen, "%s%d", basePath, i);
+ snprintf(path, pathLen, "%s%d", (char*)basePath, i);
}
mountPoint->UnlockBuffer();