From: Juergen Gross <jgross@suse.com>
To: Stefano Stabellini <sstabellini@kernel.org>, boris.ostrovsky@oracle.com
Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
Stefano Stabellini <stefano@aporeto.com>
Subject: Re: [PATCH v2 1/2] pvcalls-front: introduce a per sock_mapping refcount
Date: Wed, 14 Feb 2018 14:46:11 +0100 [thread overview]
Message-ID: <5e34f4f5-faa5-1983-7e7e-a71d4aec80ca@suse.com> (raw)
In-Reply-To: <1518488027-22386-1-git-send-email-sstabellini@kernel.org>
On 13/02/18 03:13, Stefano Stabellini wrote:
> Introduce a per sock_mapping refcount, in addition to the existing
> global refcount. Thanks to the sock_mapping refcount, we can safely wait
> for it to be 1 in pvcalls_front_release before freeing an active socket,
> instead of waiting for the global refcount to be 1.
>
> Signed-off-by: Stefano Stabellini <stefano@aporeto.com>
>
> ---
> Changes in v2:
> - fix code style
> - nicer checks in pvcalls_front_release
> - fix check in pvcalls_enter_sock
> ---
> drivers/xen/pvcalls-front.c | 193 +++++++++++++++++++-------------------------
> 1 file changed, 81 insertions(+), 112 deletions(-)
>
> diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c
> index 4c789e6..163bf8c 100644
> --- a/drivers/xen/pvcalls-front.c
> +++ b/drivers/xen/pvcalls-front.c
> @@ -60,6 +60,7 @@ struct sock_mapping {
> bool active_socket;
> struct list_head list;
> struct socket *sock;
> + atomic_t refcount;
> union {
> struct {
> int irq;
> @@ -93,6 +94,34 @@ struct sock_mapping {
> };
> };
>
> +static inline struct sock_mapping *pvcalls_enter_sock(struct socket *sock)
> +{
> + struct sock_mapping *map = NULL;
Pointless initializer.
> +
> + if (!pvcalls_front_dev ||
> + dev_get_drvdata(&pvcalls_front_dev->dev) == NULL)
> + return ERR_PTR(-ENOTCONN);
> +
> + pvcalls_enter();
> + map = (struct sock_mapping *)sock->sk->sk_send_head;
> + if (map == NULL) {
> + pvcalls_exit()
> + return ERR_PTR(-ENOTSOCK);
> + }
Sorry for noticing this only now: any reason you don't call
pvcalls_enter() only here instead? This would remove the need of
calling pvcalls_exit() if map == NULL.
I can't see pvcalls_enter() protecting sock->sk->sk_send_head in any
way.
> +
> + atomic_inc(&map->refcount);
> + return map;
> +}
> +
> +static inline void pvcalls_exit_sock(struct socket *sock)
> +{
> + struct sock_mapping *map = NULL;
Pointless initializer again.
Juergen
next prev parent reply other threads:[~2018-02-14 13:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 2:13 [PATCH v2] pvcalls-front improvements Stefano Stabellini
2018-02-13 2:13 ` [PATCH v2 1/2] pvcalls-front: introduce a per sock_mapping refcount Stefano Stabellini
2018-02-13 2:13 ` [PATCH v2 2/2] pvcalls-front: wait for other operations to return when release passive sockets Stefano Stabellini
2018-02-14 13:46 ` Juergen Gross [this message]
2018-02-14 18:13 ` [PATCH v2 1/2] pvcalls-front: introduce a per sock_mapping refcount Stefano Stabellini
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=5e34f4f5-faa5-1983-7e7e-a71d4aec80ca@suse.com \
--to=jgross@suse.com \
--cc=boris.ostrovsky@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sstabellini@kernel.org \
--cc=stefano@aporeto.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®