You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
percpu: add __percpu sparse annotations to net drivers
Add __percpu sparse annotations to net drivers. These annotations are to make sparse consider percpu variables to be in a different address space and warn if accessed without going through percpu accessors. This patch doesn't affect normal builds. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: David S. Miller <davem@davemloft.net> Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
7d720c3e4f
commit
47d742752d
@@ -72,7 +72,8 @@ struct pcpu_lstats {
|
||||
static netdev_tx_t loopback_xmit(struct sk_buff *skb,
|
||||
struct net_device *dev)
|
||||
{
|
||||
struct pcpu_lstats *pcpu_lstats, *lb_stats;
|
||||
struct pcpu_lstats __percpu *pcpu_lstats;
|
||||
struct pcpu_lstats *lb_stats;
|
||||
int len;
|
||||
|
||||
skb_orphan(skb);
|
||||
@@ -80,7 +81,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
|
||||
skb->protocol = eth_type_trans(skb, dev);
|
||||
|
||||
/* it's OK to use per_cpu_ptr() because BHs are off */
|
||||
pcpu_lstats = dev->ml_priv;
|
||||
pcpu_lstats = (void __percpu __force *)dev->ml_priv;
|
||||
lb_stats = this_cpu_ptr(pcpu_lstats);
|
||||
|
||||
len = skb->len;
|
||||
@@ -95,14 +96,14 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
|
||||
|
||||
static struct net_device_stats *loopback_get_stats(struct net_device *dev)
|
||||
{
|
||||
const struct pcpu_lstats *pcpu_lstats;
|
||||
const struct pcpu_lstats __percpu *pcpu_lstats;
|
||||
struct net_device_stats *stats = &dev->stats;
|
||||
unsigned long bytes = 0;
|
||||
unsigned long packets = 0;
|
||||
unsigned long drops = 0;
|
||||
int i;
|
||||
|
||||
pcpu_lstats = dev->ml_priv;
|
||||
pcpu_lstats = (void __percpu __force *)dev->ml_priv;
|
||||
for_each_possible_cpu(i) {
|
||||
const struct pcpu_lstats *lb_stats;
|
||||
|
||||
@@ -135,19 +136,20 @@ static const struct ethtool_ops loopback_ethtool_ops = {
|
||||
|
||||
static int loopback_dev_init(struct net_device *dev)
|
||||
{
|
||||
struct pcpu_lstats *lstats;
|
||||
struct pcpu_lstats __percpu *lstats;
|
||||
|
||||
lstats = alloc_percpu(struct pcpu_lstats);
|
||||
if (!lstats)
|
||||
return -ENOMEM;
|
||||
|
||||
dev->ml_priv = lstats;
|
||||
dev->ml_priv = (void __force *)lstats;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void loopback_dev_free(struct net_device *dev)
|
||||
{
|
||||
struct pcpu_lstats *lstats = dev->ml_priv;
|
||||
struct pcpu_lstats __percpu *lstats =
|
||||
(void __percpu __force *)dev->ml_priv;
|
||||
|
||||
free_percpu(lstats);
|
||||
free_netdev(dev);
|
||||
|
||||
Reference in New Issue
Block a user