mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-18 20:04:16 +08:00
net: Update netstamp_needed static key to modern api
No changes in refcount semantics -- key init is false; replace static_key_slow_inc|dec with static_branch_inc|dec static_key_false with static_branch_unlikely Added a '_key' suffix to netstamp_needed, for better self documentation. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
aabf6772cc
commit
39e8392201
@ -1786,7 +1786,7 @@ void net_dec_egress_queue(void)
|
|||||||
EXPORT_SYMBOL_GPL(net_dec_egress_queue);
|
EXPORT_SYMBOL_GPL(net_dec_egress_queue);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct static_key netstamp_needed __read_mostly;
|
static DEFINE_STATIC_KEY_FALSE(netstamp_needed_key);
|
||||||
#ifdef HAVE_JUMP_LABEL
|
#ifdef HAVE_JUMP_LABEL
|
||||||
static atomic_t netstamp_needed_deferred;
|
static atomic_t netstamp_needed_deferred;
|
||||||
static atomic_t netstamp_wanted;
|
static atomic_t netstamp_wanted;
|
||||||
@ -1797,9 +1797,9 @@ static void netstamp_clear(struct work_struct *work)
|
|||||||
|
|
||||||
wanted = atomic_add_return(deferred, &netstamp_wanted);
|
wanted = atomic_add_return(deferred, &netstamp_wanted);
|
||||||
if (wanted > 0)
|
if (wanted > 0)
|
||||||
static_key_enable(&netstamp_needed);
|
static_branch_enable(&netstamp_needed_key);
|
||||||
else
|
else
|
||||||
static_key_disable(&netstamp_needed);
|
static_branch_disable(&netstamp_needed_key);
|
||||||
}
|
}
|
||||||
static DECLARE_WORK(netstamp_work, netstamp_clear);
|
static DECLARE_WORK(netstamp_work, netstamp_clear);
|
||||||
#endif
|
#endif
|
||||||
@ -1819,7 +1819,7 @@ void net_enable_timestamp(void)
|
|||||||
atomic_inc(&netstamp_needed_deferred);
|
atomic_inc(&netstamp_needed_deferred);
|
||||||
schedule_work(&netstamp_work);
|
schedule_work(&netstamp_work);
|
||||||
#else
|
#else
|
||||||
static_key_slow_inc(&netstamp_needed);
|
static_branch_inc(&netstamp_needed_key);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(net_enable_timestamp);
|
EXPORT_SYMBOL(net_enable_timestamp);
|
||||||
@ -1839,7 +1839,7 @@ void net_disable_timestamp(void)
|
|||||||
atomic_dec(&netstamp_needed_deferred);
|
atomic_dec(&netstamp_needed_deferred);
|
||||||
schedule_work(&netstamp_work);
|
schedule_work(&netstamp_work);
|
||||||
#else
|
#else
|
||||||
static_key_slow_dec(&netstamp_needed);
|
static_branch_dec(&netstamp_needed_key);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(net_disable_timestamp);
|
EXPORT_SYMBOL(net_disable_timestamp);
|
||||||
@ -1847,15 +1847,15 @@ EXPORT_SYMBOL(net_disable_timestamp);
|
|||||||
static inline void net_timestamp_set(struct sk_buff *skb)
|
static inline void net_timestamp_set(struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
skb->tstamp = 0;
|
skb->tstamp = 0;
|
||||||
if (static_key_false(&netstamp_needed))
|
if (static_branch_unlikely(&netstamp_needed_key))
|
||||||
__net_timestamp(skb);
|
__net_timestamp(skb);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define net_timestamp_check(COND, SKB) \
|
#define net_timestamp_check(COND, SKB) \
|
||||||
if (static_key_false(&netstamp_needed)) { \
|
if (static_branch_unlikely(&netstamp_needed_key)) { \
|
||||||
if ((COND) && !(SKB)->tstamp) \
|
if ((COND) && !(SKB)->tstamp) \
|
||||||
__net_timestamp(SKB); \
|
__net_timestamp(SKB); \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
bool is_skb_forwardable(const struct net_device *dev, const struct sk_buff *skb)
|
bool is_skb_forwardable(const struct net_device *dev, const struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user