Thread (21 messages) 21 messages, 8 authors, 2015-12-10

Re: [PATCH 1/2] mm: introduce page reference manipulation functions

From: Kirill A. Shutemov <hidden>
Date: 2015-11-09 11:45:46
Also in: linux-mm, lkml

On Mon, Nov 09, 2015 at 05:00:32PM +0900, Joonsoo Kim wrote:
2015-11-09 16:53 GMT+09:00 Sergey Senozhatsky
[off-list ref]:
quoted
Hi,

On (11/09/15 16:23), Joonsoo Kim wrote:
[..]
quoted
+static inline int page_count(struct page *page)
+{
+     return atomic_read(&compound_head(page)->_count);
+}
+
+static inline void set_page_count(struct page *page, int v)
+{
+     atomic_set(&page->_count, v);
+}
+
+/*
+ * Setup the page count before being freed into the page allocator for
+ * the first time (boot or memory hotplug)
+ */
+static inline void init_page_count(struct page *page)
+{
+     set_page_count(page, 1);
+}
+
+static inline void page_ref_add(struct page *page, int nr)
+{
+     atomic_add(nr, &page->_count);
+}
Since page_ref_FOO wrappers operate with page->_count and there
are already page_count()/set_page_count()/etc. may be name new
wrappers in page_count_FOO() manner?
Hello,

I used that page_count_ before but change my mind.
I think that ref is more relevant to this operation.
Perhaps, it'd be better to change page_count()/set_page_count()
to page_ref()/set_page_ref().
What about get_page() vs. page_cache_get() and put_page() vs.
page_cache_release()? Two different helpers for the same thing is annyoing
me for some time (plus PAGE_SIZE vs. PAGE_CACHE_SIZE, etc.).

If you want coherent API you might want to get them consitent too.
FYI, some functions such as page_(un)freeze_refs uses ref. :)
-- 
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help