From: Ingo Molnar <mingo@elte.hu>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: penberg@kernel.org, asias.hejun@gmail.com,
prasadjoshi124@gmail.com, avi@redhat.com, gorcunov@gmail.com,
kvm@vger.kernel.org
Subject: Re: [PATCH] kvm tools: Add memory gap for larger RAM sizes
Date: Wed, 11 May 2011 13:13:58 +0200 [thread overview]
Message-ID: <20110511111358.GC18521@elte.hu> (raw)
In-Reply-To: <1305109881-11189-1-git-send-email-levinsasha928@gmail.com>
* Sasha Levin <levinsasha928@gmail.com> wrote:
> }
>
> +void kvm__init_ram(struct kvm *self)
> +{
Why is there no comment explaining what this function does and what the whole
gap logic is about? The bug this problem caused was non-obvious, so any future
developer reading this code will wonder what this is all about.
> + if (self->ram_size < KVM_32BIT_GAP_START) {
> + kvm_register_mem_slot(self, 0, 0, self->ram_size, self->ram_start);
> + } else {
> + kvm_register_mem_slot(self, 0, 0, KVM_32BIT_GAP_START, self->ram_start);
> + kvm_register_mem_slot(self, 1, 0x100000000ULL, self->ram_size - KVM_32BIT_GAP_START, self->ram_start + 0x100000000ULL);
> + }
> +}
Why not write it in a much more obvious and almost self-documenting way:
/* First RAM range from zero to the PCI gap: */
phys_start = 0;
phys_size = KVM_32BIT_GAP_START;
host_mem = self->ram_start;
kvm_register_mem_slot(self, 0, phys_start, phys_size, host_mem);
/* Second RAM range from 4GB to the end of RAM: */
phys_start = 0x100000000ULL;
phys_size = self->ram_size - phys_size;
host_mem = self->ram_start + phys_start;
kvm_register_mem_slot(self, 1, phys_start, phys_size, host_mem);
?
Btw., could we please also stop using 'self' for function parameters? It's
utterly meaningless as a name and makes grepping pretty hard.
Use a consistent and meaningful convention please, such as:
struct kvm_cpu *vcpu
And obviously CPU related methods will always have a vcpu parameter around.
Thanks,
Ingo
next prev parent reply other threads:[~2011-05-11 15:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-11 10:31 [PATCH] kvm tools: Add memory gap for larger RAM sizes Sasha Levin
2011-05-11 11:13 ` Ingo Molnar [this message]
2011-05-11 11:15 ` Pekka Enberg
2011-05-11 11:18 ` Ingo Molnar
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=20110511111358.GC18521@elte.hu \
--to=mingo@elte.hu \
--cc=asias.hejun@gmail.com \
--cc=avi@redhat.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=penberg@kernel.org \
--cc=prasadjoshi124@gmail.com \
/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