@@ -1258,12 +1258,12 @@ static long htab_lru_map_update_elem(struct bpf_map *map, void *key, void *value
12581258 return ret ;
12591259}
12601260
1261- static long __htab_percpu_map_update_elem (struct bpf_map * map , void * key ,
1261+ static long htab_map_update_elem_in_place (struct bpf_map * map , void * key ,
12621262 void * value , u64 map_flags ,
1263- bool onallcpus )
1263+ bool percpu , bool onallcpus )
12641264{
12651265 struct bpf_htab * htab = container_of (map , struct bpf_htab , map );
1266- struct htab_elem * l_new = NULL , * l_old ;
1266+ struct htab_elem * l_new , * l_old ;
12671267 struct hlist_nulls_head * head ;
12681268 unsigned long flags ;
12691269 struct bucket * b ;
@@ -1295,19 +1295,18 @@ static long __htab_percpu_map_update_elem(struct bpf_map *map, void *key,
12951295 goto err ;
12961296
12971297 if (l_old ) {
1298- /* per-cpu hash map can update value in-place */
1298+ /* Update value in-place */
12991299 pcpu_copy_value (htab , htab_elem_get_ptr (l_old , key_size ),
13001300 value , onallcpus );
13011301 } else {
13021302 l_new = alloc_htab_elem (htab , key , value , key_size ,
1303- hash , true , onallcpus , NULL );
1303+ hash , percpu , onallcpus , NULL );
13041304 if (IS_ERR (l_new )) {
13051305 ret = PTR_ERR (l_new );
13061306 goto err ;
13071307 }
13081308 hlist_nulls_add_head_rcu (& l_new -> hash_node , head );
13091309 }
1310- ret = 0 ;
13111310err :
13121311 htab_unlock_bucket (b , flags );
13131312 return ret ;
@@ -1386,7 +1385,7 @@ static long __htab_lru_percpu_map_update_elem(struct bpf_map *map, void *key,
13861385static long htab_percpu_map_update_elem (struct bpf_map * map , void * key ,
13871386 void * value , u64 map_flags )
13881387{
1389- return __htab_percpu_map_update_elem (map , key , value , map_flags , false);
1388+ return htab_map_update_elem_in_place (map , key , value , map_flags , true , false);
13901389}
13911390
13921391static long htab_lru_percpu_map_update_elem (struct bpf_map * map , void * key ,
@@ -2407,8 +2406,8 @@ int bpf_percpu_hash_update(struct bpf_map *map, void *key, void *value,
24072406 ret = __htab_lru_percpu_map_update_elem (map , key , value ,
24082407 map_flags , true);
24092408 else
2410- ret = __htab_percpu_map_update_elem (map , key , value , map_flags ,
2411- true);
2409+ ret = htab_map_update_elem_in_place (map , key , value , map_flags ,
2410+ true, true );
24122411 rcu_read_unlock ();
24132412
24142413 return ret ;
0 commit comments