From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>, Doug Goldstein <cardoe@cardoe.com>,
Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH v1 2/4] tmem: Wrap atomic_t in struct tmem_statistics as well.
Date: Thu, 2 Jun 2016 16:16:51 +0100 [thread overview]
Message-ID: <57504DE3.9070805@citrix.com> (raw)
In-Reply-To: <1464879860-25554-3-git-send-email-konrad.wilk@oracle.com>
On 02/06/16 16:04, Konrad Rzeszutek Wilk wrote:
> diff --git a/xen/common/tmem.c b/xen/common/tmem.c
> index d362eae..b58ab4d 100644
> --- a/xen/common/tmem.c
> +++ b/xen/common/tmem.c
> @@ -51,9 +51,32 @@ struct tmem_statistics {
> unsigned long failed_copies;
> unsigned long pcd_tot_tze_size;
> unsigned long pcd_tot_csize;
> + /* Global counters (should use long_atomic_t access). */
> + atomic_t global_obj_count;
> + atomic_t global_pgp_count;
> + atomic_t global_pcd_count;
> + atomic_t global_page_count;
> + atomic_t global_rtree_node_count;
> };
>
> -static struct tmem_statistics tmem_stats;
> +#define atomic_inc_and_max(_c) do { \
> + atomic_inc(&tmem_stats._c); \
> + if ( _atomic_read(tmem_stats._c) > tmem_stats._c##_max ) \
> + tmem_stats._c##_max = _atomic_read(tmem_stats._c); \
> +} while (0)
> +
> +#define atomic_dec_and_assert(_c) do { \
> + atomic_dec(&tmem_stats._c); \
> + ASSERT(_atomic_read(tmem_stats._c) >= 0); \
> +} while (0)
I know you are just modifying existing code (thus this complain doesn't
count against the patch), but these constructs are racy and broken.
You need to use atomic_{inc,dec}_and_test() for these to function as
intended.
Up to you whether you want to fix that in this patch, or a subsequent
non-cleanup patch.
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-02 15:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 15:04 [PATCH v1 for 4.7] Tmem cleanups Konrad Rzeszutek Wilk
2016-06-02 15:04 ` [PATCH v1 1/4] tmem: Move global stats in a tmem_statistics structure Konrad Rzeszutek Wilk
2016-06-02 15:04 ` [PATCH v1 2/4] tmem: Wrap atomic_t in struct tmem_statistics as well Konrad Rzeszutek Wilk
2016-06-02 15:16 ` Andrew Cooper [this message]
2016-06-02 15:26 ` Konrad Rzeszutek Wilk
2016-06-02 15:04 ` [PATCH v1 3/4] tmem: Move global_ individual variables in a global structure Konrad Rzeszutek Wilk
2016-06-02 15:04 ` [PATCH v1 4/4] tmem: Move bulk of tmem control functions in its own file Konrad Rzeszutek Wilk
2016-06-02 15:17 ` [PATCH v1 for 4.7] Tmem cleanups Jan Beulich
2016-06-02 15:27 ` Konrad Rzeszutek Wilk
2016-06-02 15:42 ` Wei Liu
2016-06-02 15:46 ` Konrad Rzeszutek Wilk
2016-06-02 20:09 ` 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=57504DE3.9070805@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=cardoe@cardoe.com \
--cc=jbeulich@suse.com \
--cc=konrad.wilk@oracle.com \
--cc=wei.liu2@citrix.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.