diff mbox

[1/1] mm/page_ref: introduce page_ref_inc_return

Message ID 1466419093-114348-2-git-send-email-borntraeger@de.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christian Borntraeger June 20, 2016, 10:38 a.m. UTC
From: David Hildenbrand <dahi@linux.vnet.ibm.com>

Let's introduce that helper.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 include/linux/page_ref.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Andrew Morton June 20, 2016, 11:11 p.m. UTC | #1
On Mon, 20 Jun 2016 12:38:13 +0200 Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> From: David Hildenbrand <dahi@linux.vnet.ibm.com>
> 
> Let's introduce that helper.
> 
> ...
>
> +static inline int page_ref_inc_return(struct page *page)
> +{
> +	int ret = atomic_inc_return(&page->_refcount);
> +
> +	if (page_ref_tracepoint_active(__tracepoint_page_ref_mod_and_return))
> +		__page_ref_mod_and_return(page, 1, ret);
> +	return ret;
> +}

Acked-by: Andrew Morton <akpm@linux-foundation.org>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/page_ref.h b/include/linux/page_ref.h
index 8b5e0a9..610e132 100644
--- a/include/linux/page_ref.h
+++ b/include/linux/page_ref.h
@@ -124,6 +124,15 @@  static inline int page_ref_sub_and_test(struct page *page, int nr)
 	return ret;
 }
 
+static inline int page_ref_inc_return(struct page *page)
+{
+	int ret = atomic_inc_return(&page->_refcount);
+
+	if (page_ref_tracepoint_active(__tracepoint_page_ref_mod_and_return))
+		__page_ref_mod_and_return(page, 1, ret);
+	return ret;
+}
+
 static inline int page_ref_dec_and_test(struct page *page)
 {
 	int ret = atomic_dec_and_test(&page->_refcount);