mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
net: introduce netdev_alloc_pcpu_stats() for drivers
There are many drivers calling alloc_percpu() to allocate pcpu stats and then initializing ->syncp. So just introduce a helper function for them. Cc: David S. Miller <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
ed1acc8cd8
commit
1c213bd24a
19 changed files with 35 additions and 154 deletions
|
|
@ -1215,18 +1215,12 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
|
|||
if (err)
|
||||
goto err_free_dp;
|
||||
|
||||
dp->stats_percpu = alloc_percpu(struct dp_stats_percpu);
|
||||
dp->stats_percpu = netdev_alloc_pcpu_stats(struct dp_stats_percpu);
|
||||
if (!dp->stats_percpu) {
|
||||
err = -ENOMEM;
|
||||
goto err_destroy_table;
|
||||
}
|
||||
|
||||
for_each_possible_cpu(i) {
|
||||
struct dp_stats_percpu *dpath_stats;
|
||||
dpath_stats = per_cpu_ptr(dp->stats_percpu, i);
|
||||
u64_stats_init(&dpath_stats->sync);
|
||||
}
|
||||
|
||||
dp->ports = kmalloc(DP_VPORT_HASH_BUCKETS * sizeof(struct hlist_head),
|
||||
GFP_KERNEL);
|
||||
if (!dp->ports) {
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
|
|||
{
|
||||
struct vport *vport;
|
||||
size_t alloc_size;
|
||||
int i;
|
||||
|
||||
alloc_size = sizeof(struct vport);
|
||||
if (priv_size) {
|
||||
|
|
@ -139,19 +138,12 @@ struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
|
|||
vport->ops = ops;
|
||||
INIT_HLIST_NODE(&vport->dp_hash_node);
|
||||
|
||||
vport->percpu_stats = alloc_percpu(struct pcpu_sw_netstats);
|
||||
vport->percpu_stats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
|
||||
if (!vport->percpu_stats) {
|
||||
kfree(vport);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
for_each_possible_cpu(i) {
|
||||
struct pcpu_sw_netstats *vport_stats;
|
||||
vport_stats = per_cpu_ptr(vport->percpu_stats, i);
|
||||
u64_stats_init(&vport_stats->syncp);
|
||||
}
|
||||
|
||||
|
||||
spin_lock_init(&vport->stats_lock);
|
||||
|
||||
return vport;
|
||||
|
|
|
|||
Loading…
Reference in a new issue