Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1265431

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

From Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] mm: introduce page reference manipulation functions
Date 2015-11-09 09:00 +0100
Message-ID <qsPwR-3v4-3@gated-at.bofh.it> (permalink)
References <qsP3Q-3kT-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi,

On (11/09/15 16:23), Joonsoo Kim wrote:
[..]
> +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?


> +static inline void page_ref_sub(struct page *page, int nr)

for example, page_count_sub(), etc.

	-ss

> +{
> +	atomic_sub(nr, &page->_count);
> +}
> +
> +static inline void page_ref_inc(struct page *page)
> +{
> +	atomic_inc(&page->_count);
> +}
> +
> +static inline void page_ref_dec(struct page *page)
> +{
> +	atomic_dec(&page->_count);
> +}
> +
> +static inline int page_ref_sub_and_test(struct page *page, int nr)
> +{
> +	return atomic_sub_and_test(nr, &page->_count);
> +}
> +
> +static inline int page_ref_dec_and_test(struct page *page)
> +{
> +	return atomic_dec_and_test(&page->_count);
> +}
> +
> +static inline int page_ref_dec_return(struct page *page)
> +{
> +	return atomic_dec_return(&page->_count);
> +}
> +
> +static inline int page_ref_add_unless(struct page *page, int nr, int u)
> +{
> +	return atomic_add_unless(&page->_count, nr, u);
> +}
> +
> +static inline int page_ref_freeze(struct page *page, int count)
> +{
> +	return likely(atomic_cmpxchg(&page->_count, count, 0) == count);
> +}
> +
> +static inline void page_ref_unfreeze(struct page *page, int count)
> +{
> +	VM_BUG_ON_PAGE(page_count(page) != 0, page);
> +	VM_BUG_ON(count == 0);
> +
> +	atomic_set(&page->_count, count);
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] mm: introduce page reference manipulation functions Joonsoo Kim <js1304@gmail.com> - 2015-11-09 08:30 +0100
  [PATCH 2/2] mm/page_ref: add tracepoint to track down page reference manipulation Joonsoo Kim <js1304@gmail.com> - 2015-11-09 08:30 +0100
    Re: [PATCH 2/2] mm/page_ref: add tracepoint to track down page reference manipulation Michal Nazarewicz <mina86@mina86.com> - 2015-11-10 17:10 +0100
  Re: [PATCH 1/2] mm: introduce page reference manipulation functions Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-11-09 09:00 +0100
    Re: [PATCH 1/2] mm: introduce page reference manipulation functions Joonsoo Kim <js1304@gmail.com> - 2015-11-09 09:10 +0100
      Re: [PATCH 1/2] mm: introduce page reference manipulation functions "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-11-09 12:50 +0100
        Re: [PATCH 1/2] mm: introduce page reference manipulation functions Joonsoo Kim <iamjoonsoo.kim@lge.com> - 2015-11-10 01:30 +0100
  Re: [PATCH 1/2] mm: introduce page reference manipulation functions Michal Nazarewicz <mina86@mina86.com> - 2015-11-10 17:00 +0100

csiph-web