All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: "Emilio G. Cota" <cota@braap.org>
Cc: qemu-devel@nongnu.org,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	Stefan Weil <sw@weilnetz.de>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Peter Xu <peterx@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH 1/3] qsp: QEMU's Synchronization Profiler
Date: Wed, 15 Aug 2018 11:09:42 +0800	[thread overview]
Message-ID: <20180815030942.GA14092@lemon.usersys.redhat.com> (raw)
In-Reply-To: <20180813171132.21939-2-cota@braap.org>

On Mon, 08/13 13:11, Emilio G. Cota wrote:
> +  --enable-sync-profiler) sync_profiler="yes"
> +  ;;

Curious, not asking for a change: can this be made a runtime option instead of
compile time, since there's no library dependencies? That should make this
somewhat easier to use.

> +
> +#define QSP_GEN_VOID(type_, qsp_t_, func_, impl_)                       \
> +    void func_(type_ *obj, const char *file, unsigned line)             \
> +    {                                                                   \
> +        struct qsp_entry *e = qsp_entry_get(obj, file, line, qsp_t_);   \
> +        int64_t t;                                                      \
> +                                                                        \

No qsp_init()?

> +        t = get_clock();                                                \
> +        impl_(obj, file, line);                                         \
> +        atomic_set(&e->ns, e->ns + get_clock() - t);                    \
> +        atomic_set(&e->n_acqs, e->n_acqs + 1);                          \
> +    }
> +
> +#define QSP_GEN_RET1(type_, qsp_t_, func_, impl_)                       \
> +    int func_(type_ *obj, const char *file, unsigned line)              \
> +    {                                                                   \
> +        struct qsp_entry *e = qsp_entry_get(obj, file, line, qsp_t_);   \
> +        int64_t t;                                                      \
> +        int err;                                                        \
> +                                                                        \

Same here.

> +        t = get_clock();                                                \
> +        err = impl_(obj, file, line);                                   \
> +        atomic_set(&e->ns, e->ns + get_clock() - t);                    \
> +        if (!err) {                                                     \
> +            atomic_set(&e->n_acqs, e->n_acqs + 1);                      \
> +        }                                                               \
> +        return err;                                                     \
> +    }
> +
> +QSP_GEN_VOID(QemuMutex, QSP_MUTEX, qsp_mutex_lock, qemu_mutex_lock_impl)
> +QSP_GEN_RET1(QemuMutex, QSP_MUTEX, qsp_mutex_trylock, qemu_mutex_trylock_impl)
> +
> +QSP_GEN_VOID(QemuRecMutex, QSP_REC_MUTEX, qsp_rec_mutex_lock,
> +             qemu_rec_mutex_lock_impl)
> +QSP_GEN_RET1(QemuRecMutex, QSP_REC_MUTEX, qsp_rec_mutex_trylock,
> +             qemu_rec_mutex_trylock_impl)
> +
> +void qsp_cond_wait(QemuCond *cond, QemuMutex *mutex, const char *file,
> +                   unsigned line)
> +{
> +    struct qsp_entry *e;
> +    int64_t t;
> +
> +    qsp_init();
> +
> +    e = qsp_entry_get(cond, file, line, QSP_CONDVAR);
> +    t = get_clock();
> +    qemu_cond_wait_impl(cond, mutex, file, line);
> +    atomic_set(&e->ns, e->ns + get_clock() - t);
> +    atomic_set(&e->n_acqs, e->n_acqs + 1);

Why not atomic_add (both here and in above macros)? Because fetching e->ns and
then updating it is not "atomic" this way.

Fam

  parent reply	other threads:[~2018-08-15  3:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-13 17:11 [Qemu-devel] [PATCH 0/3] synchronization profiler Emilio G. Cota
2018-08-13 17:11 ` [Qemu-devel] [PATCH 1/3] qsp: QEMU's Synchronization Profiler Emilio G. Cota
2018-08-14  8:13   ` Paolo Bonzini
2018-08-15  0:44     ` Emilio G. Cota
2018-08-15  4:29       ` Markus Armbruster
2018-08-15  3:09   ` Fam Zheng [this message]
2018-08-15  4:53     ` Emilio G. Cota
2018-08-15  7:04       ` Fam Zheng
2018-08-15 23:55       ` Emilio G. Cota
2018-08-16  4:29         ` Emilio G. Cota
2018-08-16  4:36           ` Fam Zheng
2018-08-13 17:11 ` [Qemu-devel] [PATCH 2/3] monitor: show sync profiling info with 'info sync' Emilio G. Cota
2018-08-14  8:14   ` Paolo Bonzini
2018-08-15  1:26     ` Emilio G. Cota
2018-08-16 13:20       ` Peter Xu
2018-08-14  9:43   ` Dr. David Alan Gilbert
2018-08-15  1:33     ` Emilio G. Cota
2018-08-14 16:03   ` Markus Armbruster
2018-08-13 17:11 ` [Qemu-devel] [PATCH 3/3] qsp: track BQL callers directly Emilio G. Cota
2018-08-15 23:30 ` [Qemu-devel] [PATCH 0/3] synchronization profiler no-reply

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=20180815030942.GA14092@lemon.usersys.redhat.com \
    --to=famz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=cota@braap.org \
    --cc=crosthwaite.peter@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=sw@weilnetz.de \
    /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.