)]}'
{
  "commit": "fc9702273e2edb90400a34b3be76f7b08fa3344b",
  "tree": "2b4f1121496869a32b6f82c63a7e37e737b6e356",
  "parents": [
    "85192dbf4de08795afe2b88e52a36fc6abfc3dba"
  ],
  "author": {
    "name": "Andrii Nakryiko",
    "email": "andriin@fb.com",
    "time": "Sun Nov 17 09:28:04 2019 -0800"
  },
  "committer": {
    "name": "Daniel Borkmann",
    "email": "daniel@iogearbox.net",
    "time": "Mon Nov 18 11:41:59 2019 +0100"
  },
  "message": "bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY\n\nAdd ability to memory-map contents of BPF array map. This is extremely useful\nfor working with BPF global data from userspace programs. It allows to avoid\ntypical bpf_map_{lookup,update}_elem operations, improving both performance\nand usability.\n\nThere had to be special considerations for map freezing, to avoid having\nwritable memory view into a frozen map. To solve this issue, map freezing and\nmmap-ing is happening under mutex now:\n  - if map is already frozen, no writable mapping is allowed;\n  - if map has writable memory mappings active (accounted in map-\u003ewritecnt),\n    map freezing will keep failing with -EBUSY;\n  - once number of writable memory mappings drops to zero, map freezing can be\n    performed again.\n\nOnly non-per-CPU plain arrays are supported right now. Maps with spinlocks\ncan\u0027t be memory mapped either.\n\nFor BPF_F_MMAPABLE array, memory allocation has to be done through vmalloc()\nto be mmap()\u0027able. We also need to make sure that array data memory is\npage-sized and page-aligned, so we over-allocate memory in such a way that\nstruct bpf_array is at the end of a single page of memory with array-\u003evalue\nbeing aligned with the start of the second page. On deallocation we need to\naccomodate this memory arrangement to free vmalloc()\u0027ed memory correctly.\n\nOne important consideration regarding how memory-mapping subsystem functions.\nMemory-mapping subsystem provides few optional callbacks, among them open()\nand close().  close() is called for each memory region that is unmapped, so\nthat users can decrease their reference counters and free up resources, if\nnecessary. open() is *almost* symmetrical: it\u0027s called for each memory region\nthat is being mapped, **except** the very first one. So bpf_map_mmap does\ninitial refcnt bump, while open() will do any extra ones after that. Thus\nnumber of close() calls is equal to number of open() calls plus one more.\n\nSigned-off-by: Andrii Nakryiko \u003candriin@fb.com\u003e\nSigned-off-by: Daniel Borkmann \u003cdaniel@iogearbox.net\u003e\nAcked-by: Song Liu \u003csongliubraving@fb.com\u003e\nAcked-by: John Fastabend \u003cjohn.fastabend@gmail.com\u003e\nAcked-by: Johannes Weiner \u003channes@cmpxchg.org\u003e\nLink: https://lore.kernel.org/bpf/20191117172806.2195367-4-andriin@fb.com\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "fb606dc61a3ad6402471db92ab5dc848ecb1c643",
      "old_mode": 33188,
      "old_path": "include/linux/bpf.h",
      "new_id": "e913dd5946ae72327375a29d45973fae21a57451",
      "new_mode": 33188,
      "new_path": "include/linux/bpf.h"
    },
    {
      "type": "modify",
      "old_id": "4e7809408073d5a066d8632fcafc0615a0b0cfd3",
      "old_mode": 33188,
      "old_path": "include/linux/vmalloc.h",
      "new_id": "b4c58a191eb140ee764daf26151c5a69eb0f75cd",
      "new_mode": 33188,
      "new_path": "include/linux/vmalloc.h"
    },
    {
      "type": "modify",
      "old_id": "4842a134b202a60af7da9e9a674bda62d7133aa7",
      "old_mode": 33188,
      "old_path": "include/uapi/linux/bpf.h",
      "new_id": "dbbcf0b02970be868446632329d078ad3b51f9a1",
      "new_mode": 33188,
      "new_path": "include/uapi/linux/bpf.h"
    },
    {
      "type": "modify",
      "old_id": "1c65ce0098a950703c3604f1d0f3e43907e69656",
      "old_mode": 33188,
      "old_path": "kernel/bpf/arraymap.c",
      "new_id": "a42097c36b0c75a1a5257e24b52f2530e287c134",
      "new_mode": 33188,
      "new_path": "kernel/bpf/arraymap.c"
    },
    {
      "type": "modify",
      "old_id": "52fe4bacb3300796b398d454684faa8b0c04504a",
      "old_mode": 33188,
      "old_path": "kernel/bpf/syscall.c",
      "new_id": "bac3becf9f90403b9ffff338889521af0be6f8bb",
      "new_mode": 33188,
      "new_path": "kernel/bpf/syscall.c"
    },
    {
      "type": "modify",
      "old_id": "a3c70e275f4e5331fd69eff970cf831021a1dced",
      "old_mode": 33188,
      "old_path": "mm/vmalloc.c",
      "new_id": "4a7d7459c4f9a54430002d0e157e0251427ebcee",
      "new_mode": 33188,
      "new_path": "mm/vmalloc.c"
    },
    {
      "type": "modify",
      "old_id": "4842a134b202a60af7da9e9a674bda62d7133aa7",
      "old_mode": 33188,
      "old_path": "tools/include/uapi/linux/bpf.h",
      "new_id": "dbbcf0b02970be868446632329d078ad3b51f9a1",
      "new_mode": 33188,
      "new_path": "tools/include/uapi/linux/bpf.h"
    }
  ]
}
