From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: xen-devel@lists.xenproject.org, Bob Liu <lliubbo@gmail.com>,
keir@xen.org, ian.campbell@citrix.com, JBeulich@suse.com
Subject: Re: [PATCH 14/16] tmem: cleanup: drop useless functions from head file
Date: Wed, 27 Nov 2013 14:59:56 +0000 [thread overview]
Message-ID: <529608EC.1020402@citrix.com> (raw)
In-Reply-To: <20131127145227.GK4430@pegasus.dumpdata.com>
On 27/11/13 14:52, Konrad Rzeszutek Wilk wrote:
> On Wed, Nov 27, 2013 at 02:38:07PM +0000, Andrew Cooper wrote:
>> On 20/11/13 08:46, Bob Liu wrote:
>>> They are several one line functions in tmem_xen.h which are useless, this patch
>>> embeded them into tmem.c directly.
>>>
>>> Signed-off-by: Bob Liu <bob.liu@oracle.com>
>>> ---
>>> xen/common/tmem.c | 22 +++++++++++-----------
>>> xen/include/xen/tmem_xen.h | 27 ---------------------------
>>> 2 files changed, 11 insertions(+), 38 deletions(-)
>>>
>>> diff --git a/xen/common/tmem.c b/xen/common/tmem.c
>>> index bf0fa1b..2e807d4 100644
>>> --- a/xen/common/tmem.c
>>> +++ b/xen/common/tmem.c
>>> @@ -1212,7 +1212,7 @@ obj_unlock:
>>>
>>> static int tmem_evict(void)
>>> {
>>> - struct client *client = tmem_client_from_current();
>>> + struct client *client = (struct client *)current->domain->tmem;
>> domain->tmem is a void pointer. Therefore this explicit cast to (struct
>> client *) is redundant.
>>
>> I would however, suggest updating struct domain to have a struct client
>> pointer rather than a void pointer.
> That might bring more of #include in the file. That was I believe the initial
> reason for not doing that. But perhaps one can also just do:
>
> extern struct client;
>
> in the header that has domain struct (I always forget the name of it)
> and that would make this neater.
just "struct client;" is the correct way to "extern" a struct in C.
I might also suggest a rename to tmem_client ?
~Andrew
>
>> ~Andrew
>>
>>> struct tmem_page_descriptor *pgp = NULL, *pgp2, *pgp_del;
>>> struct tmem_object_root *obj;
>>> struct tmem_pool *pool;
>>> @@ -1625,7 +1625,7 @@ static int do_tmem_get(struct tmem_pool *pool, struct oid *oidp, uint32_t index,
>>> list_del(&pgp->us.client_eph_pages);
>>> list_add_tail(&pgp->us.client_eph_pages,&client->ephemeral_page_list);
>>> spin_unlock(&eph_lists_spinlock);
>>> - obj->last_client = tmem_get_cli_id_from_current();
>>> + obj->last_client = current->domain->domain_id;
>>> }
>>> }
>>> if ( obj != NULL )
>>> @@ -1694,7 +1694,7 @@ out:
>>>
>>> static int do_tmem_destroy_pool(uint32_t pool_id)
>>> {
>>> - struct client *client = tmem_client_from_current();
>>> + struct client *client = (struct client *)current->domain->tmem;
>>> struct tmem_pool *pool;
>>>
>>> if ( client->pools == NULL )
>>> @@ -1725,7 +1725,7 @@ static int do_tmem_new_pool(domid_t this_cli_id,
>>> int i;
>>>
>>> if ( this_cli_id == TMEM_CLI_ID_NULL )
>>> - cli_id = tmem_get_cli_id_from_current();
>>> + cli_id = current->domain->domain_id;
>>> else
>>> cli_id = this_cli_id;
>>> tmem_client_info("tmem: allocating %s-%s tmem pool for %s=%d...",
>>> @@ -1766,7 +1766,7 @@ static int do_tmem_new_pool(domid_t this_cli_id,
>>> }
>>> else
>>> {
>>> - client = tmem_client_from_current();
>>> + client = (struct client *)current->domain->tmem;
>>> ASSERT(client != NULL);
>>> for ( d_poolid = 0; d_poolid < MAX_POOLS_PER_DOMAIN; d_poolid++ )
>>> if ( client->pools[d_poolid] == NULL )
>>> @@ -2206,7 +2206,7 @@ static int do_tmem_control(struct tmem_op *op)
>>> uint32_t subop = op->u.ctrl.subop;
>>> struct oid *oidp = (struct oid *)(&op->u.ctrl.oid[0]);
>>>
>>> - if (!tmem_current_is_privileged())
>>> + if ( xsm_tmem_control(XSM_PRIV) )
>>> return -EPERM;
>>>
>>> switch(subop)
>>> @@ -2278,7 +2278,7 @@ static int do_tmem_control(struct tmem_op *op)
>>> long do_tmem_op(tmem_cli_op_t uops)
>>> {
>>> struct tmem_op op;
>>> - struct client *client = tmem_client_from_current();
>>> + struct client *client = (struct client *)current->domain->tmem;
>>> struct tmem_pool *pool = NULL;
>>> struct oid *oidp;
>>> int rc = 0;
>>> @@ -2290,10 +2290,10 @@ long do_tmem_op(tmem_cli_op_t uops)
>>> if ( !tmem_initialized )
>>> return -ENODEV;
>>>
>>> - if ( !tmem_current_permitted() )
>>> + if ( xsm_tmem_op(XSM_HOOK) )
>>> return -EPERM;
>>>
>>> - if ( client != NULL && tmem_client_is_dying(client) )
>>> + if ( client != NULL && client->domain->is_dying )
>>> return -ENODEV;
>>>
>>> if ( unlikely(tmem_get_tmemop_from_client(&op, uops) != 0) )
>>> @@ -2328,7 +2328,7 @@ long do_tmem_op(tmem_cli_op_t uops)
>>> {
>>> write_lock(&tmem_rwlock);
>>> write_lock_set = 1;
>>> - if ( (client = client_create(tmem_get_cli_id_from_current())) == NULL )
>>> + if ( (client = client_create(current->domain->domain_id)) == NULL )
>>> {
>>> tmem_client_err("tmem: can't create tmem structure for %s\n",
>>> tmem_client_str);
>>> @@ -2417,7 +2417,7 @@ void tmem_destroy(void *v)
>>> if ( client == NULL )
>>> return;
>>>
>>> - if ( !tmem_client_is_dying(client) )
>>> + if ( !client->domain->is_dying )
>>> {
>>> printk("tmem: tmem_destroy can only destroy dying client\n");
>>> return;
>>> diff --git a/xen/include/xen/tmem_xen.h b/xen/include/xen/tmem_xen.h
>>> index c4b9f5a..bf3be62 100644
>>> --- a/xen/include/xen/tmem_xen.h
>>> +++ b/xen/include/xen/tmem_xen.h
>>> @@ -183,33 +183,6 @@ static inline struct client *tmem_client_from_cli_id(domid_t cli_id)
>>> return c;
>>> }
>>>
>>> -static inline struct client *tmem_client_from_current(void)
>>> -{
>>> - return (struct client *)(current->domain->tmem);
>>> -}
>>> -
>>> -#define tmem_client_is_dying(_client) (!!_client->domain->is_dying)
>>> -
>>> -static inline domid_t tmem_get_cli_id_from_current(void)
>>> -{
>>> - return current->domain->domain_id;
>>> -}
>>> -
>>> -static inline struct domain *tmem_get_cli_ptr_from_current(void)
>>> -{
>>> - return current->domain;
>>> -}
>>> -
>>> -static inline bool_t tmem_current_permitted(void)
>>> -{
>>> - return !xsm_tmem_op(XSM_HOOK);
>>> -}
>>> -
>>> -static inline bool_t tmem_current_is_privileged(void)
>>> -{
>>> - return !xsm_tmem_control(XSM_PRIV);
>>> -}
>>> -
>>> static inline uint8_t tmem_get_first_byte(struct page_info *pfp)
>>> {
>>> void *p = __map_domain_page(pfp);
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xen.org
>> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-11-27 15:00 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-20 8:46 [PATCH 01/16] tmem: cleanup: drop some debug code Bob Liu
2013-11-20 8:46 ` [PATCH 02/16] tmem: cleanup: drop useless function 'tmem_copy_page' Bob Liu
2013-11-20 8:46 ` [PATCH 03/16] tmem: cleanup: rm unused tmem_op Bob Liu
2013-11-22 17:38 ` Konrad Rzeszutek Wilk
2013-11-25 9:43 ` Jan Beulich
2013-11-25 9:52 ` Ian Campbell
2013-11-25 9:58 ` Jan Beulich
2013-11-25 16:37 ` Konrad Rzeszutek Wilk
2013-11-25 16:40 ` Ian Campbell
2013-11-25 17:09 ` Konrad Rzeszutek Wilk
2013-11-25 17:12 ` Ian Campbell
2013-11-25 19:56 ` Konrad Rzeszutek Wilk
2013-11-26 8:56 ` Bob Liu
2013-11-20 8:46 ` [PATCH 04/16] tmem: cleanup: rm unneeded parameters from put path Bob Liu
2013-11-22 17:54 ` Konrad Rzeszutek Wilk
2013-11-26 8:22 ` Bob Liu
2013-11-20 8:46 ` [PATCH 05/16] tmem: cleanup: rm unneeded parameters from get path Bob Liu
2013-11-22 17:55 ` Konrad Rzeszutek Wilk
2013-11-20 8:46 ` [PATCH 06/16] tmem: cleanup: reorg do_tmem_put() Bob Liu
2013-11-22 18:04 ` Konrad Rzeszutek Wilk
2013-11-20 8:46 ` [PATCH 07/16] tmem: drop unneeded is_ephemeral() and is_private() Bob Liu
2013-11-20 8:46 ` [PATCH 08/16] tmem: cleanup: rm useless EXPORT/FORWARD define Bob Liu
2013-11-22 18:05 ` Konrad Rzeszutek Wilk
2013-11-20 8:46 ` [PATCH 09/16] tmem: cleanup: drop tmemc_list() temporary Bob Liu
2013-11-22 18:07 ` Konrad Rzeszutek Wilk
2013-11-26 8:28 ` Bob Liu
2013-11-22 21:00 ` Konrad Rzeszutek Wilk
2013-11-20 8:46 ` [PATCH 10/16] tmem: cleanup: drop runtime statistics Bob Liu
2013-11-22 18:08 ` Konrad Rzeszutek Wilk
2013-11-20 8:46 ` [PATCH 11/16] tmem: cleanup: drop tmem_lock_all Bob Liu
2013-11-20 8:46 ` [PATCH 12/16] tmem: cleanup: refactor the alloc/free path Bob Liu
2013-11-20 8:46 ` [PATCH 13/16] tmem: cleanup: __tmem_alloc_page: drop unneed parameters Bob Liu
2013-11-22 18:17 ` Konrad Rzeszutek Wilk
2013-11-26 8:41 ` Bob Liu
2013-11-26 17:38 ` Konrad Rzeszutek Wilk
2013-11-20 8:46 ` [PATCH 14/16] tmem: cleanup: drop useless functions from head file Bob Liu
2013-11-27 14:38 ` Andrew Cooper
2013-11-27 14:52 ` Konrad Rzeszutek Wilk
2013-11-27 14:59 ` Andrew Cooper [this message]
2013-11-27 15:55 ` Jan Beulich
2013-11-20 8:46 ` [PATCH 15/16] tmem: refator function tmem_ensure_avail_pages() Bob Liu
2013-11-22 18:22 ` Konrad Rzeszutek Wilk
2013-11-20 8:46 ` [PATCH 16/16] tmem: cleanup: rename tmem_relinquish_npages() Bob Liu
2013-11-20 9:08 ` [PATCH 01/16] tmem: cleanup: drop some debug code Jan Beulich
2013-11-20 9:19 ` Bob Liu
2013-11-20 9:25 ` Jan Beulich
2013-11-20 13:51 ` Konrad Rzeszutek Wilk
2013-11-20 14:21 ` Jan Beulich
2013-11-20 18:46 ` Konrad Rzeszutek Wilk
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=529608EC.1020402@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=ian.campbell@citrix.com \
--cc=keir@xen.org \
--cc=konrad.wilk@oracle.com \
--cc=lliubbo@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.