ipcs: fallback for overflow

The previous commit 7a08784ab0 reduced
number of situation when we need fallback when kbytes calculated for
shmall pages, but there is still possible to see overflows.

This patch add fallback also for kbytes.

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2021-01-18 16:04:18 +01:00
parent a992cc0d98
commit c52d16098c
1 changed files with 5 additions and 3 deletions

View File

@ -217,9 +217,11 @@ static void do_shm (char format, int unit)
_("max seg size"), lim.shmmax, "\n", 0);
if (unit == IPC_UNIT_KB || unit == IPC_UNIT_DEFAULT) {
ipc_print_size(IPC_UNIT_DEFAULT,
_("max total shared memory (kbytes)"), (pgsz / 1024) *
(uint64_t) lim.shmall, "\n", 0);
tmp = (uint64_t) lim.shmall * (pgsz / 1024);
if (lim.shmall != 0 && tmp / lim.shmall != pgsz / 1024)
tmp = UINT64_MAX - (UINT64_MAX % (pgsz / 1024));
ipc_print_size(IPC_UNIT_DEFAULT, _("max total shared memory (kbytes)"), tmp, "\n", 0);
}
else {
tmp = (uint64_t) lim.shmall * pgsz;