Commit 57fc05e8 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: mm_account_pinned_pages() optimization

Adopt atomic_long_try_cmpxchg() in mm_account_pinned_pages()
as it is slightly more efficient.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8c55face
...@@ -1267,13 +1267,12 @@ int mm_account_pinned_pages(struct mmpin *mmp, size_t size) ...@@ -1267,13 +1267,12 @@ int mm_account_pinned_pages(struct mmpin *mmp, size_t size)
max_pg = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; max_pg = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
user = mmp->user ? : current_user(); user = mmp->user ? : current_user();
old_pg = atomic_long_read(&user->locked_vm);
do { do {
old_pg = atomic_long_read(&user->locked_vm);
new_pg = old_pg + num_pg; new_pg = old_pg + num_pg;
if (new_pg > max_pg) if (new_pg > max_pg)
return -ENOBUFS; return -ENOBUFS;
} while (atomic_long_cmpxchg(&user->locked_vm, old_pg, new_pg) != } while (!atomic_long_try_cmpxchg(&user->locked_vm, &old_pg, new_pg));
old_pg);
if (!mmp->user) { if (!mmp->user) {
mmp->user = get_uid(user); mmp->user = get_uid(user);
......
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