OSDN Git Service

mm: make page ref count overflow check tighter and more explicit
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Apr 2019 17:06:20 +0000 (10:06 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 May 2019 07:20:10 +0000 (09:20 +0200)
commit9f6da5fd05577ef4a05c1744cc7098d0173823af
treeacaff955106eb1aa07105d946812075aa7bd8635
parent99ae2bd0772f7fd943513ebba5cbae3899c02b13
mm: make page ref count overflow check tighter and more explicit

commit f958d7b528b1b40c44cfda5eabe2d82760d868c3 upstream.

We have a VM_BUG_ON() to check that the page reference count doesn't
underflow (or get close to overflow) by checking the sign of the count.

That's all fine, but we actually want to allow people to use a "get page
ref unless it's already very high" helper function, and we want that one
to use the sign of the page ref (without triggering this VM_BUG_ON).

Change the VM_BUG_ON to only check for small underflows (or _very_ close
to overflowing), and ignore overflows which have strayed into negative
territory.

Acked-by: Matthew Wilcox <willy@infradead.org>
Cc: Jann Horn <jannh@google.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/mm.h