util/HugeAllocator: add SetName()
This commit is contained in:
parent
3ae660ca90
commit
7ed67d216b
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2021 Max Kellermann <max.kellermann@gmail.com>
|
* Copyright 2013-2022 Max Kellermann <max.kellermann@gmail.com>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -28,6 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "HugeAllocator.hxx"
|
#include "HugeAllocator.hxx"
|
||||||
|
#include "system/VmaName.hxx"
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
@ -82,6 +83,12 @@ HugeFree(void *p, size_t size) noexcept
|
|||||||
munmap(p, AlignToPageSize(size));
|
munmap(p, AlignToPageSize(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
HugeSetName(void *p, size_t size, const char *name) noexcept
|
||||||
|
{
|
||||||
|
SetVmaName(p, size, name);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
HugeForkCow(void *p, size_t size, bool enable) noexcept
|
HugeForkCow(void *p, size_t size, bool enable) noexcept
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013-2019 Max Kellermann <max.kellermann@gmail.com>
|
* Copyright 2013-2022 Max Kellermann <max.kellermann@gmail.com>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -58,6 +58,14 @@ HugeAllocate(size_t size);
|
|||||||
void
|
void
|
||||||
HugeFree(void *p, size_t size) noexcept;
|
HugeFree(void *p, size_t size) noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a name for the specified virtual memory area.
|
||||||
|
*
|
||||||
|
* This feature requires Linux 5.17.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
HugeSetName(void *p, size_t size, const char *name) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Control whether this allocation is copied to newly forked child
|
* Control whether this allocation is copied to newly forked child
|
||||||
* processes. Disabling that makes forking a little bit cheaper.
|
* processes. Disabling that makes forking a little bit cheaper.
|
||||||
@ -88,6 +96,11 @@ HugeFree(void *p, size_t) noexcept
|
|||||||
VirtualFree(p, 0, MEM_RELEASE);
|
VirtualFree(p, 0, MEM_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
HugeSetName(void *, size_t, const char *) noexcept
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
HugeForkCow(void *, size_t, bool) noexcept
|
HugeForkCow(void *, size_t, bool) noexcept
|
||||||
{
|
{
|
||||||
@ -118,6 +131,11 @@ HugeFree(void *_p, size_t) noexcept
|
|||||||
delete[] p;
|
delete[] p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
HugeSetName(void *, size_t, const char *) noexcept
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
HugeForkCow(void *, size_t, bool) noexcept
|
HugeForkCow(void *, size_t, bool) noexcept
|
||||||
{
|
{
|
||||||
@ -167,6 +185,11 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetName(const char *name) noexcept {
|
||||||
|
const auto v = buffer.ToVoid();
|
||||||
|
HugeSetName(v.data, v.size, name);
|
||||||
|
}
|
||||||
|
|
||||||
void ForkCow(bool enable) noexcept {
|
void ForkCow(bool enable) noexcept {
|
||||||
auto v = buffer.ToVoid();
|
auto v = buffer.ToVoid();
|
||||||
HugeForkCow(v.data, v.size, enable);
|
HugeForkCow(v.data, v.size, enable);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2021 The Music Player Daemon Project
|
* Copyright 2003-2022 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -85,6 +85,10 @@ public:
|
|||||||
return n_allocated == buffer.size();
|
return n_allocated == buffer.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetName(const char *name) noexcept {
|
||||||
|
buffer.SetName(name);
|
||||||
|
}
|
||||||
|
|
||||||
void DiscardMemory() noexcept {
|
void DiscardMemory() noexcept {
|
||||||
assert(empty());
|
assert(empty());
|
||||||
|
|
||||||
|
@ -112,6 +112,10 @@ public:
|
|||||||
return map.size();
|
return map.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetName(const char *name) noexcept {
|
||||||
|
buffer.SetName(name);
|
||||||
|
}
|
||||||
|
|
||||||
struct ReadResult {
|
struct ReadResult {
|
||||||
size_type undefined_size;
|
size_type undefined_size;
|
||||||
ConstBuffer<T> defined_buffer;
|
ConstBuffer<T> defined_buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user