bpf: Add map and need_defer parameters to .map_fd_put_ptr()
[linux-2.6-microblaze.git] / kernel / bpf / arraymap.c
index 2058e89..f9aed59 100644 (file)
@@ -867,7 +867,7 @@ int bpf_fd_array_map_update_elem(struct bpf_map *map, struct file *map_file,
        }
 
        if (old_ptr)
-               map->ops->map_fd_put_ptr(old_ptr);
+               map->ops->map_fd_put_ptr(map, old_ptr, true);
        return 0;
 }
 
@@ -890,7 +890,7 @@ static long fd_array_map_delete_elem(struct bpf_map *map, void *key)
        }
 
        if (old_ptr) {
-               map->ops->map_fd_put_ptr(old_ptr);
+               map->ops->map_fd_put_ptr(map, old_ptr, true);
                return 0;
        } else {
                return -ENOENT;
@@ -913,8 +913,9 @@ static void *prog_fd_array_get_ptr(struct bpf_map *map,
        return prog;
 }
 
-static void prog_fd_array_put_ptr(void *ptr)
+static void prog_fd_array_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
 {
+       /* bpf_prog is freed after one RCU or tasks trace grace period */
        bpf_prog_put(ptr);
 }
 
@@ -1239,8 +1240,9 @@ err_out:
        return ee;
 }
 
-static void perf_event_fd_array_put_ptr(void *ptr)
+static void perf_event_fd_array_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
 {
+       /* bpf_perf_event is freed after one RCU grace period */
        bpf_event_entry_free_rcu(ptr);
 }
 
@@ -1294,7 +1296,7 @@ static void *cgroup_fd_array_get_ptr(struct bpf_map *map,
        return cgroup_get_from_fd(fd);
 }
 
-static void cgroup_fd_array_put_ptr(void *ptr)
+static void cgroup_fd_array_put_ptr(struct bpf_map *map, void *ptr, bool need_defer)
 {
        /* cgroup_put free cgrp after a rcu grace period */
        cgroup_put(ptr);