a few more cleanups
PATCH 1/3 use DEFINE_SPINLOCK in drivers/xen
In reply to Chris WrightConforming to typical CodingStyle.
--- linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c | 2 +- linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c | 2 +- linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c | 2 +- linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c | 2 +- linux-2.6-xen-sparse/drivers/xen/console/console.c | 2 +- linux-2.6-xen-sparse/drivers/xen/core/evtchn.c | 4 +--- linux-2.6-xen-sparse/drivers/xen/core/gnttab.c | 2 +- linux-2.6-xen-sparse/drivers/xen/netback/netback.c | 4 ++-- 8 files changed, 9 insertions(+), 11 deletions(-)
linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c +1 -1
@@ -67,7 +67,7 @@ static DECLARE_MUTEX(balloon_mutex);* Also protects non-atomic updates of current_pages and driver_pages, and * balloon lists. */ -spinlock_t balloon_lock =SPIN_LOCK_UNLOCKED ; +DEFINE_SPINLOCK (balloon_lock);/* We aim for 'current allocation' == 'target allocation'. */ static unsigned long current_pages;
linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c +1 -1
@@ -82,7 +82,7 @@ typedef struct {static pending_req_t *pending_reqs;static struct list_head pending_free; -static spinlock_t pending_free_lock =SPIN_LOCK_UNLOCKED ; +static DEFINE_SPINLOCK (pending_free_lock);static DECLARE_WAIT_QUEUE_HEAD (pending_free_wq);#define BLKBACK_INVALID_HANDLE (~0)
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c +1 -1
@@ -93,7 +93,7 @@ static struct block_device_operations xl .ioctl = blkif_ioctl, }; -spinlock_t blkif_io_lock =SPIN_LOCK_UNLOCKED ; +DEFINE_SPINLOCK (blkif_io_lock);static struct xlbd_major_info *xlbd_alloc_major_info (int major,int minor,int index)
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c +1 -1
@@ -138,7 +138,7 @@ typedef struct {*/ static pending_req_t pending_reqs[MAX_PENDING_REQS ];static unsigned char pending_ring[MAX_PENDING_REQS ]; -static spinlock_t pend_prod_lock =SPIN_LOCK_UNLOCKED ; +static DEFINE_SPINLOCK (pend_prod_lock);/* NB. We use a different index type to differentiate from shared blk rings. */ typedef unsigned int PEND_RING_IDX ;#define MASK_PEND_IDX (_i) ((_i)&(MAX_PENDING_REQS-1))
linux-2.6-xen-sparse/drivers/xen/console/console.c +1 -1
@@ -124,7 +124,7 @@ static int __init xencons_bufsz_setup(ch__setup ("xencons_bufsz=" , xencons_bufsz_setup);/* This lock protects accesses to the common transmit buffer. */ -static spinlock_t xencons_lock =SPIN_LOCK_UNLOCKED ; +static DEFINE_SPINLOCK (xencons_lock);/* Common transmit-kick routine. */ static void __xencons_tx_flush (void );
linux-2.6-xen-sparse/drivers/xen/core/gnttab.c +1 -1
@@ -81,7 +81,7 @@ EXPORT_SYMBOL_GPL(gnttab_grant_foreign_tstatic grant_ref_t gnttab_list[NR_GRANT_ENTRIES ];static int gnttab_free_count;static grant_ref_t gnttab_free_head; -static spinlock_t gnttab_list_lock =SPIN_LOCK_UNLOCKED ; +static DEFINE_SPINLOCK (gnttab_list_lock);static grant_entry_t *shared =NULL ;
linux-2.6-xen-sparse/drivers/xen/netback/netback.c +2 -2
@@ -99,7 +99,7 @@ static spinlock_t net_schedule_list_lock#define MAX_MFN_ALLOC 64static unsigned long mfn_list[MAX_MFN_ALLOC ];static unsigned int alloc_index =0 ; -static spinlock_t mfn_lock =SPIN_LOCK_UNLOCKED ; +static DEFINE_SPINLOCK (mfn_lock);static unsigned long alloc_mfn (void ) {
@@ -691,7 +691,7 @@ static void net_tx_action(unsigned longstatic void netif_idx_release (u16 pending_idx) { -static spinlock_t _lock =SPIN_LOCK_UNLOCKED ; +static DEFINE_SPINLOCK (_lock);unsigned long flags;spin_lock_irqsave (&_lock, flags);
linux-2.6-xen-sparse/drivers/xen/core/evtchn.c +1 -3
@@ -51,7 +51,7 @@* This lock protects updates to the following mapping and reference-count * arrays. The lock does not need to be acquired to read the mapping tables. */ -static spinlock_t irq_mapping_update_lock; +static DEFINE_SPINLOCK (irq_mapping_update_lock);/* IRQ <-> event-channel mappings. */ static int evtchn_to_irq[NR_EVENT_CHANNELS ];
@@ -815,8 +815,6 @@ void __init xen_init_IRQ(void)int i;int cpu; -spin_lock_init (&irq_mapping_update_lock); -init_evtchn_cpu_bindings ();/* No VIRQ or IPI bindings. */
--
PATCH 2/3 xencons: minor cleanups
In reply to Chris WrightFix kcons_write and kcons_write_dom0 CodingStyle.
Use roundup_pow_of_two().
--- linux-2.6-xen-sparse/drivers/xen/console/console.c | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
linux-2.6-xen-sparse/drivers/xen/console/console.c +12 -10
@@ -117,8 +117,11 @@ static int __init xencons_bufsz_setup(ch {unsigned int goal; goal =simple_strtoul (str,NULL ,0 ); -while (wbuf_size < goal) - wbuf_size <<=1 ; +if (goal) { + goal =roundup_pow_of_two (goal); +if (wbuf_size < goal) + wbuf_size = goal; + }return 1 ; }__setup ("xencons_bufsz=" , xencons_bufsz_setup);
@@ -133,8 +136,7 @@ static struct tty_driver *xencons_driver/******************** Kernel console driver ********************************/ -static void kcons_write ( -struct console *c,const char *s,unsigned int count) +static void kcons_write (struct console *c,const char *s,unsigned int count) {int i =0 ;unsigned long flags;
@@ -155,14 +157,14 @@ static void kcons_write(spin_unlock_irqrestore (&xencons_lock, flags); } -static void kcons_write_dom0 ( -struct console *c,const char *s,unsigned int count) +static void kcons_write_dom0 (struct console *c,const char *s,unsigned int count) { -int rc; -while ((count >0 ) && - ((rc =HYPERVISOR_console_io ( - CONSOLEIO_write, count, (char *)s)) >0 )) { +while (count >0 ) { +int rc; + rc =HYPERVISOR_console_io ( CONSOLEIO_write, count, (char *)s); +if (rc <=0 ) +break ; count -= rc; s += rc; }
--
PATCH 3/3 evtchn: fix opencoded for_each_cpu
In reply to Chris WrightUse for_each_cpu instead, or statically initialize data when possible.
--- linux-2.6-xen-sparse/drivers/xen/core/evtchn.c | 27 ++++++++----------------- 1 file changed, 9 insertions(+), 18 deletions(-)
linux-2.6-xen-sparse/drivers/xen/core/evtchn.c +9 -18
@@ -54,7 +54,7 @@static DEFINE_SPINLOCK (irq_mapping_update_lock);/* IRQ <-> event-channel mappings. */ -static int evtchn_to_irq[NR_EVENT_CHANNELS ]; +static int evtchn_to_irq[NR_EVENT_CHANNELS ] = {[0 ...NR_EVENT_CHANNELS -1 ] =-1 };/* Packed IRQ information: binding type, sub-type index, and event channel. */ static u32 irq_info[NR_IRQS ];
@@ -91,13 +91,13 @@ static inline unsigned int type_from_irq }/* IRQ <-> VIRQ mapping. */ -DEFINE_PER_CPU (int, virq_to_irq[NR_VIRQS ]); +DEFINE_PER_CPU(int, virq_to_irq[NR_VIRQS]) = {[0 ... NR_VIRQS-1] = -1};/* IRQ <-> IPI mapping. */ #ifndef NR_IPIS #define NR_IPIS 1#endif -DEFINE_PER_CPU (int, ipi_to_irq[NR_IPIS ]); +DEFINE_PER_CPU(int, ipi_to_irq[NR_IPIS]) = {[0 ... NR_IPIS-1] = -1};/* Reference counts for bindings to IRQs. */ static int irq_bindcount[NR_IRQS ];
@@ -751,7 +751,9 @@ void irq_resume(void)BUG_ON (irq_info[pirq_to_irq (pirq)] !=IRQ_UNBOUND );/* Secondary CPUs must have no VIRQ or IPI bindings. */ -for (cpu =1 ; cpu <NR_CPUS ; cpu++) { +for_each_cpu (cpu) { +if (cpu ==0 ) +continue ;for (virq =0 ; virq <NR_VIRQS ; virq++)BUG_ON (per_cpu (virq_to_irq, cpu)[virq] !=-1 );for (ipi =0 ; ipi <NR_IPIS ; ipi++)
@@ -813,23 +815,12 @@ void irq_resume(void)void __init xen_init_IRQ (void ) {int i; -int cpu;init_evtchn_cpu_bindings (); -/* No VIRQ or IPI bindings. */ -for (cpu =0 ; cpu <NR_CPUS ; cpu++) { -for (i =0 ; i <NR_VIRQS ; i++) -per_cpu (virq_to_irq, cpu)[i] =-1 ; -for (i =0 ; i <NR_IPIS ; i++) -per_cpu (ipi_to_irq, cpu)[i] =-1 ; - } - -/* No event-channel -> IRQ mappings. */ -for (i =0 ; i <NR_EVENT_CHANNELS ; i++) { - evtchn_to_irq[i] =-1 ; -mask_evtchn (i);/* No event channels are 'live' right now. */ - } +/* No event channels are 'live' right now. */ +for (i =0 ; i <NR_EVENT_CHANNELS ; i++) +mask_evtchn (i);/* No IRQ -> event-channel mappings. */ for (i =0 ; i <NR_IRQS ; i++)
--
cover a few more cleanups
here's a few more cleanups to the linux sparse tree from lkml patch review.
thanks,
-chris
--
Re: [patch 3/3] [PATCH] evtchn: fix opencoded for_each_cpu
In reply to Chris WrightQuoted 2 lines · Chris Wright
Use
for_each_cpuinstead, or statically initialize data when possible.
for_each_cpu is going away, this should be for_each_possible/present/online_cpu, whichever one is appropriate.
Cheers,
Muli
Re: [patch 3/3] [PATCH] evtchn: fix opencoded for_each_cpu
Quoted 7 lines · * Muli Ben-Yehuda ([email protected]) wrote:
Quoted 2 lines · Chris Wright
Use
for_each_cpuinstead, or statically initialize data when possible.
for_each_cpuis going away, this should be for_each_possible/present/online_cpu, whichever one is appropriate.
Thanks, here's a respin.
-chris
--
Subject: [PATCH] evtchn: fix opencoded for_each_cpu
Use for_each_possible_cpu instead, or statically initialize data when possible.
--- linux-2.6-xen-sparse/drivers/xen/core/evtchn.c | 27 ++++++++----------------- 1 file changed, 9 insertions(+), 18 deletions(-)
linux-2.6-xen-sparse/drivers/xen/core/evtchn.c +9 -18
@@ -54,7 +54,7 @@static DEFINE_SPINLOCK (irq_mapping_update_lock);/* IRQ <-> event-channel mappings. */ -static int evtchn_to_irq[NR_EVENT_CHANNELS ]; +static int evtchn_to_irq[NR_EVENT_CHANNELS ] = {[0 ...NR_EVENT_CHANNELS -1 ] =-1 };/* Packed IRQ information: binding type, sub-type index, and event channel. */ static u32 irq_info[NR_IRQS ];
@@ -91,13 +91,13 @@ static inline unsigned int type_from_irq }/* IRQ <-> VIRQ mapping. */ -DEFINE_PER_CPU (int, virq_to_irq[NR_VIRQS ]); +DEFINE_PER_CPU(int, virq_to_irq[NR_VIRQS]) = {[0 ... NR_VIRQS-1] = -1};/* IRQ <-> IPI mapping. */ #ifndef NR_IPIS #define NR_IPIS 1#endif -DEFINE_PER_CPU (int, ipi_to_irq[NR_IPIS ]); +DEFINE_PER_CPU(int, ipi_to_irq[NR_IPIS]) = {[0 ... NR_IPIS-1] = -1};/* Reference counts for bindings to IRQs. */ static int irq_bindcount[NR_IRQS ];
@@ -751,7 +751,9 @@ void irq_resume(void)BUG_ON (irq_info[pirq_to_irq (pirq)] !=IRQ_UNBOUND );/* Secondary CPUs must have no VIRQ or IPI bindings. */ -for (cpu =1 ; cpu <NR_CPUS ; cpu++) { +for_each_possible_cpu (cpu) { +if (cpu ==0 ) +continue ;for (virq =0 ; virq <NR_VIRQS ; virq++)BUG_ON (per_cpu (virq_to_irq, cpu)[virq] !=-1 );for (ipi =0 ; ipi <NR_IPIS ; ipi++)
@@ -813,23 +815,12 @@ void irq_resume(void)void __init xen_init_IRQ (void ) {int i; -int cpu;init_evtchn_cpu_bindings (); -/* No VIRQ or IPI bindings. */ -for (cpu =0 ; cpu <NR_CPUS ; cpu++) { -for (i =0 ; i <NR_VIRQS ; i++) -per_cpu (virq_to_irq, cpu)[i] =-1 ; -for (i =0 ; i <NR_IPIS ; i++) -per_cpu (ipi_to_irq, cpu)[i] =-1 ; - } - -/* No event-channel -> IRQ mappings. */ -for (i =0 ; i <NR_EVENT_CHANNELS ; i++) { - evtchn_to_irq[i] =-1 ; -mask_evtchn (i);/* No event channels are 'live' right now. */ - } +/* No event channels are 'live' right now. */ +for (i =0 ; i <NR_EVENT_CHANNELS ; i++) +mask_evtchn (i);/* No IRQ -> event-channel mappings. */ for (i =0 ; i <NR_IRQS ; i++)