Replace format_bytes_cgroup_protection with FORMAT_BYTES_CGROUP_PROTECTION

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-07-06 10:22:03 +02:00
parent 46e23f9a8d
commit 9ca7e3d00d
3 changed files with 5 additions and 14 deletions

View file

@ -86,10 +86,4 @@ static inline char *format_bytes(char *buf, size_t l, uint64_t t) {
#define FORMAT_BYTES(t) format_bytes((char[FORMAT_BYTES_MAX]){}, FORMAT_BYTES_MAX, t)
#define FORMAT_BYTES_FULL(t, flag) format_bytes_full((char[FORMAT_BYTES_MAX]){}, FORMAT_BYTES_MAX, t, flag)
static inline char *format_bytes_cgroup_protection(char *buf, size_t l, uint64_t t) {
if (t == CGROUP_LIMIT_MAX) {
(void) snprintf(buf, l, "%s", "infinity");
return buf;
}
return format_bytes(buf, l, t);
}
#define FORMAT_BYTES_CGROUP_PROTECTION(t) (t == CGROUP_LIMIT_MAX ? "infinity" : FORMAT_BYTES(t))

View file

@ -521,8 +521,6 @@ void oomd_dump_swap_cgroup_context(const OomdCGroupContext *ctx, FILE *f, const
}
void oomd_dump_memory_pressure_cgroup_context(const OomdCGroupContext *ctx, FILE *f, const char *prefix) {
char mem_min[FORMAT_BYTES_MAX], mem_low[FORMAT_BYTES_MAX];
assert(ctx);
assert(f);
@ -546,8 +544,8 @@ void oomd_dump_memory_pressure_cgroup_context(const OomdCGroupContext *ctx, FILE
"%s\tMemory Low: %s\n"
"%s\tPgscan: %" PRIu64 "\n"
"%s\tLast Pgscan: %" PRIu64 "\n",
strempty(prefix), format_bytes_cgroup_protection(mem_min, sizeof(mem_min), ctx->memory_min),
strempty(prefix), format_bytes_cgroup_protection(mem_low, sizeof(mem_low), ctx->memory_low),
strempty(prefix), FORMAT_BYTES_CGROUP_PROTECTION(ctx->memory_min),
strempty(prefix), FORMAT_BYTES_CGROUP_PROTECTION(ctx->memory_low),
strempty(prefix), ctx->pgscan,
strempty(prefix), ctx->last_pgscan);
}

View file

@ -671,16 +671,15 @@ static void print_status_info(
i->memory_swap_max != CGROUP_LIMIT_MAX ||
i->memory_available != CGROUP_LIMIT_MAX ||
i->memory_limit != CGROUP_LIMIT_MAX) {
char buf[FORMAT_BYTES_MAX];
const char *prefix = "";
printf(" (");
if (i->memory_min > 0) {
printf("%smin: %s", prefix, format_bytes_cgroup_protection(buf, sizeof(buf), i->memory_min));
printf("%smin: %s", prefix, FORMAT_BYTES_CGROUP_PROTECTION(i->memory_min));
prefix = " ";
}
if (i->memory_low > 0) {
printf("%slow: %s", prefix, format_bytes_cgroup_protection(buf, sizeof(buf), i->memory_low));
printf("%slow: %s", prefix, FORMAT_BYTES_CGROUP_PROTECTION(i->memory_low));
prefix = " ";
}
if (i->memory_high != CGROUP_LIMIT_MAX) {