core: resource: use cgroup/memory to calculate available memory
core: resource: use cgroup/memory to calculate available memory

Available memory calculation was done using hwloc, which when run inside
a container returns its host total memory. This patch adds cgroup usage
to determine the amount of available memory inside a container.

When memory is unlimited or Seastar is run on the host, cgroup defaults
memory.limit_in_bytes to PAGE_COUNTER_MAX, which represents ~9223 Petabytes
in 64bit systems. Since hwloc is, at most, host's memory, the minimum
between hwloc and memory.limit_in_bytes will be hwloc itself when container
memory is unlimited (or host) and memory.limit_in_bytes otherwise.

Therefore, this patch fixes memory allocation inside containers by using
std::min(hwloc, memory.limit_in_bytes) instead of hwloc solely.

Signed-off-by: Juliana Oliveira <81427a8ca2346669e614430cc07dc2b14fa0adec@scylladb.com>

scylladb/seastar,avikivity/seastar,dreamsxin/seastar,dreamsxin/seastar,scylladb/seastar,cloudius-systems/seastar,avikivity/seastar,syuu1228/seastar,syuu1228/seastar,avikivity/seastar,cloudius-systems/seastar,cloudius-systems/seastar,scylladb/seastar,dreamsxin/seastar,syuu1228/seastar