All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] use symbols rather than constant vars in kvm_create
@ 2007-06-03  9:35 Nguyen Anh Quynh
       [not found] ` <9cde8bff0706030235p2e20c9e8k3cccae1b75835887-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Nguyen Anh Quynh @ 2007-06-03  9:35 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

[-- Attachment #1: Type: text/plain, Size: 174 bytes --]

This patch replaces 2 constant variables "dosmem" and "exmem" in
kvm_create() with symbols.

Signed-off-by: Nguyen Anh Quynh <aquynh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

[-- Attachment #2: patch3.patch --]
[-- Type: application/octet-stream, Size: 944 bytes --]

diff --git a/user/kvmctl.c b/user/kvmctl.c
index 82d1926..e01410c 100644
--- a/user/kvmctl.c
+++ b/user/kvmctl.c
@@ -204,23 +204,26 @@ void kvm_finalize(kvm_context_t kvm)
 
 int kvm_create(kvm_context_t kvm, unsigned long memory, void **vm_mem)
 {
-	unsigned long dosmem = 0xa0000;
-	unsigned long exmem = 0xc0000;
+#define DOSMEM	0xa0000
+#define EXMEM	0xc0000
 	long mmap_size;
 	int fd = kvm->fd;
 	int zfd;
 	int r;
 	struct kvm_memory_region low_memory = {
 		.slot = 3,
-		.memory_size = memory  < dosmem ? memory : dosmem,
+		.memory_size = memory  < DOSMEM ? memory : DOSMEM,
 		.guest_phys_addr = 0,
 	};
 	struct kvm_memory_region extended_memory = {
 		.slot = 0,
-		.memory_size = memory < exmem ? 0 : memory - exmem,
-		.guest_phys_addr = exmem,
+		.memory_size = memory < EXMEM ? 0 : memory - EXMEM,
+		.guest_phys_addr = EXMEM,
 	};
 
+#undef DOSMEM
+#undef EXMEM
+
 	kvm->vcpu_fd[0] = -1;
 
 	fd = ioctl(fd, KVM_CREATE_VM, 0);

[-- Attachment #3: Type: text/plain, Size: 286 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] use symbols rather than constant vars in kvm_create
       [not found] ` <9cde8bff0706030235p2e20c9e8k3cccae1b75835887-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2007-06-03  9:36   ` Avi Kivity
       [not found]     ` <46628BBA.3090107-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2007-06-03  9:36 UTC (permalink / raw)
  To: Nguyen Anh Quynh; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Nguyen Anh Quynh wrote:
> This patch replaces 2 constant variables "dosmem" and "exmem" in
> kvm_create() with symbols.

What is the benefit of this?  Readability is not improved.


-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] use symbols rather than constant vars in kvm_create
       [not found]     ` <46628BBA.3090107-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-06-03  9:41       ` Nguyen Anh Quynh
       [not found]         ` <9cde8bff0706030241l1253cce8k99a24ce942205c51-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Nguyen Anh Quynh @ 2007-06-03  9:41 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On 6/3/07, Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
> Nguyen Anh Quynh wrote:
> > This patch replaces 2 constant variables "dosmem" and "exmem" in
> > kvm_create() with symbols.
>
> What is the benefit of this?  Readability is not improved.
>
>

yes, but what is the reason to use vars instead of symbols here? do
you want to waste some place in stack?

i am not sure if gcc can optmize that, but there is no good reason to
use variables here.

cheers,
Q

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] use symbols rather than constant vars in kvm_create
       [not found]         ` <9cde8bff0706030241l1253cce8k99a24ce942205c51-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2007-06-03  9:45           ` Avi Kivity
       [not found]             ` <46628DB3.60502-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2007-06-03  9:45 UTC (permalink / raw)
  To: Nguyen Anh Quynh; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Nguyen Anh Quynh wrote:
> On 6/3/07, Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
>> Nguyen Anh Quynh wrote:
>> > This patch replaces 2 constant variables "dosmem" and "exmem" in
>> > kvm_create() with symbols.
>>
>> What is the benefit of this?  Readability is not improved.
>>
>>
>
> yes, but what is the reason to use vars instead of symbols here? do
> you want to waste some place in stack?
>
> i am not sure if gcc can optmize that, but there is no good reason to
> use variables here.
>

gcc does optimize it, and even if it didn't, this function is called 
once per virtual machine.  There's no reason to try to make it more 
efficient.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] use symbols rather than constant vars in kvm_create
       [not found]             ` <46628DB3.60502-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-06-03  9:50               ` Nguyen Anh Quynh
  0 siblings, 0 replies; 5+ messages in thread
From: Nguyen Anh Quynh @ 2007-06-03  9:50 UTC (permalink / raw)
  To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On 6/3/07, Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
> Nguyen Anh Quynh wrote:
> > On 6/3/07, Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org> wrote:
> >> Nguyen Anh Quynh wrote:
> >> > This patch replaces 2 constant variables "dosmem" and "exmem" in
> >> > kvm_create() with symbols.
> >>
> >> What is the benefit of this?  Readability is not improved.
> >>
> >>
> >
> > yes, but what is the reason to use vars instead of symbols here? do
> > you want to waste some place in stack?
> >
> > i am not sure if gcc can optmize that, but there is no good reason to
> > use variables here.
> >
>
> gcc does optimize it, and even if it didn't, this function is called
> once per virtual machine.  There's no reason to try to make it more
> efficient.

ok, it is up to you. but i always find that constants in capitalized
(DOSMEM instead of dosmem) is far more readable.

cheers,
Q

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-06-03  9:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-03  9:35 [PATCH] use symbols rather than constant vars in kvm_create Nguyen Anh Quynh
     [not found] ` <9cde8bff0706030235p2e20c9e8k3cccae1b75835887-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-06-03  9:36   ` Avi Kivity
     [not found]     ` <46628BBA.3090107-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-03  9:41       ` Nguyen Anh Quynh
     [not found]         ` <9cde8bff0706030241l1253cce8k99a24ce942205c51-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-06-03  9:45           ` Avi Kivity
     [not found]             ` <46628DB3.60502-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-03  9:50               ` Nguyen Anh Quynh

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.