linuxdockernamespacescgroups

Why CGroups file memory.limit_in_bytes use 9223372036854771712 as a default value?


Docker cgroup file memory.limit_in_bytes use 9223372036854771712 instead of uint64 max as a default value ?

uint64 max = 9223372036854775807.

ahojliu@ubuntu:/sys/fs/cgroup/memory/docker/210401ffb15b18832b6a104d8aebac98cd29ff20fe0bc779f4ddfe04923faf46$ cat memory.limit_in_bytes
9223372036854771712

Ubuntu 20.04

Linux kernel version:

Linux version 5.11.0-41-generic (buildd@lgw01-amd64-005) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #45~20.04.1-Ubuntu SMP Wed Nov 10 10:20:10 UTC 2021

Docker version:

Client: Docker Engine - Community
 Version:           20.10.11
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        dea9396
 Built:             Thu Nov 18 00:37:06 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.11
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       847da18
  Built:            Thu Nov 18 00:35:15 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Solution

  • seems the default value of cgroup memory is set to PAGE_COUNTER_MAX,which is LONG_MAX/PAGE_SIZE on 64-bit platform.when the paltform`s PAGE_SIZE is diferent ,the default value of cgroup memory is diferent, such as 4k and 64k has the different default values: 0x7ffffffffffff000(pagesize=4k) 0x7fffffffffff0000(pagesize= 64k) reflink:

    1. https://tracker.ceph.com/issues/42059
    2. https://github.com/torvalds/linux/blob/ea4424be16887a37735d6550cfd0611528dbe5d9/mm/memcontrol.c#L5337