All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Egger <Christoph.Egger@amd.com>
To: xen-devel@lists.xensource.com
Cc: Ian Campbell <ian.campbell@citrix.com>
Subject: Re: [PATCH] libxc: free thread specific hypercall buffer on xc_interface_close
Date: Wed, 18 Aug 2010 18:04:56 +0200	[thread overview]
Message-ID: <201008181804.56934.Christoph.Egger@amd.com> (raw)
In-Reply-To: <b1f4b4be1f94c0007794.1282143667@localhost.localdomain>


This patch prevents me from starting a guest until
the outstanding issue - namely why is hcall_buf_prep() never called -
is solved.

Christoph



On Wednesday 18 August 2010 17:01:07 Ian Campbell wrote:
> # HG changeset patch
> # User Ian Campbell <ian.campbell@citrix.com>
> # Date 1282143629 -3600
> # Node ID b1f4b4be1f94c0007794f86abd019f5c2629c59b
> # Parent  ddbd38da07397dca4760fb687551c3f6f9134700
> libxc: free thread specific hypercall buffer on xc_interface_close
>
> The per-thread hypercall buffer is usually cleaned up on pthread_exit
> by the destructor passed to pthread_key_create. However if the calling
> application is not threaded then the destructor is never called.
>
> This frees the data for the current thread only but that is OK since
> any other threads will be cleaned up by the destructor.
>
> Changed since v1:
>  * Ensure hcall_buf_pkey is initialised before use. Thanks to
>    Christoph Egger for his help diagnosing this issue on NetBSD.
>  * Remove redundant if (hcall_buf) from xc_clean_hcall_buf since
>    _xc_clean_hcall_buf includes the same check.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
>
> diff -r ddbd38da0739 -r b1f4b4be1f94 tools/libxc/xc_private.c
> --- a/tools/libxc/xc_private.c	Wed Aug 18 13:14:57 2010 +0100
> +++ b/tools/libxc/xc_private.c	Wed Aug 18 16:00:29 2010 +0100
> @@ -57,6 +57,8 @@ xc_interface *xc_interface_open(xentooll
>      return 0;
>  }
>
> +static void xc_clean_hcall_buf(void);
> +
>  int xc_interface_close(xc_interface *xch)
>  {
>      int rc = 0;
> @@ -68,6 +70,9 @@ int xc_interface_close(xc_interface *xch
>          rc = xc_interface_close_core(xch, xch->fd);
>          if (rc) PERROR("Could not close hypervisor interface");
>      }
> +
> +    xc_clean_hcall_buf();
> +
>      free(xch);
>      return rc;
>  }
> @@ -180,6 +185,8 @@ int hcall_buf_prep(void **addr, size_t l
>  int hcall_buf_prep(void **addr, size_t len) { return 0; }
>  void hcall_buf_release(void **addr, size_t len) { }
>
> +static void xc_clean_hcall_buf(void) { }
> +
>  #else /* !__sun__ */
>
>  int lock_pages(void *addr, size_t len)
> @@ -228,6 +235,13 @@ static void _xc_init_hcall_buf(void)
>  static void _xc_init_hcall_buf(void)
>  {
>      pthread_key_create(&hcall_buf_pkey, _xc_clean_hcall_buf);
> +}
> +
> +static void xc_clean_hcall_buf(void)
> +{
> +    pthread_once(&hcall_buf_pkey_once, _xc_init_hcall_buf);
> +
> +    _xc_clean_hcall_buf(pthread_getspecific(hcall_buf_pkey));
>  }
>
>  int hcall_buf_prep(void **addr, size_t len)
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel



-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

  reply	other threads:[~2010-08-18 16:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-18 15:01 [PATCH] libxc: free thread specific hypercall buffer on xc_interface_close Ian Campbell
2010-08-18 16:04 ` Christoph Egger [this message]
2010-08-18 16:26   ` Ian Campbell
2010-08-19 12:39     ` Christoph Egger
2010-08-19 12:48       ` Ian Campbell

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=201008181804.56934.Christoph.Egger@amd.com \
    --to=christoph.egger@amd.com \
    --cc=ian.campbell@citrix.com \
    --cc=xen-devel@lists.xensource.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.