From: "Jan Beulich" Subject: [PATCH] linux/x86: convert 'cpu' (and a few other) variables to unsigned Date: Fri, 18 Jan 2008 16:06:23 +0000 Message-ID: <4790DC8F.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org .. producing better code for x86-64. As usual, written and tested on 2.6.24-rc7 and made apply to the 2.6.18 tree without further testing. Signed-off-by: Jan Beulich Index: head-2007-12-11/arch/i386/kernel/time-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2007-12-11.orig/arch/i386/kernel/time-xen.c 2007-12-18 = 15:28:14.000000000 +0100 +++ head-2007-12-11/arch/i386/kernel/time-xen.c 2007-12-18 13:39:39.0000000= 00 +0100 @@ -301,7 +301,7 @@ static void update_wallclock(void) * Reads a consistent set of time-base values from Xen, into a shadow = data * area. */ -static void get_time_values_from_xen(int cpu) +static void get_time_values_from_xen(unsigned int cpu) { struct vcpu_time_info *src; struct shadow_time_info *dst; @@ -322,7 +322,7 @@ static void get_time_values_from_xen(int dst->tsc_to_usec_mul =3D dst->tsc_to_nsec_mul / 1000; } =20 -static inline int time_values_up_to_date(int cpu) +static inline int time_values_up_to_date(unsigned int cpu) { struct vcpu_time_info *src; struct shadow_time_info *dst; @@ -513,7 +513,7 @@ static int set_rtc_mmss(unsigned long no */ unsigned long long monotonic_clock(void) { - int cpu =3D get_cpu(); + unsigned int cpu =3D get_cpu(); struct shadow_time_info *shadow =3D &per_cpu(shadow_time, cpu); u64 time; u32 local_time_version; @@ -579,7 +579,7 @@ irqreturn_t timer_interrupt( { s64 delta, delta_cpu, stolen, blocked; u64 sched_time; - int i, cpu =3D smp_processor_id(); + unsigned int i, cpu =3D smp_processor_id(); struct shadow_time_info *shadow =3D &per_cpu(shadow_time, cpu); struct vcpu_runstate_info *runstate =3D &per_cpu(runstate, cpu); =20 @@ -614,7 +614,7 @@ irqreturn_t timer_interrupt(int irq, voi if ((unlikely(delta < -(s64)permitted_clock_jitter) || unlikely(delta_cpu < -(s64)permitted_clock_jitter)) && printk_ratelimit()) { - printk("Timer ISR/%d: Time went backwards: " + printk("Timer ISR/%u: Time went backwards: " "delta=3D%lld delta_cpu=3D%lld shadow=3D%lld " "off=3D%lld processed=3D%lld cpu_processed=3D%lld\n"= , cpu, delta, delta_cpu, shadow->system_timestamp, @@ -717,7 +717,7 @@ static struct clocksource clocksource_xe return IRQ_HANDLED; } =20 -static void init_missing_ticks_accounting(int cpu) +static void init_missing_ticks_accounting(unsigned int cpu) { struct vcpu_register_runstate_memory_area area; struct vcpu_runstate_info *runstate =3D &per_cpu(runstate, cpu); @@ -965,7 +965,7 @@ int __cpuinit local_setup_timer(unsigned init_missing_ticks_accounting(cpu); } while (read_seqretry(&xtime_lock, seq)); =20 - sprintf(timer_name[cpu], "timer%d", cpu); + sprintf(timer_name[cpu], "timer%u", cpu); irq =3D bind_virq_to_irqhandler(VIRQ_TIMER, cpu, timer_interrupt, Index: head-2007-12-11/arch/i386/mm/hypervisor.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2007-12-11.orig/arch/i386/mm/hypervisor.c 2007-10-19 = 17:18:37.000000000 +0200 +++ head-2007-12-11/arch/i386/mm/hypervisor.c 2007-12-18 15:34:13.0000000= 00 +0100 @@ -250,9 +250,9 @@ int xen_create_contiguous_region( unsigned long vstart, unsigned int order, unsigned int address_bits= ) { unsigned long *in_frames =3D discontig_frames, out_frame; - unsigned long frame, i, flags; - long rc; - int success; + unsigned long frame, flags; + unsigned int i; + int rc, success; struct xen_memory_exchange exchange =3D { .in =3D { .nr_extents =3D 1UL << order, @@ -286,7 +286,7 @@ int xen_create_contiguous_region( balloon_lock(flags); =20 /* 1. Zap current PTEs, remembering MFNs. */ - for (i =3D 0; i < (1UL<> PAGE_SHIFT) + = i); MULTI_update_va_mapping(cr_mcl + i, vstart + (i*PAGE_SIZE),= __pte_ma(0), 0); @@ -312,7 +312,7 @@ int xen_create_contiguous_region( &exchange.out) =3D=3D 1); if (!success) { /* Couldn't get special memory: fall back to = normal. */ - for (i =3D 0; i < (1UL<>PAGE_SHIFT)= + i; if (HYPERVISOR_memory_op(XENMEM_populate_physmap, &exchange.in) !=3D = (1UL<> PAGE_SHIFT); =20 /* 2. Zap current PTEs. */ - for (i =3D 0; i < (1UL<>PAGE_SHIFT)+i, @@ -413,7 +413,7 @@ void xen_destroy_contiguous_region(unsig #endif =20 /* 4. Map new pages in place of old pages. */ - for (i =3D 0; i < (1UL<=3D NR_CPUS) || !cpu_possible(cpu)) return; =20 - sprintf(dir, "cpu/%d", cpu); + sprintf(dir, "cpu/%u", cpu); err =3D xenbus_scanf(XBT_NIL, dir, "availability", "%s", state); if (err !=3D 1) { printk(KERN_ERR "XENBUS: Unable to read cpu state\n"); @@ -54,12 +54,12 @@ static void vcpu_hotplug(unsigned int cp static void handle_vcpu_hotplug_event( struct xenbus_watch *watch, const char **vec, unsigned int len) { - int cpu; + unsigned int cpu; char *cpustr; const char *node =3D vec[XS_WATCH_PATH]; =20 if ((cpustr =3D strstr(node, "cpu/")) !=3D NULL) { - sscanf(cpustr, "cpu/%d", &cpu); + sscanf(cpustr, "cpu/%u", &cpu); vcpu_hotplug(cpu); } } @@ -67,7 +67,7 @@ static void handle_vcpu_hotplug_event( static int smpboot_cpu_notify(struct notifier_block *notifier, unsigned long action, void *hcpu) { - int cpu =3D (long)hcpu; + unsigned int cpu =3D (long)hcpu; =20 /* * We do this in a callback notifier rather than __cpu_disable() @@ -83,7 +83,7 @@ static int smpboot_cpu_notify(struct not static int setup_cpu_watcher(struct notifier_block *notifier, unsigned long event, void *data) { - int i; + unsigned int i; =20 static struct xenbus_watch cpu_watch =3D { .node =3D "cpu", @@ -121,7 +121,8 @@ arch_initcall(setup_vcpu_hotplug_event); =20 int smp_suspend(void) { - int cpu, err; + unsigned int cpu; + int err; =20 for_each_online_cpu(cpu) { if (cpu =3D=3D 0) @@ -141,7 +142,7 @@ int smp_suspend(void) =20 void smp_resume(void) { - int cpu; + unsigned int cpu; =20 for_each_possible_cpu(cpu) vcpu_hotplug(cpu); Index: head-2007-12-11/drivers/xen/core/evtchn.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2007-12-11.orig/drivers/xen/core/evtchn.c 2007-12-18 = 15:28:14.000000000 +0100 +++ head-2007-12-11/drivers/xen/core/evtchn.c 2007-12-18 15:11:34.0000000= 00 +0100 @@ -230,7 +230,8 @@ asmlinkage void evtchn_do_upcall(struct=20 unsigned long l1, l2; unsigned long masked_l1, masked_l2; unsigned int l1i, l2i, port, count; - int irq, cpu =3D smp_processor_id(); + int irq; + unsigned int cpu =3D smp_processor_id(); shared_info_t *s =3D HYPERVISOR_shared_info; vcpu_info_t *vcpu_info =3D &s->vcpu_info[cpu]; =20 @@ -466,7 +467,8 @@ static int bind_ipi_to_irq(unsigned int=20 static void unbind_from_irq(unsigned int irq) { struct evtchn_close close; - int cpu, evtchn =3D evtchn_from_irq(irq); + unsigned int cpu; + int evtchn =3D evtchn_from_irq(irq); =20 spin_lock(&irq_mapping_update_lock); =20 @@ -927,7 +929,7 @@ void disable_all_local_evtchn(void) synch_set_bit(i, &s->evtchn_mask[0]); } =20 -static void restore_cpu_virqs(int cpu) +static void restore_cpu_virqs(unsigned int cpu) { struct evtchn_bind_virq bind_virq; int virq, irq, evtchn; @@ -956,7 +958,7 @@ static void restore_cpu_virqs(int cpu) } } =20 -static void restore_cpu_ipis(int cpu) +static void restore_cpu_ipis(unsigned int cpu) { struct evtchn_bind_ipi bind_ipi; int ipi, irq, evtchn; @@ -987,7 +989,7 @@ static void restore_cpu_ipis(int cpu) =20 void irq_resume(void) { - int cpu, pirq, irq, evtchn; + unsigned int cpu, pirq, irq, evtchn; =20 init_evtchn_cpu_bindings(); =20 @@ -1014,7 +1016,7 @@ void irq_resume(void) =20 void __init xen_init_IRQ(void) { - int i; + unsigned int i; =20 init_evtchn_cpu_bindings(); =20 Index: head-2007-12-11/drivers/xen/core/smpboot.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2007-12-11.orig/drivers/xen/core/smpboot.c 2007-12-18 = 15:28:14.000000000 +0100 +++ head-2007-12-11/drivers/xen/core/smpboot.c 2007-12-18 12:10:12.0000000= 00 +0100 @@ -88,7 +88,7 @@ void __init smp_alloc_memory(void) } =20 static inline void -set_cpu_sibling_map(int cpu) +set_cpu_sibling_map(unsigned int cpu) { cpu_data[cpu].phys_proc_id =3D cpu; cpu_data[cpu].cpu_core_id =3D 0; @@ -100,7 +100,7 @@ set_cpu_sibling_map(int cpu) } =20 static void -remove_siblinginfo(int cpu) +remove_siblinginfo(unsigned int cpu) { cpu_data[cpu].phys_proc_id =3D BAD_APICID; cpu_data[cpu].cpu_core_id =3D BAD_APICID; @@ -117,7 +117,7 @@ static int __cpuinit xen_smp_intr_init(u =20 per_cpu(resched_irq, cpu) =3D per_cpu(callfunc_irq, cpu) =3D -1; =20 - sprintf(resched_name[cpu], "resched%d", cpu); + sprintf(resched_name[cpu], "resched%u", cpu); rc =3D bind_ipi_to_irqhandler(RESCHEDULE_VECTOR, cpu, smp_reschedule_interrupt, @@ -128,7 +128,7 @@ static int __cpuinit xen_smp_intr_init(u goto fail; per_cpu(resched_irq, cpu) =3D rc; =20 - sprintf(callfunc_name[cpu], "callfunc%d", cpu); + sprintf(callfunc_name[cpu], "callfunc%u", cpu); rc =3D bind_ipi_to_irqhandler(CALL_FUNCTION_VECTOR, cpu, smp_call_function_interrupt, @@ -248,7 +248,7 @@ static void __cpuinit cpu_initialize_con =20 void __init smp_prepare_cpus(unsigned int max_cpus) { - int cpu; + unsigned int cpu; struct task_struct *idle; #ifdef __x86_64__ struct desc_ptr *gdt_descr; @@ -369,7 +369,7 @@ core_initcall(initialize_cpu_present_map int __cpu_disable(void) { cpumask_t map =3D cpu_online_map; - int cpu =3D smp_processor_id(); + unsigned int cpu =3D smp_processor_id(); =20 if (cpu =3D=3D 0) return -EBUSY; Index: head-2007-12-11/drivers/xen/xenoprof/xenoprofile.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2007-12-11.orig/drivers/xen/xenoprof/xenoprofile.c 2007-12-18 = 15:28:14.000000000 +0100 +++ head-2007-12-11/drivers/xen/xenoprof/xenoprofile.c 2007-12-18 = 15:06:08.000000000 +0100 @@ -198,11 +198,9 @@ static irqreturn_t=20 xenoprof_ovf_interrupt(int irq, void * dev_id) { struct xenoprof_buf * buf; - int cpu; static unsigned long flag; =20 - cpu =3D smp_processor_id(); - buf =3D xenoprof_buf[cpu]; + buf =3D xenoprof_buf[smp_processor_id()]; =20 xenoprof_add_pc(buf, 0); =20 @@ -218,7 +216,7 @@ xenoprof_ovf_interrupt(int irq, void * d =20 static void unbind_virq(void) { - int i; + unsigned int i; =20 for_each_online_cpu(i) { if (ovf_irq[i] >=3D 0) { @@ -231,7 +229,8 @@ static void unbind_virq(void) =20 static int bind_virq(void) { - int i, result; + unsigned int i; + int result; =20 for_each_online_cpu(i) { result =3D bind_virq_to_irqhandler(VIRQ_XENOPROF, @@ -429,7 +428,7 @@ static int xenoprof_set_passive(int * p_ unsigned int pdoms) { int ret; - int i, j; + unsigned int i, j; struct xenoprof_buf *buf; =20 if (!xenoprof_is_primary) @@ -503,7 +502,8 @@ static int using_xenoprof; int __init xenoprofile_init(struct oprofile_operations * ops) { struct xenoprof_init init; - int ret, i; + unsigned int i; + int ret; =20 ret =3D HYPERVISOR_xenoprof_op(XENOPROF_init, &init); if (!ret) {