add drop fs caches to tools/perfect-cli
This commit is contained in:
@@ -116,7 +116,7 @@ See [tools/sync_drop_caches.cpp](tools/sync_drop_caches.cpp)
|
|||||||
```
|
```
|
||||||
|
|
||||||
* `Result sync()`: flush filesystem caches to disk
|
* `Result sync()`: flush filesystem caches to disk
|
||||||
* `Result drop_caches(DropCaches_t mode)`: remove file system caches
|
* `Result drop_caches(DropCaches_t mode = DropCaches_t(PAGECACHE | ENTRIES))`: remove file system caches
|
||||||
* `mode = PAGECACHE`: drop page caches
|
* `mode = PAGECACHE`: drop page caches
|
||||||
* `mode = ENTRIES`: drop dentries and inodes
|
* `mode = ENTRIES`: drop dentries and inodes
|
||||||
* `mode = PAGECACHE | ENTRIES`: both
|
* `mode = PAGECACHE | ENTRIES`: both
|
||||||
|
@@ -24,7 +24,7 @@ Result sync() {
|
|||||||
return Result::SUCCESS;
|
return Result::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result drop_caches(const DropCaches_t mode) {
|
Result drop_caches(const DropCaches_t mode = DropCaches_t(PAGECACHE | ENTRIES)) {
|
||||||
using detail::write_str;
|
using detail::write_str;
|
||||||
const std::string path = "/proc/sys/vm/drop_caches";
|
const std::string path = "/proc/sys/vm/drop_caches";
|
||||||
if (mode & PAGECACHE & ENTRIES) {
|
if (mode & PAGECACHE & ENTRIES) {
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "perfect/cpu_turbo.hpp"
|
#include "perfect/cpu_turbo.hpp"
|
||||||
#include "perfect/os_perf.hpp"
|
#include "perfect/os_perf.hpp"
|
||||||
#include "perfect/detail/os/linux.hpp"
|
#include "perfect/detail/os/linux.hpp"
|
||||||
|
#include "perfect/drop_caches.hpp"
|
||||||
|
|
||||||
// argv should be null-terminated
|
// argv should be null-terminated
|
||||||
int fork_child(char *const *argv) {
|
int fork_child(char *const *argv) {
|
||||||
@@ -72,6 +73,7 @@ int main(int argc, char **argv) {
|
|||||||
bool aslr = false;
|
bool aslr = false;
|
||||||
bool cpuTurbo = false;
|
bool cpuTurbo = false;
|
||||||
bool maxOsPerf = true;
|
bool maxOsPerf = true;
|
||||||
|
bool dropCaches = true;
|
||||||
|
|
||||||
std::vector<std::string> program;
|
std::vector<std::string> program;
|
||||||
|
|
||||||
@@ -83,6 +85,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
|
|
||||||
auto cli = (shieldGroup,
|
auto cli = (shieldGroup,
|
||||||
|
option("--no-drop-cache").set(dropCaches, false).doc("do not drop filesystem caches"),
|
||||||
option("--no-max-perf").set(maxOsPerf, false).doc("do not max os perf"),
|
option("--no-max-perf").set(maxOsPerf, false).doc("do not max os perf"),
|
||||||
option("--no-aslr").set(aslr, false).doc("disable ASLR"),
|
option("--no-aslr").set(aslr, false).doc("disable ASLR"),
|
||||||
option("--no-cpu-turbo").set(cpuTurbo, false).doc("disable CPU turbo"),
|
option("--no-cpu-turbo").set(cpuTurbo, false).doc("disable CPU turbo"),
|
||||||
@@ -167,6 +170,12 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle file system caches
|
||||||
|
if (dropCaches) {
|
||||||
|
std::cerr << "clearing file system cache\n";
|
||||||
|
PERFECT(perfect::drop_caches());
|
||||||
|
}
|
||||||
|
|
||||||
// parent should return
|
// parent should return
|
||||||
std::cerr << "exec ";
|
std::cerr << "exec ";
|
||||||
for (size_t i = 0; i < args.size() - 1; ++i) {
|
for (size_t i = 0; i < args.size() - 1; ++i) {
|
||||||
|
Reference in New Issue
Block a user