107 lines
4.4 KiB
Diff
107 lines
4.4 KiB
Diff
musl does not implement mallinfo()/mallinfo2()
|
|
(or rather, malloc-ng, musl's allocator, doesn't)
|
|
|
|
for some reason only outside of x86_64 HAVE_MALLINFO gets weirdly set by something
|
|
--
|
|
--- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
|
|
+++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
|
|
@@ -646,7 +645,7 @@ SHIM_ALWAYS_EXPORT int mallopt(int cmd, int value) __THROW {
|
|
|
|
#endif // !PA_BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(IS_ANDROID)
|
|
|
|
-#if PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS)
|
|
+#if 0
|
|
SHIM_ALWAYS_EXPORT struct mallinfo mallinfo(void) __THROW {
|
|
partition_alloc::SimplePartitionStatsDumper allocator_dumper;
|
|
Allocator()->DumpStats("malloc", true, &allocator_dumper);
|
|
--- a/base/process/process_metrics_posix.cc
|
|
+++ b/base/process/process_metrics_posix.cc
|
|
@@ -106,7 +107,8 @@ void IncreaseFdLimitTo(unsigned int max_descriptors) {
|
|
|
|
#endif // !BUILDFLAG(IS_FUCHSIA)
|
|
|
|
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
|
|
+#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || \
|
|
+ BUILDFLAG(IS_ANDROID)
|
|
namespace {
|
|
|
|
size_t GetMallocUsageMallinfo() {
|
|
@@ -132,7 +134,8 @@ size_t ProcessMetrics::GetMallocUsage() {
|
|
malloc_statistics_t stats = {0};
|
|
malloc_zone_statistics(nullptr, &stats);
|
|
return stats.size_in_use;
|
|
-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
|
|
+#elif (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || \
|
|
+ BUILDFLAG(IS_ANDROID)
|
|
return GetMallocUsageMallinfo();
|
|
#elif BUILDFLAG(IS_FUCHSIA)
|
|
// TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
|
|
diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc
|
|
index e37fc69c00..394f5dfdbb 100644
|
|
--- a/base/trace_event/malloc_dump_provider.cc
|
|
+++ b/base/trace_event/malloc_dump_provider.cc
|
|
@@ -189,7 +188,6 @@ void ReportMallinfoStats(ProcessMemoryDump* pmd,
|
|
#define MALLINFO2_FOUND_IN_LIBC
|
|
struct mallinfo2 info = mallinfo2();
|
|
#endif
|
|
-#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
|
#if !defined(MALLINFO2_FOUND_IN_LIBC)
|
|
struct mallinfo info = mallinfo();
|
|
#endif
|
|
@@ -211,6 +209,7 @@ void ReportMallinfoStats(ProcessMemoryDump* pmd,
|
|
MemoryAllocatorDump::kUnitsBytes,
|
|
total_allocated_size);
|
|
}
|
|
+#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
|
}
|
|
#endif
|
|
|
|
@@ -368,7 +367,7 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
|
|
&allocated_objects_count);
|
|
#elif BUILDFLAG(IS_FUCHSIA)
|
|
// TODO(fuchsia): Port, see https://crbug.com/706592.
|
|
-#else
|
|
+#elif defined(__GLIBC__)
|
|
ReportMallinfoStats(/*pmd=*/nullptr, &total_virtual_size, &resident_size,
|
|
&allocated_objects_size, &allocated_objects_count);
|
|
#endif
|
|
diff --git a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
|
|
index 9a4428ec45..07defd5ded 100644
|
|
--- a/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
|
|
+++ b/third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
|
|
@@ -43,7 +43,7 @@ MemoryUsage GetMemoryUsage() {
|
|
if (getrusage(RUSAGE_SELF, &res) == 0) {
|
|
result.mem_footprint_kb = res.ru_maxrss;
|
|
}
|
|
-#if defined(__NO_MALLINFO__)
|
|
+#if 1
|
|
result.total_allocated_bytes = -1;
|
|
result.in_use_allocated_bytes = -1;
|
|
#elif defined(__GLIBC__) && __GLIBC_MINOR__ >= 33
|
|
--- a/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
|
|
+++ b/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
|
|
@@ -133,7 +133,6 @@
|
|
/* #undef HAVE_MALLCTL */
|
|
|
|
/* Define to 1 if you have the `mallinfo' function. */
|
|
-#define HAVE_MALLINFO 1
|
|
|
|
/* Some projects using SwiftShader bypass cmake (eg Chromium via gn) */
|
|
/* so we need to check glibc version for the new API to be safe */
|
|
--- a/third_party/swiftshader/third_party/llvm-10.0/llvm/lib/Support/Unix/Process.inc
|
|
+++ b/third_party/swiftshader/third_party/llvm-10.0/llvm/lib/Support/Unix/Process.inc
|
|
@@ -83,11 +83,11 @@ Expected<unsigned> Process::getPageSize() {
|
|
}
|
|
|
|
size_t Process::GetMallocUsage() {
|
|
-#if defined(HAVE_MALLINFO2)
|
|
+#if 0
|
|
struct mallinfo2 mi;
|
|
mi = ::mallinfo2();
|
|
return mi.uordblks;
|
|
-#elif defined(HAVE_MALLINFO)
|
|
+#elif 0
|
|
struct mallinfo mi;
|
|
mi = ::mallinfo();
|
|
return mi.uordblks;
|