qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH][RFC] Optimize ld[bwlq]_phys and st[bwlq]_phys
Date: Tue, 21 Oct 2008 08:37:22 -0500	[thread overview]
Message-ID: <48FDDB12.6050701@codemonkey.ws> (raw)
In-Reply-To: <f43fc5580810200936q1631fa61t1c4bf4e651f021a4@mail.gmail.com>

Blue Swirl wrote:
> On 10/14/08, Anthony Liguori <aliguori@us.ibm.com> wrote:
>   
>> This patch optimizes the ld and st functions that operate on physical addresses.
>>  Right now, a number of them default to cpu_phys_memory_{read,write} which is
>>  very slow.  As long as the operations are aligned, it is safe to just lookup
>>  the page and directly read/write the data via ld_p or st_p.
>>
>>  This patch introduces a common function since all of these functions are
>>  roughly the same.  I've tested x86 and sparc with Linux and Windows guests.
>>
>>  I'm pretty confident that this new code is functionally equivalent but I wanted
>>  to have someone else confirm this.
>>     
>
> Why there are special cases for lduw and stw?
>   

I figured the 'u' in lduw stood for unaligned.  The "optimization" only 
works if the physical address is aligned because it doesn't handle the 
case where a word would cross a physical page boundary.  This is why it 
falls back to cpu_physical_memory_rw which can handle this.

ldub is the same, but since it's a single byte, it can't cross a page 
boundary so I don't think the special casing is necessary (or really 
possible :-)).

I wasn't sure about stw.  The current code didn't assume alignment but 
the name doesn't imply that alignment is necessary.  I added a fallback 
case just to be on the safe side in case any code depends on it today.

FWIW, I'm still not sure this optimization really makes anything faster.

> I'd add 'inline' to the common functions, otherwise looks OK.
>   

In general, I tend to avoid inline unless it's required for correctness 
(like in a header file in combination with static).  In general, the 
compiler can make better decisions about inlining than a person can.  
I'm not at all interested in starting a long thread about the merits of 
'inline' but suffice to say that this is not an uncommon view.

Regards,

Anthony Liguori

      reply	other threads:[~2008-10-21 13:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-14 19:59 [Qemu-devel] [PATCH][RFC] Optimize ld[bwlq]_phys and st[bwlq]_phys Anthony Liguori
2008-10-20 16:36 ` Blue Swirl
2008-10-21 13:37   ` Anthony Liguori [this message]

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=48FDDB12.6050701@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).