Commit a7950ae8 authored by Davidlohr Bueso's avatar Davidlohr Bueso Committed by David S. Miller

net/sock: Update memalloc_socks 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 memalloc_socks, for better self
documentation.
Signed-off-by: default avatarDavidlohr Bueso <dbueso@suse.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5263a98f
...@@ -808,10 +808,10 @@ static inline bool sock_flag(const struct sock *sk, enum sock_flags flag) ...@@ -808,10 +808,10 @@ static inline bool sock_flag(const struct sock *sk, enum sock_flags flag)
} }
#ifdef CONFIG_NET #ifdef CONFIG_NET
extern struct static_key memalloc_socks; DECLARE_STATIC_KEY_FALSE(memalloc_socks_key);
static inline int sk_memalloc_socks(void) static inline int sk_memalloc_socks(void)
{ {
return static_key_false(&memalloc_socks); return static_branch_unlikely(&memalloc_socks_key);
} }
#else #else
......
...@@ -327,8 +327,8 @@ EXPORT_SYMBOL(sysctl_optmem_max); ...@@ -327,8 +327,8 @@ EXPORT_SYMBOL(sysctl_optmem_max);
int sysctl_tstamp_allow_data __read_mostly = 1; int sysctl_tstamp_allow_data __read_mostly = 1;
struct static_key memalloc_socks = STATIC_KEY_INIT_FALSE; DEFINE_STATIC_KEY_FALSE(memalloc_socks_key);
EXPORT_SYMBOL_GPL(memalloc_socks); EXPORT_SYMBOL_GPL(memalloc_socks_key);
/** /**
* sk_set_memalloc - sets %SOCK_MEMALLOC * sk_set_memalloc - sets %SOCK_MEMALLOC
...@@ -342,7 +342,7 @@ void sk_set_memalloc(struct sock *sk) ...@@ -342,7 +342,7 @@ void sk_set_memalloc(struct sock *sk)
{ {
sock_set_flag(sk, SOCK_MEMALLOC); sock_set_flag(sk, SOCK_MEMALLOC);
sk->sk_allocation |= __GFP_MEMALLOC; sk->sk_allocation |= __GFP_MEMALLOC;
static_key_slow_inc(&memalloc_socks); static_branch_inc(&memalloc_socks_key);
} }
EXPORT_SYMBOL_GPL(sk_set_memalloc); EXPORT_SYMBOL_GPL(sk_set_memalloc);
...@@ -350,7 +350,7 @@ void sk_clear_memalloc(struct sock *sk) ...@@ -350,7 +350,7 @@ void sk_clear_memalloc(struct sock *sk)
{ {
sock_reset_flag(sk, SOCK_MEMALLOC); sock_reset_flag(sk, SOCK_MEMALLOC);
sk->sk_allocation &= ~__GFP_MEMALLOC; sk->sk_allocation &= ~__GFP_MEMALLOC;
static_key_slow_dec(&memalloc_socks); static_branch_dec(&memalloc_socks_key);
/* /*
* SOCK_MEMALLOC is allowed to ignore rmem limits to ensure forward * SOCK_MEMALLOC is allowed to ignore rmem limits to ensure forward
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment