From: Jan Kiszka <jan.kiszka@web.de>
To: Glauber Costa <glommer@redhat.com>
Cc: Glauber Costa <gcosta@redhat.com>,
kvm@vger.kernel.org, avi@qumranet.com, aliguori@us.ibm.com
Subject: Re: [PATCH] remove KVM_CAP_USER_MEMORY reference from qemu-kvm.c
Date: Wed, 10 Sep 2008 21:59:25 +0200 [thread overview]
Message-ID: <48C8271D.5020703@web.de> (raw)
In-Reply-To: <20080910193709.GD17969@poweredge.glommer>
[-- Attachment #1: Type: text/plain, Size: 3658 bytes --]
Glauber Costa wrote:
> On Wed, Sep 10, 2008 at 09:23:18PM +0200, Jan Kiszka wrote:
>> Glauber Costa wrote:
>>> From: Glauber Costa <glommer@redhat.com>
>>>
>>> kvm_cpu_register_physical_memory() is its only user. Remove it.
>>>
>>> Signed-off-by: Glauber Costa <glommer@redhat.com>
>>> ---
>>> qemu/qemu-kvm.c | 52 +++++++++++++++++++++-------------------------------
>>> 1 files changed, 21 insertions(+), 31 deletions(-)
>>>
>>> diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
>>> index 8d366e5..f0ef21e 100644
>>> --- a/qemu/qemu-kvm.c
>>> +++ b/qemu/qemu-kvm.c
>>> @@ -775,42 +775,32 @@ void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
>>> unsigned long size,
>>> unsigned long phys_offset)
>>> {
>>> -#ifdef KVM_CAP_USER_MEMORY
>>> int r = 0;
>>> -
>>> - r = kvm_check_extension(kvm_context, KVM_CAP_USER_MEMORY);
>>> - if (r) {
>>> - if (!(phys_offset & ~TARGET_PAGE_MASK)) {
>>> - r = kvm_is_allocated_mem(kvm_context, start_addr, size);
>>> - if (r)
>>> - return;
>>> - r = kvm_is_intersecting_mem(kvm_context, start_addr);
>>> - if (r)
>>> - kvm_create_mem_hole(kvm_context, start_addr, size);
>>> - r = kvm_register_userspace_phys_mem(kvm_context, start_addr,
>>> - phys_ram_base + phys_offset,
>>> - size, 0);
>>> - }
>>> - if (phys_offset & IO_MEM_ROM) {
>>> - phys_offset &= ~IO_MEM_ROM;
>>> - r = kvm_is_intersecting_mem(kvm_context, start_addr);
>>> - if (r)
>>> - kvm_create_mem_hole(kvm_context, start_addr, size);
>>> - r = kvm_register_userspace_phys_mem(kvm_context, start_addr,
>>> - phys_ram_base + phys_offset,
>>> - size, 0);
>>> - }
>>> - if (r < 0) {
>>> - printf("kvm_cpu_register_physical_memory: failed\n");
>>> - exit(1);
>>> - }
>>> - return;
>>> + if (!(phys_offset & ~TARGET_PAGE_MASK)) {
>>> + r = kvm_is_allocated_mem(kvm_context, start_addr, size);
>>> + if (r)
>>> + return;
>>> + r = kvm_is_intersecting_mem(kvm_context, start_addr);
>>> + if (r)
>>> + kvm_create_mem_hole(kvm_context, start_addr, size);
>>> + r = kvm_register_userspace_phys_mem(kvm_context, start_addr,
>>> + phys_ram_base + phys_offset,
>>> + size, 0);
>>> }
>>> -#endif
>>> if (phys_offset & IO_MEM_ROM) {
>> At this chance: Shouldn't this become 'else if'?
>
> fyi: just sent out a new series, this time with numbers and no tabs in qemu ;-)
Yeah, much better. :)
>
> As a coding style practice, yes. But they are mutually exclusive anyway, so it shouldn't
> matter. We could definitely try to make it better, but they way to go is to have only one case
> instead of two: look at how close they are to each other! I have a later series that do that,
> so I'm just trying to set up the ground here.
Well, they are close partly because the IO_MEM_ROM part is incomplete
(it ignores the 'read-only' property).
However, I just stumbled over it while trying to understand how this
function works. Without the 'else', I had to check twice that the cases
are exclusive in practice...
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
next prev parent reply other threads:[~2008-09-10 19:59 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-08 19:30 [PATCH 0/12] Get rid of kernel memory allocation Glauber Costa
2008-09-08 19:30 ` [PATCH] start removing kernel memory functions Glauber Costa
2008-09-08 19:30 ` [PATCH] remove tests of user memory from vl.c Glauber Costa
2008-09-08 19:30 ` [PATCH] coalesce memory allocation Glauber Costa
2008-09-08 19:30 ` [PATCH] remove KVM_CAP_USER_MEMORY reference from qemu-kvm.c Glauber Costa
2008-09-08 19:30 ` [PATCH] remove KVM_CAP_USER_MEMORY from libkvm.c Glauber Costa
2008-09-08 19:30 ` [PATCH] remove create_kernel_phys_mem Glauber Costa
2008-09-08 19:30 ` [PATCH] get rid of kvm_create_userspace_phys_mem Glauber Costa
2008-09-08 19:30 ` [PATCH] remove user_alloc field from slot representation Glauber Costa
2008-09-08 19:30 ` [PATCH] merge destroy phys mem functions Glauber Costa
2008-09-08 19:30 ` [PATCH] rename kvm_register_userspace_phys_mem Glauber Costa
2008-09-08 19:30 ` [PATCH] remove kernel memory code from hw/pc.c Glauber Costa
2008-09-08 19:30 ` [PATCH] remove kernel memory allocation code from ipf.c Glauber Costa
2008-09-10 19:23 ` [PATCH] remove KVM_CAP_USER_MEMORY reference from qemu-kvm.c Jan Kiszka
2008-09-10 19:37 ` Glauber Costa
2008-09-10 19:59 ` Jan Kiszka [this message]
2008-09-09 14:25 ` [PATCH 0/12] Get rid of kernel memory allocation Avi Kivity
2008-09-09 14:57 ` Glauber Costa
2008-09-09 15:01 ` Avi Kivity
2008-09-10 19:20 ` [PATCH 0/12] get rid of kernel memory registration Glauber Costa
2008-09-11 8:59 ` Avi Kivity
2008-09-10 19:20 ` [PATCH 01/12] start removing kernel memory functions Glauber Costa
2008-09-10 19:20 ` [PATCH 02/12] remove tests of user memory from vl.c Glauber Costa
2008-09-10 19:20 ` [PATCH 03/12] coalesce memory allocation Glauber Costa
2008-09-10 19:20 ` [PATCH 04/12] remove KVM_CAP_USER_MEMORY reference from qemu-kvm.c Glauber Costa
2008-09-10 19:20 ` [PATCH 05/12] remove KVM_CAP_USER_MEMORY from libkvm.c Glauber Costa
2008-09-10 19:21 ` [PATCH 06/12] remove create_kernel_phys_mem Glauber Costa
2008-09-10 19:21 ` [PATCH 07/12] get rid of kvm_create_userspace_phys_mem Glauber Costa
2008-09-10 19:21 ` [PATCH 08/12] remove user_alloc field from slot representation Glauber Costa
2008-09-10 19:21 ` [PATCH 09/12] merge destroy phys mem functions Glauber Costa
2008-09-10 19:21 ` [PATCH 10/12] rename kvm_register_userspace_phys_mem Glauber Costa
2008-09-10 19:21 ` [PATCH 11/12] remove kernel memory code from hw/pc.c Glauber Costa
2008-09-10 19:21 ` [PATCH 12/12] remove kernel memory allocation code from ipf.c Glauber Costa
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=48C8271D.5020703@web.de \
--to=jan.kiszka@web.de \
--cc=aliguori@us.ibm.com \
--cc=avi@qumranet.com \
--cc=gcosta@redhat.com \
--cc=glommer@redhat.com \
--cc=kvm@vger.kernel.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