From: Bob Liu <lliubbo@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: james.harper@bendigoit.com.au, ian.campbell@citrix.com,
andrew.cooper3@citrix.com, JBeulich@suse.com
Subject: [PATCH v3 11/15] tmem: cleanup: __tmem_alloc_page: drop unneed parameters
Date: Wed, 11 Dec 2013 16:50:40 +0800 [thread overview]
Message-ID: <1386751844-32387-12-git-send-email-bob.liu@oracle.com> (raw)
In-Reply-To: <1386751844-32387-1-git-send-email-bob.liu@oracle.com>
The two parameters of __tmem_alloc_page() can be reduced.
tmem_called_from_tmem() was also dropped by this patch.
Signed-off-by: Bob Liu <bob.liu@oracle.com>
---
xen/common/tmem.c | 13 +++++--------
xen/include/xen/tmem_xen.h | 11 +++++------
2 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/xen/common/tmem.c b/xen/common/tmem.c
index b904285..abc9053 100644
--- a/xen/common/tmem.c
+++ b/xen/common/tmem.c
@@ -244,7 +244,7 @@ static struct page_info *tmem_alloc_page(struct tmem_pool *pool)
if ( pool != NULL && is_persistent(pool) )
pfp = __tmem_alloc_page_thispool(pool->client->domain);
else
- pfp = __tmem_alloc_page(pool,0);
+ pfp = __tmem_alloc_page();
return pfp;
}
@@ -262,9 +262,8 @@ static noinline void *tmem_mempool_page_get(unsigned long size)
struct page_info *pi;
ASSERT(size == PAGE_SIZE);
- if ( (pi = __tmem_alloc_page(NULL,0)) == NULL )
+ if ( (pi = __tmem_alloc_page()) == NULL )
return NULL;
- ASSERT(IS_VALID_PAGE(pi));
return page_to_virt(pi);
}
@@ -2425,7 +2424,6 @@ void tmem_freeze_all(unsigned char key)
void *tmem_relinquish_pages(unsigned int order, unsigned int memflags)
{
struct page_info *pfp;
- unsigned long evicts_per_relinq = 0;
int max_evictions = 10;
if (!tmem_enabled() || !tmem_freeable_pages())
@@ -2439,14 +2437,13 @@ void *tmem_relinquish_pages(unsigned int order, unsigned int memflags)
return NULL;
}
- if ( tmem_called_from_tmem(memflags) )
+ if ( memflags & MEMF_tmem )
read_lock(&tmem_rwlock);
- while ( (pfp = __tmem_alloc_page(NULL,1)) == NULL )
+ while ( (pfp = tmem_page_list_get()) == NULL )
{
if ( (max_evictions-- <= 0) || !tmem_evict())
break;
- evicts_per_relinq++;
}
if ( pfp != NULL )
{
@@ -2454,7 +2451,7 @@ void *tmem_relinquish_pages(unsigned int order, unsigned int memflags)
scrub_one_page(pfp);
}
- if ( tmem_called_from_tmem(memflags) )
+ if ( memflags & MEMF_tmem )
read_unlock(&tmem_rwlock);
return pfp;
diff --git a/xen/include/xen/tmem_xen.h b/xen/include/xen/tmem_xen.h
index 79b0730..101c5b6 100644
--- a/xen/include/xen/tmem_xen.h
+++ b/xen/include/xen/tmem_xen.h
@@ -144,15 +144,16 @@ static inline void __tmem_free_page_thispool(struct page_info *pi)
/*
* Memory allocation for ephemeral (non-persistent) data
*/
-static inline struct page_info *__tmem_alloc_page(void *pool, int no_heap)
+static inline struct page_info *__tmem_alloc_page(void)
{
struct page_info *pi = tmem_page_list_get();
- if ( pi == NULL && !no_heap )
+ if ( pi == NULL)
pi = alloc_domheap_pages(0,0,MEMF_tmem);
- ASSERT((pi == NULL) || IS_VALID_PAGE(pi));
- if ( pi != NULL && !no_heap )
+
+ if ( pi )
atomic_inc(&freeable_page_count);
+ ASSERT((pi == NULL) || IS_VALID_PAGE(pi));
return pi;
}
@@ -168,8 +169,6 @@ static inline unsigned long tmem_free_mb(void)
return (tmem_page_list_pages + total_free_pages()) >> (20 - PAGE_SHIFT);
}
-#define tmem_called_from_tmem(_memflags) (_memflags & MEMF_tmem)
-
/* "Client" (==domain) abstraction */
struct client;
--
1.7.10.4
next prev parent reply other threads:[~2013-12-11 8:54 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-11 8:50 [PATCH v3 00/15] tmem: continue to cleanup tmem Bob Liu
2013-12-11 8:50 ` [PATCH v3 01/15] tmem: cleanup: drop unused sub command Bob Liu
2013-12-11 8:50 ` [PATCH v3 02/15] tmem: cleanup: drop some debug code Bob Liu
2013-12-11 8:50 ` [PATCH v3 03/15] tmem: cleanup: drop useless function 'tmem_copy_page' Bob Liu
2013-12-11 8:50 ` [PATCH v3 04/15] tmem: cleanup: drop useless parameters from put/get page Bob Liu
2013-12-11 8:50 ` [PATCH v3 05/15] tmem: cleanup: reorg function do_tmem_put() Bob Liu
2013-12-11 8:50 ` [PATCH v3 06/15] tmem: drop unneeded is_ephemeral() and is_private() Bob Liu
2013-12-11 8:50 ` [PATCH v3 07/15] tmem: cleanup: rm useless EXPORT/FORWARD define Bob Liu
2013-12-11 8:50 ` [PATCH v3 08/15] tmem: cleanup: drop runtime statistics Bob Liu
2013-12-11 8:50 ` [PATCH v3 09/15] tmem: cleanup: drop tmem_lock_all Bob Liu
2013-12-11 10:45 ` Andrew Cooper
2013-12-11 13:11 ` Bob Liu
2013-12-11 22:01 ` Konrad Rzeszutek Wilk
2013-12-11 8:50 ` [PATCH v3 10/15] tmem: cleanup: refactor the alloc/free path Bob Liu
2013-12-11 8:50 ` Bob Liu [this message]
2013-12-11 8:50 ` [PATCH v3 12/15] tmem: cleanup: drop useless functions from head file Bob Liu
2013-12-11 8:50 ` [PATCH v3 13/15] tmem: refator function tmem_ensure_avail_pages() Bob Liu
2013-12-11 8:50 ` [PATCH v3 14/15] tmem: cleanup: rename tmem_relinquish_npages() Bob Liu
2013-12-11 8:50 ` [PATCH v3 15/15] tmem: cleanup: rm unused tmem_freeze_all() Bob Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386751844-32387-12-git-send-email-bob.liu@oracle.com \
--to=lliubbo@gmail.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=james.harper@bendigoit.com.au \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).