Skip to content

Commit 903ceff

Browse files
Christoph Lameterhtejun
authored andcommitted
net: Replace get_cpu_var through this_cpu_ptr
Replace uses of get_cpu_var for address calculation through this_cpu_ptr. Cc: netdev@vger.kernel.org Cc: Eric Dumazet <edumazet@google.com> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Christoph Lameter <cl@linux.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent f7f66b0 commit 903ceff

File tree

11 files changed

+20
-20
lines changed

11 files changed

+20
-20
lines changed

include/net/netfilter/nf_conntrack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ extern s32 (*nf_ct_nat_offset)(const struct nf_conn *ct,
242242
DECLARE_PER_CPU(struct nf_conn, nf_conntrack_untracked);
243243
static inline struct nf_conn *nf_ct_untracked_get(void)
244244
{
245-
return &__raw_get_cpu_var(nf_conntrack_untracked);
245+
return raw_cpu_ptr(&nf_conntrack_untracked);
246246
}
247247
void nf_ct_untracked_status_or(unsigned long bits);
248248

include/net/snmp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ struct linux_xfrm_mib {
168168

169169
#define SNMP_ADD_STATS64_BH(mib, field, addend) \
170170
do { \
171-
__typeof__(*mib) *ptr = __this_cpu_ptr(mib); \
171+
__typeof__(*mib) *ptr = raw_cpu_ptr(mib); \
172172
u64_stats_update_begin(&ptr->syncp); \
173173
ptr->mibs[field] += addend; \
174174
u64_stats_update_end(&ptr->syncp); \
@@ -189,8 +189,8 @@ struct linux_xfrm_mib {
189189
#define SNMP_INC_STATS64(mib, field) SNMP_ADD_STATS64(mib, field, 1)
190190
#define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) \
191191
do { \
192-
__typeof__(*mib) *ptr; \
193-
ptr = __this_cpu_ptr(mib); \
192+
__typeof__(*mib) *ptr; \
193+
ptr = raw_cpu_ptr((mib)); \
194194
u64_stats_update_begin(&ptr->syncp); \
195195
ptr->mibs[basefield##PKTS]++; \
196196
ptr->mibs[basefield##OCTETS] += addend; \

net/core/dev.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,7 +2153,7 @@ static inline void __netif_reschedule(struct Qdisc *q)
21532153
unsigned long flags;
21542154

21552155
local_irq_save(flags);
2156-
sd = &__get_cpu_var(softnet_data);
2156+
sd = this_cpu_ptr(&softnet_data);
21572157
q->next_sched = NULL;
21582158
*sd->output_queue_tailp = q;
21592159
sd->output_queue_tailp = &q->next_sched;
@@ -3195,7 +3195,7 @@ static void rps_trigger_softirq(void *data)
31953195
static int rps_ipi_queued(struct softnet_data *sd)
31963196
{
31973197
#ifdef CONFIG_RPS
3198-
struct softnet_data *mysd = &__get_cpu_var(softnet_data);
3198+
struct softnet_data *mysd = this_cpu_ptr(&softnet_data);
31993199

32003200
if (sd != mysd) {
32013201
sd->rps_ipi_next = mysd->rps_ipi_list;
@@ -3222,7 +3222,7 @@ static bool skb_flow_limit(struct sk_buff *skb, unsigned int qlen)
32223222
if (qlen < (netdev_max_backlog >> 1))
32233223
return false;
32243224

3225-
sd = &__get_cpu_var(softnet_data);
3225+
sd = this_cpu_ptr(&softnet_data);
32263226

32273227
rcu_read_lock();
32283228
fl = rcu_dereference(sd->flow_limit);
@@ -3369,7 +3369,7 @@ EXPORT_SYMBOL(netif_rx_ni);
33693369

33703370
static void net_tx_action(struct softirq_action *h)
33713371
{
3372-
struct softnet_data *sd = &__get_cpu_var(softnet_data);
3372+
struct softnet_data *sd = this_cpu_ptr(&softnet_data);
33733373

33743374
if (sd->completion_queue) {
33753375
struct sk_buff *clist;
@@ -3794,7 +3794,7 @@ EXPORT_SYMBOL(netif_receive_skb);
37943794
static void flush_backlog(void *arg)
37953795
{
37963796
struct net_device *dev = arg;
3797-
struct softnet_data *sd = &__get_cpu_var(softnet_data);
3797+
struct softnet_data *sd = this_cpu_ptr(&softnet_data);
37983798
struct sk_buff *skb, *tmp;
37993799

38003800
rps_lock(sd);
@@ -4301,7 +4301,7 @@ void __napi_schedule(struct napi_struct *n)
43014301
unsigned long flags;
43024302

43034303
local_irq_save(flags);
4304-
____napi_schedule(&__get_cpu_var(softnet_data), n);
4304+
____napi_schedule(this_cpu_ptr(&softnet_data), n);
43054305
local_irq_restore(flags);
43064306
}
43074307
EXPORT_SYMBOL(__napi_schedule);
@@ -4422,7 +4422,7 @@ EXPORT_SYMBOL(netif_napi_del);
44224422

44234423
static void net_rx_action(struct softirq_action *h)
44244424
{
4425-
struct softnet_data *sd = &__get_cpu_var(softnet_data);
4425+
struct softnet_data *sd = this_cpu_ptr(&softnet_data);
44264426
unsigned long time_limit = jiffies + 2;
44274427
int budget = netdev_budget;
44284428
void *have;

net/core/drop_monitor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static void trace_drop_common(struct sk_buff *skb, void *location)
146146
unsigned long flags;
147147

148148
local_irq_save(flags);
149-
data = &__get_cpu_var(dm_cpu_data);
149+
data = this_cpu_ptr(&dm_cpu_data);
150150
spin_lock(&data->lock);
151151
dskb = data->skb;
152152

net/core/skbuff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask)
345345
unsigned long flags;
346346

347347
local_irq_save(flags);
348-
nc = &__get_cpu_var(netdev_alloc_cache);
348+
nc = this_cpu_ptr(&netdev_alloc_cache);
349349
if (unlikely(!nc->frag.page)) {
350350
refill:
351351
for (order = NETDEV_FRAG_PAGE_MAX_ORDER; ;) {

net/ipv4/route.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ static bool rt_cache_route(struct fib_nh *nh, struct rtable *rt)
13111311
if (rt_is_input_route(rt)) {
13121312
p = (struct rtable **)&nh->nh_rth_input;
13131313
} else {
1314-
p = (struct rtable **)__this_cpu_ptr(nh->nh_pcpu_rth_output);
1314+
p = (struct rtable **)raw_cpu_ptr(nh->nh_pcpu_rth_output);
13151315
}
13161316
orig = *p;
13171317

@@ -1939,7 +1939,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
19391939
do_cache = false;
19401940
goto add;
19411941
}
1942-
prth = __this_cpu_ptr(nh->nh_pcpu_rth_output);
1942+
prth = raw_cpu_ptr(nh->nh_pcpu_rth_output);
19431943
}
19441944
rth = rcu_dereference(*prth);
19451945
if (rt_cache_valid(rth)) {

net/ipv4/syncookies.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport,
4040

4141
net_get_random_once(syncookie_secret, sizeof(syncookie_secret));
4242

43-
tmp = __get_cpu_var(ipv4_cookie_scratch);
43+
tmp = this_cpu_ptr(ipv4_cookie_scratch);
4444
memcpy(tmp + 4, syncookie_secret[c], sizeof(syncookie_secret[c]));
4545
tmp[0] = (__force u32)saddr;
4646
tmp[1] = (__force u32)daddr;

net/ipv4/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3058,7 +3058,7 @@ struct tcp_md5sig_pool *tcp_get_md5sig_pool(void)
30583058
local_bh_disable();
30593059
p = ACCESS_ONCE(tcp_md5sig_pool);
30603060
if (p)
3061-
return __this_cpu_ptr(p);
3061+
return raw_cpu_ptr(p);
30623062

30633063
local_bh_enable();
30643064
return NULL;

net/ipv4/tcp_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ void tcp_wfree(struct sk_buff *skb)
842842

843843
/* queue this socket to tasklet queue */
844844
local_irq_save(flags);
845-
tsq = &__get_cpu_var(tsq_tasklet);
845+
tsq = this_cpu_ptr(&tsq_tasklet);
846846
list_add(&tp->tsq_node, &tsq->head);
847847
tasklet_schedule(&tsq->tasklet);
848848
local_irq_restore(flags);

net/ipv6/syncookies.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static u32 cookie_hash(const struct in6_addr *saddr, const struct in6_addr *dadd
6767

6868
net_get_random_once(syncookie6_secret, sizeof(syncookie6_secret));
6969

70-
tmp = __get_cpu_var(ipv6_cookie_scratch);
70+
tmp = this_cpu_ptr(ipv6_cookie_scratch);
7171

7272
/*
7373
* we have 320 bits of information to hash, copy in the remaining

net/rds/ib_rdma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static inline struct rds_ib_mr *rds_ib_reuse_fmr(struct rds_ib_mr_pool *pool)
267267
unsigned long *flag;
268268

269269
preempt_disable();
270-
flag = &__get_cpu_var(clean_list_grace);
270+
flag = this_cpu_ptr(&clean_list_grace);
271271
set_bit(CLEAN_LIST_BUSY_BIT, flag);
272272
ret = llist_del_first(&pool->clean_list);
273273
if (ret)

0 commit comments

Comments
 (0)