/* At this point bpf_prog->aux->refcnt == 0 and this map->refcnt == 0,
         * so the bpf programs (can be more than one that used this map) were
         * disconnected from events. Wait for outstanding critical sections in
-        * these programs to complete. The rcu critical section only guarantees
-        * no further "XDP/bpf-side" reads against bpf_cpu_map->cpu_map.
-        * It does __not__ ensure pending flush operations (if any) are
-        * complete.
+        * these programs to complete. synchronize_rcu() below not only
+        * guarantees no further "XDP/bpf-side" reads against
+        * bpf_cpu_map->cpu_map, but also ensure pending flush operations
+        * (if any) are completed.
         */
-
        synchronize_rcu();
 
-       /* For cpu_map the remote CPUs can still be using the entries
-        * (struct bpf_cpu_map_entry).
+       /* The only possible user of bpf_cpu_map_entry is
+        * cpu_map_kthread_run().
         */
        for (i = 0; i < cmap->map.max_entries; i++) {
                struct bpf_cpu_map_entry *rcpu;
                if (!rcpu)
                        continue;
 
-               /* bq flush and cleanup happens after RCU grace-period */
-               __cpu_map_entry_replace(cmap, i, NULL); /* call_rcu */
+               /* Stop kthread and cleanup entry directly */
+               __cpu_map_entry_free(&rcpu->free_work.work);
        }
        bpf_map_area_free(cmap->cpu_map);
        bpf_map_area_free(cmap);