Skip to contentSkip to conversation

unified spinlock initialization

PATCH New Matthew Wilcox 5 participants 16 messages Jan 20, 2005 – Jan 25, 2005

Subsystems (6)
lore
Share & tools
lore
#0 lore raw
Quoted 1 line · Amit Gud

Unify the spinlock initialization as far as possible.

Why would you want to replace a statically initialised spinlock with one that's initialised at runtime?

Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw

PATCH 1/1 unified spinlock initialization

Unify the spinlock initialization as far as possible.

Do consider applying.

arch/um/drivers/net_kern.c +5 -3
@@ -30,7 +30,7 @@
 #include "irq_user.h"
 #include "irq_kern.h"
 
-static spinlock_t opened_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t opened_lock;
 LIST_HEAD(opened);
 
 static int uml_net_rx(struct net_device *dev)
@@ -286,7 +286,7 @@ void uml_net_user_timer_expire(unsigned 
 #endif
 }
 
-static spinlock_t devices_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t devices_lock;
 static struct list_head devices = LIST_HEAD_INIT(devices);
 
 static int eth_configure(int n, void *init, char *mac,
@@ -371,7 +371,6 @@ static int eth_configure(int n, void *in
 	save = lp->user[0];
 	*lp = ((struct uml_net_private)
 		{ .list  		= LIST_HEAD_INIT(lp->list),
-		  .lock 		= SPIN_LOCK_UNLOCKED,
 		  .dev 			= dev,
 		  .fd 			= -1,
 		  .mac 			= { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0},
@@ -387,6 +386,7 @@ static int eth_configure(int n, void *in
 		  .set_mtu 		= transport->user->set_mtu,
 		  .user  		= { save } });
 
+	spin_lock_init(&lp->lock);
 	init_timer(&lp->tl);
 	lp->tl.function = uml_net_user_timer_expire;
 	if (lp->have_mac)
@@ -679,6 +679,8 @@ static int uml_net_init(void)
 	struct in_device *ip;
 	struct in_ifaddr *in;
 
+	spin_lock_init(&opened_lock);
+	spin_lock_init(&devices_lock);
 	mconsole_register_dev(&net_mc);
 	register_inetaddr_notifier(&uml_inetaddr_notifier);
 

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw

PATCH 1/1 unified spinlock initialization

In reply to Matthew Wilcox

Unify the spinlock initialization as far as possible.

Do consider applying.

arch/um/drivers/mconsole_kern.c +2 -2
@@ -454,12 +454,14 @@ void mconsole_sysrq(struct mc_request *r
  * active.
  */
 static char *notify_socket = NULL; 
+static spinlock_t notify_spinlock;
 
 int mconsole_init(void)
 {
 	int err, sock;
 	char file[256];
 
+	spin_lock_init(&notify_spinlock);
 	if(umid_file_name("mconsole", file, sizeof(file))) return(-1);
 	snprintf(mconsole_socket_name, sizeof(file), "%s", file);
 
@@ -535,8 +537,6 @@ static int create_proc_mconsole(void)
 	return(0);
 }
 
-static spinlock_t notify_spinlock = SPIN_LOCK_UNLOCKED;
-
 void lock_notify(void)
 {
 	spin_lock(&notify_spinlock);

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#3 lore raw

PATCH 1/1 unified spinlock initialization

In reply to Matthew Wilcox

Unify the spinlock initialization as far as possible.

Do consider applying.

arch/um/drivers/port_kern.c +1 -1
@@ -185,11 +185,11 @@ void *port_data(int port_num)
 		  .has_connection 	= 0,
 		  .sem 			= __SEMAPHORE_INITIALIZER(port->sem, 
 								  0),
-		  .lock 		= SPIN_LOCK_UNLOCKED,
 		  .port 	 	= port_num,
 		  .fd  			= fd,
 		  .pending 		= LIST_HEAD_INIT(port->pending),
 		  .connections 		= LIST_HEAD_INIT(port->connections) });
+	spin_lock_init(&port->lock);
 	list_add(&port->list, &ports);
 
  found:

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#4 lore raw

PATCH 1/1 unified spinlock initialization

In reply to Matthew Wilcox

Unify the spinlock initialization as far as possible.

Do consider applying.

arch/um/drivers/ubd_kern.c +5 -2
@@ -54,8 +54,8 @@
 #include "mem.h"
 #include "mem_kern.h"
 
-static spinlock_t ubd_io_lock = SPIN_LOCK_UNLOCKED;
-static spinlock_t ubd_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t ubd_io_lock;
+static spinlock_t ubd_lock;
 
 static void (*do_ubd)(void);
 
@@ -744,6 +744,9 @@ int ubd_init(void)
 {
         int i;
 
+	spin_lock_init(&ubd_lock);
+	spin_lock_init(&ubd_io_lock);
+
 	devfs_mk_dir("ubd");
 	if (register_blkdev(MAJOR_NR, "ubd"))
 		return -1;

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#5 lore raw

PATCH 1/1 unified spinlock initialization drivers/acpi/ec.c

In reply to Matthew Wilcox

Unify the spinlock initialization as far as possible.

Do consider applying.

drivers/acpi/ec.c +2 -2
@@ -599,7 +599,7 @@ acpi_ec_add (
 
 	ec->handle = device->handle;
 	ec->uid = -1;
-	ec->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&ec->lock);
 	strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
 	strcpy(acpi_device_class(device), ACPI_EC_CLASS);
 	acpi_driver_data(device) = ec;
@@ -813,7 +813,7 @@ acpi_ec_ecdt_probe (void)
 	ec_ecdt->status_addr = ecdt_ptr->ec_control;
 	ec_ecdt->data_addr = ecdt_ptr->ec_data;
 	ec_ecdt->gpe_bit = ecdt_ptr->gpe_bit;
-	ec_ecdt->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&ec_ecdt->lock);
 	/* use the GL just to be safe */
 	ec_ecdt->global_lock = TRUE;
 	ec_ecdt->uid = ecdt_ptr->uid;

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#6 lore raw

PATCH 1/1 unified spinlock initialization

In reply to Matthew Wilcox

Unify the spinlock initialization as far as possible.

Do consider applying.

drivers/block/cciss_scsi.c +1 -1
@@ -534,7 +534,7 @@ cciss_scsi_setup(int cntl_num)
 	if (shba == NULL)
 		return;
 	shba->scsi_host = NULL;
-	shba->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&shba->lock);
 	shba->registered = 0;
 	if (scsi_cmd_stack_setup(cntl_num, shba) != 0) {
 		kfree(shba);

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#7 lore raw

PATCH 1/1 unified spinlock initialization drivers/block/DAC960.c

In reply to Matthew Wilcox

Unify the spinlock initialization as far as possible.

Do consider applying.

drivers/block/DAC960.c +1 -1
@@ -2738,7 +2738,7 @@ DAC960_DetectController(struct pci_dev *
   }
   init_waitqueue_head(&Controller->CommandWaitQueue);
   init_waitqueue_head(&Controller->HealthStatusWaitQueue);
-  Controller->queue_lock = SPIN_LOCK_UNLOCKED; 
+  spin_lock_init(&Controller->queue_lock); 
   DAC960_AnnounceDriver(Controller);
   /*
     Map the Controller Register Window.

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#8 lore raw

PATCH 1/1 unified spinlock initialization

In reply to Matthew Wilcox

Unify the spinlock initialization as far as possible.

Do consider applying.

drivers/char/drm/drm_auth.h +3 -2
@@ -174,11 +174,12 @@ int DRM(getmagic)(struct inode *inode, s
 		  unsigned int cmd, unsigned long arg)
 {
 	static drm_magic_t sequence = 0;
-	static spinlock_t  lock	    = SPIN_LOCK_UNLOCKED;
+	static spinlock_t  lock;
 	drm_file_t	   *priv    = filp->private_data;
 	drm_device_t	   *dev	    = priv->dev;
 	drm_auth_t	   auth;
-
+	
+	spin_lock_init(&lock);
 				/* Find unique magic */
 	if (priv->magic) {
 		auth.magic = priv->magic;

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#9 lore raw

PATCH 1/1 unified spinlock initialization

In reply to Matthew Wilcox

Unify the spinlock initialization as far as possible.

Do consider applying.

drivers/char/drm/drm_drv.h +1 -1
@@ -447,7 +447,7 @@ static int DRM(probe)(struct pci_dev *pd
 	dev = &(DRM(device)[DRM(numdevs)]);
 
 	memset( (void *)dev, 0, sizeof(*dev) );
-	dev->count_lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&dev->count_lock);
 	init_timer( &dev->timer );
 	sema_init( &dev->struct_sem, 1 );
 	sema_init( &dev->ctxlist_sem, 1 );

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#10 lore raw
In reply to Matthew Wilcox
Quoted 11 lines · Christophe Lucas

In: drivers/misc/ibmasm/module.c

------------------------------------------------------------------------

diff -urbNB linux-2.6.10-vanilla/drivers/misc/ibmasm/module.c linux-2.6.10/drivers/misc/ibmasm/module.c

drivers/misc/ibmasm/module.c line 110

Quoted 5 lines
drivers/misc/ibmasm/module.c +1 -1
@@ -107,7 +107,7 @@
 		goto error_remote_queue;
 	}
 
-	sp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init( &sp->lock );

Please lose those spaces... that's not kernel coding style.

Signature · 5 lines
~Randy
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
#11 lore raw

PATCH 1/1 unified spinlock initialization

In reply to Matthew Wilcox

In: drivers/misc/ibmasm/module.c

Signature · 1 line
Christophe
drivers/misc/ibmasm/module.c +1 -1
diff -urbNB linux-2.6.10-vanilla/drivers/misc/ibmasm/module.c linux-2.6.10/drivers/misc/ibmasm/module.c
@@ -107,7 +107,7 @@
 		goto error_remote_queue;
 	}
 
-	sp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init( &sp->lock );
 	INIT_LIST_HEAD(&sp->command_queue);
 
 	result = request_irq(sp->irq, ibmasm_interrupt_handler, SA_SHIRQ, sp->devname, (void*)sp);
#12 lore raw
In reply to Matthew Wilcox

Already done in 2.6.11-rc2, look below for some comments.

Quoted 9 lines · Amit Gud

Unify the spinlock initialization as far as possible.

Do consider applying.

drivers/char/drm/drm_auth.h int DRM(getmagic)(struct inode *inode, s · line 181

Quoted 10 lines
drivers/char/drm/drm_auth.h +2 -2
@@ -174,11 +174,12 @@ int DRM(getmagic)(struct inode *inode, s
 		  unsigned int cmd, unsigned long arg)
 {
 	static drm_magic_t sequence = 0;
-	static spinlock_t  lock	    = SPIN_LOCK_UNLOCKED;
+	static spinlock_t  lock;
 	drm_file_t	   *priv    = filp->private_data;
 	drm_device_t	   *dev	    = priv->dev;
 	drm_auth_t	   auth;
-
+	

You added whitespace.

drivers/char/drm/drm_auth.h int DRM(getmagic)(struct inode *inode, s · line 182

Quoted 1 line
drivers/char/drm/drm_auth.h +1 -0
+	spin_lock_init(&lock);

This changes behaviour, because of static lock wasn't initialized on every function run, now it is, which makes it rather useless.

Correct way to do this seems to be what is already in 2.6.11-rc2 in drm_auth.c:

	static drm_magic_t sequence = 0;
	static DEFINE_SPINLOCK(lock);
	drm_file_t         *priv    = filp->private_data;



	Domen

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#13 lore raw
In reply to Matthew Wilcox
Quoted 18 lines · Randy.Dunlap
Quoted 17 lines · Christophe Lucas

In: drivers/misc/ibmasm/module.c

------------------------------------------------------------------------

diff -urbNB linux-2.6.10-vanilla/drivers/misc/ibmasm/module.c linux-2.6.10/drivers/misc/ibmasm/module.c
--- linux-2.6.10-vanilla/drivers/misc/ibmasm/module.c 2005-01-24
17:08:09.000000000 +0100
+++ linux-2.6.10/drivers/misc/ibmasm/module.c 2005-01-24
17:18:31.000000000 +0100

(quoted diff) +0 -0
@@ -107,7 +107,7 @@
 		goto error_remote_queue;
 	}
 
Quoted 4 lines

Review line 110

Quoted 2 lines
(quoted diff) +1 -1
-	sp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init( &sp->lock );

Please lose those spaces... that's not kernel coding style.

Hi,

Thanks Randy,
Here is the corrected patch.
In: drivers/misc/ibmasm/module.c

Have a good day :)

Signature · 1 line
Christophe
drivers/misc/ibmasm/module.c +1 -1
diff -urbNB linux-2.6.10-vanilla/drivers/misc/ibmasm/module.c linux-2.6.10/drivers/misc/ibmasm/module.c
@@ -107,7 +107,7 @@
 		goto error_remote_queue;
 	}
 
-	sp->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&sp->lock);
 	INIT_LIST_HEAD(&sp->command_queue);
 
 	result = request_irq(sp->irq, ibmasm_interrupt_handler, SA_SHIRQ, sp->devname, (void*)sp);

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#14 lore raw

PATCH 1/1 Unified spinlock initialization

In reply to Matthew Wilcox

Unified spinlock initialization.

Signature · 1 line
Christophe
drivers/media/dvb/b2c2/skystar2.c +1 -1
diff -urB linux-2.6.10-vanilla/drivers/media/dvb/b2c2/skystar2.c linux-2.6.10/drivers/media/dvb/b2c2/skystar2.c
@@ -1979,7 +1979,7 @@
 		ctrl_enable_mac(adapter, 1);
 	}
 
-	adapter->lock = SPIN_LOCK_UNLOCKED;
+	spin_lock_init(&adapter->lock);
 
 	return 0;
 }

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors