<< " raw_duplicates|"
"duplicates|"
"free_dump|"
+ "assess_free <alloc_unit>|"
"try_alloc <count> <want> <alloc_unit>|"
"replay_alloc <alloc_list_file|"
"export_binary <out_file>|"
}
return 0;
});
+ } else if (strcmp(argv[2], "assess_free") == 0) {
+ if (argc < 4) {
+ std::cerr << "Error: insufficient arguments for \"assess_free_extents\" operation."
+ << std::endl;
+ usage(argv[0]);
+ return 1;
+ }
+ auto alloc_unit = strtoul(argv[3], nullptr, 10);
+ return replay_free_dump_and_apply(argv[1],
+ [&](Allocator* a, const string& aname) {
+ ceph_assert(a);
+ std::cout << "Fragmentation:" << a->get_fragmentation()
+ << std::endl;
+ std::cout << "Fragmentation score:" << a->get_fragmentation_score()
+ << std::endl;
+ std::cout << "Free:" << std::hex << a->get_free() << std::dec
+ << std::endl;
+ {
+ uint64_t available = 0;
+ uint64_t available2 = 0;
+ a->foreach([&](uint64_t offs, uint64_t len) {
+ auto a = p2align(len, alloc_unit);
+ available += a;
+ auto a0 = p2roundup(offs, alloc_unit);
+ a = p2align(offs + len, alloc_unit);
+ if (a > a0) {
+ available2 += a - a0;
+ }
+ });
+ std::cout << "Available: 0x" << std::hex << available
+ << " Available(strict align): 0x" << available2
+ << " alloc_unit: 0x" << alloc_unit << std::dec
+ << std::endl;
+ }
+ return 0;
+ });
} else if (strcmp(argv[2], "try_alloc") == 0) {
if (argc < 6) {
std::cerr << "Error: insufficient arguments for \"try_alloc\" operation."
{
PExtentVector extents;
for(size_t i = 0; i < count; i++) {
- extents.clear();
- auto r = a->allocate(want, alloc_unit, 0, &extents);
- if (r < 0) {
- std::cerr << "Error: allocation failure at step:" << i + 1
- << ", ret = " << r << std::endl;
+ extents.clear();
+ auto r = a->allocate(want, alloc_unit, 0, &extents);
+ if (r < 0) {
+ std::cerr << "Error: allocation failure at step:" << i + 1
+ << ", ret = " << r << std::endl;
return -1;
}
+ std::cout << ">allocated: " << r << std::endl;
+
+ std::cout << "Extents:" << std::hex;
+ for (auto& e : extents) {
+ std::cout << e.offset << "~" << e.length << " ";
+ }
+ std::cout << std::dec << std::endl;
}
}
std::cout << "Successfully allocated: " << count << " * " << want