Skip to content

Commit aabc92b

Browse files
committed
net: add __netdev_alloc_pcpu_stats() to indicate gfp flags
nf_tables may create percpu counters from the packet path through its dynamic set instantiation infrastructure, so we need a way to allocate this through GFP_ATOMIC. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Acked-by: David S. Miller <davem@davemloft.net>
1 parent 74ec4d5 commit aabc92b

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

include/linux/netdevice.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2068,20 +2068,23 @@ struct pcpu_sw_netstats {
20682068
struct u64_stats_sync syncp;
20692069
};
20702070

2071-
#define netdev_alloc_pcpu_stats(type) \
2072-
({ \
2073-
typeof(type) __percpu *pcpu_stats = alloc_percpu(type); \
2074-
if (pcpu_stats) { \
2075-
int __cpu; \
2076-
for_each_possible_cpu(__cpu) { \
2077-
typeof(type) *stat; \
2078-
stat = per_cpu_ptr(pcpu_stats, __cpu); \
2079-
u64_stats_init(&stat->syncp); \
2080-
} \
2081-
} \
2082-
pcpu_stats; \
2071+
#define __netdev_alloc_pcpu_stats(type, gfp) \
2072+
({ \
2073+
typeof(type) __percpu *pcpu_stats = alloc_percpu_gfp(type, gfp);\
2074+
if (pcpu_stats) { \
2075+
int __cpu; \
2076+
for_each_possible_cpu(__cpu) { \
2077+
typeof(type) *stat; \
2078+
stat = per_cpu_ptr(pcpu_stats, __cpu); \
2079+
u64_stats_init(&stat->syncp); \
2080+
} \
2081+
} \
2082+
pcpu_stats; \
20832083
})
20842084

2085+
#define netdev_alloc_pcpu_stats(type) \
2086+
__netdev_alloc_pcpu_stats(type, GFP_KERNEL);
2087+
20852088
#include <linux/notifier.h>
20862089

20872090
/* netdevice notifier chain. Please remember to update the rtnetlink

0 commit comments

Comments
 (0)