Skip to content

Commit 7249fd8

Browse files
committed
bpf: Rename __htab_percpu_map_update_elem to htab_map_update_elem_in_place
JIRA: https://issues.redhat.com/browse/RHEL-110274 Conflicts: changed context due to missing upstream commit 4fa8d68 ("bpf: Convert hashtab.c to rqspinlock") commit 5771e30 Author: Hou Tao <[email protected]> Date: Tue Apr 1 14:22:46 2025 +0800 bpf: Rename __htab_percpu_map_update_elem to htab_map_update_elem_in_place Rename __htab_percpu_map_update_elem to htab_map_update_elem_in_place, and add a new percpu argument for the helper to support in-place update for both per-cpu htab and htab of maps. Acked-by: Andrii Nakryiko <[email protected]> Signed-off-by: Hou Tao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Viktor Malik <[email protected]>
1 parent abfca01 commit 7249fd8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

kernel/bpf/hashtab.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,12 +1289,12 @@ static long htab_lru_map_update_elem(struct bpf_map *map, void *key, void *value
12891289
return ret;
12901290
}
12911291

1292-
static long __htab_percpu_map_update_elem(struct bpf_map *map, void *key,
1292+
static long htab_map_update_elem_in_place(struct bpf_map *map, void *key,
12931293
void *value, u64 map_flags,
1294-
bool onallcpus)
1294+
bool percpu, bool onallcpus)
12951295
{
12961296
struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
1297-
struct htab_elem *l_new = NULL, *l_old;
1297+
struct htab_elem *l_new, *l_old;
12981298
struct hlist_nulls_head *head;
12991299
unsigned long flags;
13001300
struct bucket *b;
@@ -1326,19 +1326,18 @@ static long __htab_percpu_map_update_elem(struct bpf_map *map, void *key,
13261326
goto err;
13271327

13281328
if (l_old) {
1329-
/* per-cpu hash map can update value in-place */
1329+
/* Update value in-place */
13301330
pcpu_copy_value(htab, htab_elem_get_ptr(l_old, key_size),
13311331
value, onallcpus);
13321332
} else {
13331333
l_new = alloc_htab_elem(htab, key, value, key_size,
1334-
hash, true, onallcpus, NULL);
1334+
hash, percpu, onallcpus, NULL);
13351335
if (IS_ERR(l_new)) {
13361336
ret = PTR_ERR(l_new);
13371337
goto err;
13381338
}
13391339
hlist_nulls_add_head_rcu(&l_new->hash_node, head);
13401340
}
1341-
ret = 0;
13421341
err:
13431342
htab_unlock_bucket(htab, b, hash, flags);
13441343
return ret;
@@ -1417,7 +1416,7 @@ static long __htab_lru_percpu_map_update_elem(struct bpf_map *map, void *key,
14171416
static long htab_percpu_map_update_elem(struct bpf_map *map, void *key,
14181417
void *value, u64 map_flags)
14191418
{
1420-
return __htab_percpu_map_update_elem(map, key, value, map_flags, false);
1419+
return htab_map_update_elem_in_place(map, key, value, map_flags, true, false);
14211420
}
14221421

14231422
static long htab_lru_percpu_map_update_elem(struct bpf_map *map, void *key,
@@ -2443,8 +2442,8 @@ int bpf_percpu_hash_update(struct bpf_map *map, void *key, void *value,
24432442
ret = __htab_lru_percpu_map_update_elem(map, key, value,
24442443
map_flags, true);
24452444
else
2446-
ret = __htab_percpu_map_update_elem(map, key, value, map_flags,
2447-
true);
2445+
ret = htab_map_update_elem_in_place(map, key, value, map_flags,
2446+
true, true);
24482447
rcu_read_unlock();
24492448

24502449
return ret;

0 commit comments

Comments
 (0)