mm/page_ref: Convert the open coded tracepoint enabled to the new helper

As more use cases of checking if a tracepoint is enabled in a header are
coming to fruition, a helper macro, tracepoint_enabled(), has been added to
check if a tracepoint is enabled or not, and can be used with minimal header
requirements (avoid "include hell"). Convert the page_ref logic over to the
new helper macro.

Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent afbe7973
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
#include <linux/page-flags.h> #include <linux/page-flags.h>
#include <linux/tracepoint-defs.h> #include <linux/tracepoint-defs.h>
extern struct tracepoint __tracepoint_page_ref_set; DECLARE_TRACEPOINT(page_ref_set);
extern struct tracepoint __tracepoint_page_ref_mod; DECLARE_TRACEPOINT(page_ref_mod);
extern struct tracepoint __tracepoint_page_ref_mod_and_test; DECLARE_TRACEPOINT(page_ref_mod_and_test);
extern struct tracepoint __tracepoint_page_ref_mod_and_return; DECLARE_TRACEPOINT(page_ref_mod_and_return);
extern struct tracepoint __tracepoint_page_ref_mod_unless; DECLARE_TRACEPOINT(page_ref_mod_unless);
extern struct tracepoint __tracepoint_page_ref_freeze; DECLARE_TRACEPOINT(page_ref_freeze);
extern struct tracepoint __tracepoint_page_ref_unfreeze; DECLARE_TRACEPOINT(page_ref_unfreeze);
#ifdef CONFIG_DEBUG_PAGE_REF #ifdef CONFIG_DEBUG_PAGE_REF
...@@ -24,7 +24,7 @@ extern struct tracepoint __tracepoint_page_ref_unfreeze; ...@@ -24,7 +24,7 @@ extern struct tracepoint __tracepoint_page_ref_unfreeze;
* *
* See trace_##name##_enabled(void) in include/linux/tracepoint.h * See trace_##name##_enabled(void) in include/linux/tracepoint.h
*/ */
#define page_ref_tracepoint_active(t) static_key_false(&(t).key) #define page_ref_tracepoint_active(t) tracepoint_enabled(t)
extern void __page_ref_set(struct page *page, int v); extern void __page_ref_set(struct page *page, int v);
extern void __page_ref_mod(struct page *page, int v); extern void __page_ref_mod(struct page *page, int v);
...@@ -75,7 +75,7 @@ static inline int page_count(struct page *page) ...@@ -75,7 +75,7 @@ static inline int page_count(struct page *page)
static inline void set_page_count(struct page *page, int v) static inline void set_page_count(struct page *page, int v)
{ {
atomic_set(&page->_refcount, v); atomic_set(&page->_refcount, v);
if (page_ref_tracepoint_active(__tracepoint_page_ref_set)) if (page_ref_tracepoint_active(page_ref_set))
__page_ref_set(page, v); __page_ref_set(page, v);
} }
...@@ -91,14 +91,14 @@ static inline void init_page_count(struct page *page) ...@@ -91,14 +91,14 @@ static inline void init_page_count(struct page *page)
static inline void page_ref_add(struct page *page, int nr) static inline void page_ref_add(struct page *page, int nr)
{ {
atomic_add(nr, &page->_refcount); atomic_add(nr, &page->_refcount);
if (page_ref_tracepoint_active(__tracepoint_page_ref_mod)) if (page_ref_tracepoint_active(page_ref_mod))
__page_ref_mod(page, nr); __page_ref_mod(page, nr);
} }
static inline void page_ref_sub(struct page *page, int nr) static inline void page_ref_sub(struct page *page, int nr)
{ {
atomic_sub(nr, &page->_refcount); atomic_sub(nr, &page->_refcount);
if (page_ref_tracepoint_active(__tracepoint_page_ref_mod)) if (page_ref_tracepoint_active(page_ref_mod))
__page_ref_mod(page, -nr); __page_ref_mod(page, -nr);
} }
...@@ -106,7 +106,7 @@ static inline int page_ref_sub_return(struct page *page, int nr) ...@@ -106,7 +106,7 @@ static inline int page_ref_sub_return(struct page *page, int nr)
{ {
int ret = atomic_sub_return(nr, &page->_refcount); int ret = atomic_sub_return(nr, &page->_refcount);
if (page_ref_tracepoint_active(__tracepoint_page_ref_mod_and_return)) if (page_ref_tracepoint_active(page_ref_mod_and_return))
__page_ref_mod_and_return(page, -nr, ret); __page_ref_mod_and_return(page, -nr, ret);
return ret; return ret;
} }
...@@ -114,14 +114,14 @@ static inline int page_ref_sub_return(struct page *page, int nr) ...@@ -114,14 +114,14 @@ static inline int page_ref_sub_return(struct page *page, int nr)
static inline void page_ref_inc(struct page *page) static inline void page_ref_inc(struct page *page)
{ {
atomic_inc(&page->_refcount); atomic_inc(&page->_refcount);
if (page_ref_tracepoint_active(__tracepoint_page_ref_mod)) if (page_ref_tracepoint_active(page_ref_mod))
__page_ref_mod(page, 1); __page_ref_mod(page, 1);
} }
static inline void page_ref_dec(struct page *page) static inline void page_ref_dec(struct page *page)
{ {
atomic_dec(&page->_refcount); atomic_dec(&page->_refcount);
if (page_ref_tracepoint_active(__tracepoint_page_ref_mod)) if (page_ref_tracepoint_active(page_ref_mod))
__page_ref_mod(page, -1); __page_ref_mod(page, -1);
} }
...@@ -129,7 +129,7 @@ static inline int page_ref_sub_and_test(struct page *page, int nr) ...@@ -129,7 +129,7 @@ static inline int page_ref_sub_and_test(struct page *page, int nr)
{ {
int ret = atomic_sub_and_test(nr, &page->_refcount); int ret = atomic_sub_and_test(nr, &page->_refcount);
if (page_ref_tracepoint_active(__tracepoint_page_ref_mod_and_test)) if (page_ref_tracepoint_active(page_ref_mod_and_test))
__page_ref_mod_and_test(page, -nr, ret); __page_ref_mod_and_test(page, -nr, ret);
return ret; return ret;
} }
...@@ -138,7 +138,7 @@ static inline int page_ref_inc_return(struct page *page) ...@@ -138,7 +138,7 @@ static inline int page_ref_inc_return(struct page *page)
{ {
int ret = atomic_inc_return(&page->_refcount); int ret = atomic_inc_return(&page->_refcount);
if (page_ref_tracepoint_active(__tracepoint_page_ref_mod_and_return)) if (page_ref_tracepoint_active(page_ref_mod_and_return))
__page_ref_mod_and_return(page, 1, ret); __page_ref_mod_and_return(page, 1, ret);
return ret; return ret;
} }
...@@ -147,7 +147,7 @@ static inline int page_ref_dec_and_test(struct page *page) ...@@ -147,7 +147,7 @@ static inline int page_ref_dec_and_test(struct page *page)
{ {
int ret = atomic_dec_and_test(&page->_refcount); int ret = atomic_dec_and_test(&page->_refcount);
if (page_ref_tracepoint_active(__tracepoint_page_ref_mod_and_test)) if (page_ref_tracepoint_active(page_ref_mod_and_test))
__page_ref_mod_and_test(page, -1, ret); __page_ref_mod_and_test(page, -1, ret);
return ret; return ret;
} }
...@@ -156,7 +156,7 @@ static inline int page_ref_dec_return(struct page *page) ...@@ -156,7 +156,7 @@ static inline int page_ref_dec_return(struct page *page)
{ {
int ret = atomic_dec_return(&page->_refcount); int ret = atomic_dec_return(&page->_refcount);
if (page_ref_tracepoint_active(__tracepoint_page_ref_mod_and_return)) if (page_ref_tracepoint_active(page_ref_mod_and_return))
__page_ref_mod_and_return(page, -1, ret); __page_ref_mod_and_return(page, -1, ret);
return ret; return ret;
} }
...@@ -165,7 +165,7 @@ static inline int page_ref_add_unless(struct page *page, int nr, int u) ...@@ -165,7 +165,7 @@ static inline int page_ref_add_unless(struct page *page, int nr, int u)
{ {
int ret = atomic_add_unless(&page->_refcount, nr, u); int ret = atomic_add_unless(&page->_refcount, nr, u);
if (page_ref_tracepoint_active(__tracepoint_page_ref_mod_unless)) if (page_ref_tracepoint_active(page_ref_mod_unless))
__page_ref_mod_unless(page, nr, ret); __page_ref_mod_unless(page, nr, ret);
return ret; return ret;
} }
...@@ -174,7 +174,7 @@ static inline int page_ref_freeze(struct page *page, int count) ...@@ -174,7 +174,7 @@ static inline int page_ref_freeze(struct page *page, int count)
{ {
int ret = likely(atomic_cmpxchg(&page->_refcount, count, 0) == count); int ret = likely(atomic_cmpxchg(&page->_refcount, count, 0) == count);
if (page_ref_tracepoint_active(__tracepoint_page_ref_freeze)) if (page_ref_tracepoint_active(page_ref_freeze))
__page_ref_freeze(page, count, ret); __page_ref_freeze(page, count, ret);
return ret; return ret;
} }
...@@ -185,7 +185,7 @@ static inline void page_ref_unfreeze(struct page *page, int count) ...@@ -185,7 +185,7 @@ static inline void page_ref_unfreeze(struct page *page, int count)
VM_BUG_ON(count == 0); VM_BUG_ON(count == 0);
atomic_set_release(&page->_refcount, count); atomic_set_release(&page->_refcount, count);
if (page_ref_tracepoint_active(__tracepoint_page_ref_unfreeze)) if (page_ref_tracepoint_active(page_ref_unfreeze))
__page_ref_unfreeze(page, count); __page_ref_unfreeze(page, count);
} }
......
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