[syscall.c - kernel/bpf/syscall.c - Linux source code v4.9 - Bootlin Elixir Cross Referencer](https://elixir.bootlin.com/linux/v4.9/source/kernel/bpf/syscall.c#L345)
[[RCU ]]
```c:
} else {
rcu_read_lock();
err = map->ops->map_update_elem(map, key, value, attr->flags);
rcu_read_unlock();
}
```
[[スピンロック]]
[hashtab.c - kernel/bpf/hashtab.c - Linux source code v4.9 - Bootlin Elixir Cross Referencer](https://elixir.bootlin.com/linux/v4.9/source/kernel/bpf/hashtab.c#L519)o
```c:
b = __select_bucket(htab, hash);
head = &b->head;
/* bpf_map_update_elem() can be called in_irq() */
raw_spin_lock_irqsave(&b->lock, flags);
l_old = lookup_elem_raw(head, hash, key, key_size);
ret = check_flags(htab, l_old, map_flags);
if (ret)
goto err;
l_new = alloc_htab_elem(htab, key, value, key_size, hash, false, false,
!!l_old);
if (IS_ERR(l_new)) {
/* all pre-allocated elements are in use or memory exhausted */
ret = PTR_ERR(l_new);
goto err;
}
/* add new element to the head of the list, so that
* concurrent search will find it before old elem
*/
hlist_add_head_rcu(&l_new->hash_node, head);
if (l_old) {
hlist_del_rcu(&l_old->hash_node);
free_htab_elem(htab, l_old);
}
ret = 0;
err:
raw_spin_unlock_irqrestore(&b->lock, flags);
return ret;
```