All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@ieee.org>
To: Ilya Dryomov <ilya.dryomov@inktank.com>, ceph-devel@vger.kernel.org
Subject: Re: [PATCH 03/14] libceph: move and add dout()s to ceph_msg_{get,put}()
Date: Mon, 30 Jun 2014 07:29:09 -0500	[thread overview]
Message-ID: <53B15815.7050700@ieee.org> (raw)
In-Reply-To: <1403716607-13535-4-git-send-email-ilya.dryomov@inktank.com>

On 06/25/2014 12:16 PM, Ilya Dryomov wrote:
> Add dout()s to ceph_msg_{get,put}().  Also move them to .c and turn
> kref release callback into a static function.
> 
> Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>

This is all very good.

I have one suggestion though, below, but regardless:

Reviewed-by: Alex Elder <elder@linaro.org>


> ---
>  include/linux/ceph/messenger.h |   14 ++------------
>  net/ceph/messenger.c           |   31 ++++++++++++++++++++++---------
>  2 files changed, 24 insertions(+), 21 deletions(-)
> 
> diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
> index d21f2dba0731..40ae58e3e9db 100644
> --- a/include/linux/ceph/messenger.h
> +++ b/include/linux/ceph/messenger.h
> @@ -285,19 +285,9 @@ extern void ceph_msg_data_add_bio(struct ceph_msg *msg, struct bio *bio,
>  
>  extern struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
>  				     bool can_fail);
> -extern void ceph_msg_kfree(struct ceph_msg *m);
>  
> -
> -static inline struct ceph_msg *ceph_msg_get(struct ceph_msg *msg)
> -{
> -	kref_get(&msg->kref);
> -	return msg;
> -}
> -extern void ceph_msg_last_put(struct kref *kref);
> -static inline void ceph_msg_put(struct ceph_msg *msg)
> -{
> -	kref_put(&msg->kref, ceph_msg_last_put);
> -}
> +extern struct ceph_msg *ceph_msg_get(struct ceph_msg *msg);
> +extern void ceph_msg_put(struct ceph_msg *msg);
>  
>  extern void ceph_msg_dump(struct ceph_msg *msg);
>  
> diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
> index 1948d592aa54..8bffa5b90fef 100644
> --- a/net/ceph/messenger.c
> +++ b/net/ceph/messenger.c
> @@ -3269,24 +3269,21 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
>  /*
>   * Free a generically kmalloc'd message.
>   */
> -void ceph_msg_kfree(struct ceph_msg *m)
> +static void ceph_msg_free(struct ceph_msg *m)
>  {
> -	dout("msg_kfree %p\n", m);
> +	dout("%s %p\n", __func__, m);
>  	ceph_kvfree(m->front.iov_base);
>  	kmem_cache_free(ceph_msg_cache, m);
>  }
>  
> -/*
> - * Drop a msg ref.  Destroy as needed.
> - */
> -void ceph_msg_last_put(struct kref *kref)
> +static void ceph_msg_release(struct kref *kref)
>  {
>  	struct ceph_msg *m = container_of(kref, struct ceph_msg, kref);
>  	LIST_HEAD(data);
>  	struct list_head *links;
>  	struct list_head *next;
>  
> -	dout("ceph_msg_put last one on %p\n", m);
> +	dout("%s %p\n", __func__, m);
>  	WARN_ON(!list_empty(&m->list_head));
>  
>  	/* drop middle, data, if any */
> @@ -3308,9 +3305,25 @@ void ceph_msg_last_put(struct kref *kref)
>  	if (m->pool)
>  		ceph_msgpool_put(m->pool, m);
>  	else
> -		ceph_msg_kfree(m);
> +		ceph_msg_free(m);
> +}
> +
> +struct ceph_msg *ceph_msg_get(struct ceph_msg *msg)
> +{
> +	dout("%s %p (was %d)\n", __func__, msg,
> +	     atomic_read(&msg->kref.refcount));
> +	kref_get(&msg->kref);

I suggest you do the dout() *after* you call kref_get().
I'm sure it doesn't matter in practice here, but my
reasoning is that you get the reference immediately, and
you'll have the reference when reading the refcount value.
It also  makes the dout() calls here and in ceph_msg_put()
end up getting symmetrically wrapped by the get kref
get and put.  (You have a race reading the updated
refcount value either way, but it's debug code.)

> +	return msg;
> +}
> +EXPORT_SYMBOL(ceph_msg_get);
> +
> +void ceph_msg_put(struct ceph_msg *msg)
> +{
> +	dout("%s %p (was %d)\n", __func__, msg,
> +	     atomic_read(&msg->kref.refcount));
> +	kref_put(&msg->kref, ceph_msg_release);
>  }
> -EXPORT_SYMBOL(ceph_msg_last_put);
> +EXPORT_SYMBOL(ceph_msg_put);
>  
>  void ceph_msg_dump(struct ceph_msg *msg)
>  {
> 


  reply	other threads:[~2014-06-30 12:29 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-25 17:16 [PATCH 00/14] rbd: #6628 fixes (wip-remove-osd-6628) Ilya Dryomov
2014-06-25 17:16 ` [PATCH 01/14] libceph: rename ceph_osd_request::r_linger_osd to r_linger_osd_item Ilya Dryomov
2014-06-30 12:16   ` Alex Elder
2014-06-25 17:16 ` [PATCH 02/14] libceph: add maybe_move_osd_to_lru() and switch to it Ilya Dryomov
2014-06-30 12:17   ` Alex Elder
2014-06-25 17:16 ` [PATCH 03/14] libceph: move and add dout()s to ceph_msg_{get,put}() Ilya Dryomov
2014-06-30 12:29   ` Alex Elder [this message]
2014-07-08 11:12     ` Ilya Dryomov
2014-06-25 17:16 ` [PATCH 04/14] libceph: move and add dout()s to ceph_osdc_request_{get,put}() Ilya Dryomov
2014-06-30 12:32   ` Alex Elder
2014-06-25 17:16 ` [PATCH 05/14] libceph: harden ceph_osdc_request_release() a bit Ilya Dryomov
2014-06-30 12:36   ` Alex Elder
2014-06-25 17:16 ` [PATCH 06/14] libceph: assert both regular and lingering lists in __remove_osd() Ilya Dryomov
2014-06-30 12:37   ` Alex Elder
2014-06-25 17:16 ` [PATCH 07/14] libceph: unregister only registered linger requests Ilya Dryomov
2014-06-30 13:05   ` Alex Elder
2014-06-30 13:50   ` Alex Elder
2014-06-30 14:21     ` Ilya Dryomov
2014-06-25 17:16 ` [PATCH 08/14] libceph: fix linger request check in __unregister_request() Ilya Dryomov
2014-06-30 13:07   ` Alex Elder
2014-06-25 17:16 ` [PATCH 09/14] libceph: introduce ceph_osdc_cancel_request() Ilya Dryomov
2014-06-30 13:39   ` Alex Elder
2014-06-30 14:34     ` Ilya Dryomov
2014-07-07 13:47       ` Alex Elder
2014-07-08 11:15         ` Ilya Dryomov
2014-07-08 12:58           ` Alex Elder
2014-06-25 17:16 ` [PATCH 10/14] rbd: rbd_obj_request_wait() should cancel the request if interrupted Ilya Dryomov
2014-07-07 16:55   ` Alex Elder
2014-07-08 11:18     ` Ilya Dryomov
2014-07-08 12:17       ` Alex Elder
2014-06-25 17:16 ` [PATCH 11/14] rbd: add rbd_obj_watch_request_helper() helper Ilya Dryomov
2014-07-07 22:36   ` Alex Elder
2014-07-08 11:18     ` Ilya Dryomov
2014-06-25 17:16 ` [PATCH 12/14] rbd: use " Ilya Dryomov
2014-07-07 22:36   ` Alex Elder
2014-06-25 17:16 ` [PATCH 13/14] libceph: nuke ceph_osdc_unregister_linger_request() Ilya Dryomov
2014-07-07 22:36   ` Alex Elder
2014-06-25 17:16 ` [PATCH 14/14] libceph: drop osd ref when canceling con work Ilya Dryomov
2014-07-07 22:38   ` Alex Elder
2014-07-08 11:22     ` Ilya Dryomov

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=53B15815.7050700@ieee.org \
    --to=elder@ieee.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=ilya.dryomov@inktank.com \
    /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.