All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	KONRAD Frederic <frederic.konrad@adacore.com>,
	Richard Henderson <rth@twiddle.net>,
	Edgar Iglesias <edgar.iglesias@xilinx.com>
Subject: Re: [Qemu-devel] [PULL v2 6/7] exec: allow to get a pointer for some mmio memory region
Date: Thu, 10 Aug 2017 14:59:34 +0200	[thread overview]
Message-ID: <9fc966eb-ee33-d5b8-fef8-5472853ca4fc@redhat.com> (raw)
In-Reply-To: <CAFEAcA_7_EwgxfnEmr+moHc5u4uprKjyL+ZA1VzspYwqONjfCg@mail.gmail.com>

On 10/08/2017 14:56, Peter Maydell wrote:
>> +    qemu_mutex_lock_iothread();
>> +
>> +    /* Reset dirty so this doesn't happen later. */
>> +    cpu_physical_memory_test_and_clear_dirty(offset, size, 1);
>> +
>> +    if (section.mr != mr) {
>> +        /* memory_region_find add a ref on section.mr */
>> +        memory_region_unref(section.mr);
>> +        if (MMIO_INTERFACE(section.mr->owner)) {
> 
> Could somebody explain why it's OK to unref section.mr here before
> we go on to do things with it, rather than only unrefing it after
> we've finished using it?

The memory region won't disappear until you release the BQL and/or
RCU-read-lock, but yes it's cleaner to move it later, and yes there is a
leak.

Paolo

> Also, by my reading memory_region_find() will always ref
> ret.mr (if it's not NULL), whereas this code only unrefs it
> if section.mr == mr. Does this leak a reference in the case
> where section.mr != mr, or am I missing something ?
> 

  reply	other threads:[~2017-08-10 12:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 15:37 [Qemu-devel] [PULL v2 0/7] MMIO Exec pull request Edgar E. Iglesias
2017-06-27 15:37 ` [Qemu-devel] [PULL v2 1/7] cputlb: cleanup get_page_addr_code to use VICTIM_TLB_HIT Edgar E. Iglesias
2017-06-27 15:37 ` [Qemu-devel] [PULL v2 2/7] cputlb: move get_page_addr_code Edgar E. Iglesias
2017-06-27 15:37 ` [Qemu-devel] [PULL v2 3/7] cputlb: fix the way get_page_addr_code fills the tlb Edgar E. Iglesias
2017-06-27 15:37 ` [Qemu-devel] [PULL v2 4/7] qdev: add MemoryRegion property Edgar E. Iglesias
2017-06-27 15:37 ` [Qemu-devel] [PULL v2 5/7] introduce mmio_interface Edgar E. Iglesias
2017-06-27 15:37 ` [Qemu-devel] [PULL v2 6/7] exec: allow to get a pointer for some mmio memory region Edgar E. Iglesias
2017-08-10 12:56   ` Peter Maydell
2017-08-10 12:59     ` Paolo Bonzini [this message]
2017-08-10 13:23       ` KONRAD Frederic
2017-06-27 15:37 ` [Qemu-devel] [PULL v2 7/7] xilinx_spips: allow mmio execution Edgar E. Iglesias
2017-06-27 17:09 ` [Qemu-devel] [PULL v2 0/7] MMIO Exec pull request Peter Maydell

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=9fc966eb-ee33-d5b8-fef8-5472853ca4fc@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=frederic.konrad@adacore.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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.