hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/kernel/bpf/bpf_lru_list.h
....@@ -1,12 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /* Copyright (c) 2016 Facebook
2
- *
3
- * This program is free software; you can redistribute it and/or
4
- * modify it under the terms of version 2 of the GNU General Public
5
- * License as published by the Free Software Foundation.
63 */
74 #ifndef __BPF_LRU_LIST_H_
85 #define __BPF_LRU_LIST_H_
96
7
+#include <linux/cache.h>
108 #include <linux/list.h>
119 #include <linux/spinlock_types.h>
1210
....@@ -33,7 +31,7 @@
3331 struct bpf_lru_list {
3432 struct list_head lists[NR_BPF_LRU_LIST_T];
3533 unsigned int counts[NR_BPF_LRU_LIST_COUNT];
36
- /* The next inacitve list rotation starts from here */
34
+ /* The next inactive list rotation starts from here */
3735 struct list_head *next_inactive_rotation;
3836
3937 raw_spinlock_t lock ____cacheline_aligned_in_smp;
....@@ -66,11 +64,8 @@
6664
6765 static inline void bpf_lru_node_set_ref(struct bpf_lru_node *node)
6866 {
69
- /* ref is an approximation on access frequency. It does not
70
- * have to be very accurate. Hence, no protection is used.
71
- */
72
- if (!node->ref)
73
- node->ref = 1;
67
+ if (!READ_ONCE(node->ref))
68
+ WRITE_ONCE(node->ref, 1);
7469 }
7570
7671 int bpf_lru_init(struct bpf_lru *lru, bool percpu, u32 hash_offset,