linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 10/19] UML - Remove spinlock wrapper functions
@ 2006-07-07  0:33 Jeff Dike
       [not found] ` <517e86fb0608040600n52f36b8ci60f4e219f8cd4b5a@mail.gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Dike @ 2006-07-07  0:33 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, user-mode-linux-devel

The irq_spinlock is not needed from user code any more, so the
irq_lock and irq_unlock wrappers can go away.  This also changes the
name of the lock to irq_lock.

Signed-off-by: Jeff Dike <jdike@addtoit.com>

Index: linux-2.6.17/arch/um/include/irq_user.h
===================================================================
--- linux-2.6.17.orig/arch/um/include/irq_user.h	2006-07-06 13:27:58.000000000 -0400
+++ linux-2.6.17/arch/um/include/irq_user.h	2006-07-06 13:28:14.000000000 -0400
@@ -29,8 +29,6 @@ extern void reactivate_fd(int fd, int ir
 extern void deactivate_fd(int fd, int irqnum);
 extern int deactivate_all_fds(void);
 extern int activate_ipi(int fd, int pid);
-extern unsigned long irq_lock(void);
-extern void irq_unlock(unsigned long flags);
 
 #ifdef CONFIG_MODE_TT
 extern void forward_interrupts(int pid);
Index: linux-2.6.17/arch/um/kernel/irq.c
===================================================================
--- linux-2.6.17.orig/arch/um/kernel/irq.c	2006-07-06 13:27:58.000000000 -0400
+++ linux-2.6.17/arch/um/kernel/irq.c	2006-07-06 13:28:43.000000000 -0400
@@ -123,6 +123,8 @@ static void maybe_sigio_broken(int fd, i
 	}
 }
 
+static DEFINE_SPINLOCK(irq_lock);
+
 int activate_fd(int irq, int fd, int type, void *dev_id)
 {
 	struct pollfd *tmp_pfd;
@@ -166,7 +168,7 @@ int activate_fd(int irq, int fd, int typ
 	 * this is called only from process context, and can be locked with
 	 * a semaphore.
 	 */
-	flags = irq_lock();
+	spin_lock_irqsave(&irq_lock, flags);
 	for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) {
 		if ((irq_fd->fd == fd) && (irq_fd->type == type)) {
 			printk("Registering fd %d twice\n", fd);
@@ -199,7 +201,7 @@ int activate_fd(int irq, int fd, int typ
 		 * so we will not be able to put new pollfd struct to pollfds
 		 * then we free the buffer tmp_fds and try again.
 		 */
-		irq_unlock(flags);
+		spin_unlock_irqrestore(&irq_lock, flags);
 		kfree(tmp_pfd);
 		tmp_pfd = NULL;
 
@@ -207,14 +209,14 @@ int activate_fd(int irq, int fd, int typ
 		if (tmp_pfd == NULL)
 			goto out_kfree;
 
-		flags = irq_lock();
+		spin_lock_irqsave(&irq_lock, flags);
 	}
 	/*-------------*/
 
 	*last_irq_ptr = new_fd;
 	last_irq_ptr = &new_fd->next;
 
-	irq_unlock(flags);
+	spin_unlock_irqrestore(&irq_lock, flags);
 
 	/* This calls activate_fd, so it has to be outside the critical
 	 * section.
@@ -224,7 +226,7 @@ int activate_fd(int irq, int fd, int typ
 	return(0);
 
  out_unlock:
-	irq_unlock(flags);
+	spin_unlock_irqrestore(&irq_lock, flags);
  out_kfree:
 	kfree(new_fd);
  out:
@@ -235,9 +237,9 @@ static void free_irq_by_cb(int (*test)(s
 {
 	unsigned long flags;
 
-	flags = irq_lock();
+	spin_lock_irqsave(&irq_lock, flags);
 	os_free_irq_by_cb(test, arg, active_fds, &last_irq_ptr);
-	irq_unlock(flags);
+	spin_unlock_irqrestore(&irq_lock, flags);
 }
 
 struct irq_and_dev {
@@ -304,14 +306,14 @@ void reactivate_fd(int fd, int irqnum)
 	unsigned long flags;
 	int i;
 
-	flags = irq_lock();
+	spin_lock_irqsave(&irq_lock, flags);
 	irq = find_irq_by_fd(fd, irqnum, &i);
 	if (irq == NULL) {
-		irq_unlock(flags);
+		spin_unlock_irqrestore(&irq_lock, flags);
 		return;
 	}
 	os_set_pollfd(i, irq->fd);
-	irq_unlock(flags);
+	spin_unlock_irqrestore(&irq_lock, flags);
 
 	/* This calls activate_fd, so it has to be outside the critical
 	 * section.
@@ -325,13 +327,13 @@ void deactivate_fd(int fd, int irqnum)
 	unsigned long flags;
 	int i;
 
-	flags = irq_lock();
+	spin_lock_irqsave(&irq_lock, flags);
 	irq = find_irq_by_fd(fd, irqnum, &i);
 	if (irq == NULL)
 		goto out;
 	os_set_pollfd(i, -1);
  out:
-	irq_unlock(flags);
+	spin_unlock_irqrestore(&irq_lock, flags);
 }
 
 int deactivate_all_fds(void)
@@ -357,7 +359,7 @@ void forward_interrupts(int pid)
 	unsigned long flags;
 	int err;
 
-	flags = irq_lock();
+	spin_lock_irqsave(&irq_lock, flags);
 	for (irq = active_fds; irq != NULL; irq = irq->next) {
 		err = os_set_owner(irq->fd, pid);
 		if (err < 0) {
@@ -370,7 +372,7 @@ void forward_interrupts(int pid)
 
 		irq->pid = pid;
 	}
-	irq_unlock(flags);
+	spin_unlock_irqrestore(&irq_lock, flags);
 }
 #endif
 
@@ -405,21 +407,6 @@ int um_request_irq(unsigned int irq, int
 EXPORT_SYMBOL(um_request_irq);
 EXPORT_SYMBOL(reactivate_fd);
 
-static DEFINE_SPINLOCK(irq_spinlock);
-
-unsigned long irq_lock(void)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&irq_spinlock, flags);
-	return flags;
-}
-
-void irq_unlock(unsigned long flags)
-{
-	spin_unlock_irqrestore(&irq_spinlock, flags);
-}
-
 /* hw_interrupt_type must define (startup || enable) &&
  * (shutdown || disable) && end */
 static void dummy(unsigned int irq)


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

* [uml-devel] [PATCH 10/19] UML - Remove spinlock wrapper functions
       [not found] ` <517e86fb0608040600n52f36b8ci60f4e219f8cd4b5a@mail.gmail.com>
@ 2006-08-04 13:02   ` alessandro salvatori
  2006-08-04 14:14   ` Jeff Dike
  2006-08-05 11:47   ` Blaisorblade
  2 siblings, 0 replies; 4+ messages in thread
From: alessandro salvatori @ 2006-08-04 13:02 UTC (permalink / raw)
  To: linux-kernel

Jeff,

    the new lock irq_lock is still static, but we now have
preprocessor macros to be included from a header file instead of
non-static functions in the same module as the static irq_lock.

 Am I missing something?

 cheers
 Alessandro Salvatori


On 7/7/06, Jeff Dike <jdike@addtoit.com> wrote:
>  The irq_spinlock is not needed from user code any more, so the
> irq_lock and irq_unlock wrappers can go away.  This also changes the
> name of the lock to irq_lock.
>
> Signed-off-by: Jeff Dike < jdike@addtoit.com>
>
> Index: linux-2.6.17/arch/um/include/irq_user.h
> ===================================================================
> --- linux-2.6.17.orig/arch/um/include/irq_user.h        2006-07-06 13:27:58.000000000 -0400
> +++ linux-2.6.17/arch/um/include/irq_user.h     2006-07-06 13:28:14.000000000 -0400
> @@ -29,8 +29,6 @@ extern void reactivate_fd(int fd, int ir
>  extern void deactivate_fd(int fd, int irqnum);
>  extern int deactivate_all_fds(void);
>  extern int activate_ipi(int fd, int pid);
> -extern unsigned long irq_lock(void);
> -extern void irq_unlock(unsigned long flags);
>
>  #ifdef CONFIG_MODE_TT
>  extern void forward_interrupts(int pid);
> Index: linux-2.6.17/arch/um/kernel/irq.c
> ===================================================================
> --- linux-2.6.17.orig/arch/um/kernel/irq.c      2006-07-06 13:27:58.000000000 -0400
> +++ linux-2.6.17 /arch/um/kernel/irq.c   2006-07-06 13:28:43.000000000 -0400
> @@ -123,6 +123,8 @@ static void maybe_sigio_broken(int fd, i
>         }
>  }
>
> +static DEFINE_SPINLOCK(irq_lock);
> +
>  int activate_fd(int irq, int fd, int type, void *dev_id)
>  {
>         struct pollfd *tmp_pfd;
> @@ -166,7 +168,7 @@ int activate_fd(int irq, int fd, int typ
>          * this is called only from process context, and can be locked with
>          * a semaphore.
>          */
> -       flags = irq_lock();
> +       spin_lock_irqsave(&irq_lock, flags);
>         for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) {
>                 if ((irq_fd->fd == fd) && (irq_fd->type == type)) {
>                         printk("Registering fd %d twice\n", fd);
> @@ -199,7 +201,7 @@ int activate_fd(int irq, int fd, int typ
>                  * so we will not be able to put new pollfd struct to pollfds
>                  * then we free the buffer tmp_fds and try again.
>                  */
> -               irq_unlock(flags);
> +               spin_unlock_irqrestore(&irq_lock, flags);
>                 kfree(tmp_pfd);
>                 tmp_pfd = NULL;
>
> @@ -207,14 +209,14 @@ int activate_fd(int irq, int fd, int typ
>                 if (tmp_pfd == NULL)
>                         goto out_kfree;
>
> -               flags = irq_lock();
> +               spin_lock_irqsave(&irq_lock, flags);
>         }
>         /*-------------*/
>
>         *last_irq_ptr = new_fd;
>         last_irq_ptr = &new_fd->next;
>
> -       irq_unlock(flags);
> +       spin_unlock_irqrestore(&irq_lock, flags);
>
>         /* This calls activate_fd, so it has to be outside the critical
>          * section.
> @@ -224,7 +226,7 @@ int activate_fd(int irq, int fd, int typ
>         return(0);
>
>   out_unlock:
> -       irq_unlock(flags);
> +       spin_unlock_irqrestore(&irq_lock, flags);
>   out_kfree:
>         kfree(new_fd);
>   out:
> @@ -235,9 +237,9 @@ static void free_irq_by_cb(int (*test)(s
>  {
>         unsigned long flags;
>
> -       flags = irq_lock();
> +       spin_lock_irqsave(&irq_lock, flags);
>         os_free_irq_by_cb(test, arg, active_fds, &last_irq_ptr);
> -       irq_unlock(flags);
> +       spin_unlock_irqrestore(&irq_lock, flags);
>  }
>
>  struct irq_and_dev {
> @@ -304,14 +306,14 @@ void reactivate_fd(int fd, int irqnum)
>         unsigned long flags;
>         int i;
>
> -       flags = irq_lock();
> +       spin_lock_irqsave(&irq_lock, flags);
>         irq = find_irq_by_fd(fd, irqnum, &i);
>         if (irq == NULL) {
> -               irq_unlock(flags);
> +               spin_unlock_irqrestore(&irq_lock, flags);
>                 return;
>         }
>         os_set_pollfd(i, irq->fd);
> -       irq_unlock(flags);
> +       spin_unlock_irqrestore(&irq_lock, flags);
>
>         /* This calls activate_fd, so it has to be outside the critical
>          * section.
> @@ -325,13 +327,13 @@ void deactivate_fd(int fd, int irqnum)
>         unsigned long flags;
>         int i;
>
> -       flags = irq_lock();
> +       spin_lock_irqsave(&irq_lock, flags);
>         irq = find_irq_by_fd(fd, irqnum, &i);
>         if (irq == NULL)
>                 goto out;
>         os_set_pollfd(i, -1);
>   out:
> -       irq_unlock(flags);
> +       spin_unlock_irqrestore(&irq_lock, flags);
>  }
>
>  int deactivate_all_fds(void)
> @@ -357,7 +359,7 @@ void forward_interrupts(int pid)
>         unsigned long flags;
>         int err;
>
> -       flags = irq_lock();
> +       spin_lock_irqsave(&irq_lock, flags);
>         for (irq = active_fds; irq != NULL; irq = irq->next) {
>                 err = os_set_owner(irq->fd, pid);
>                 if (err < 0) {
> @@ -370,7 +372,7 @@ void forward_interrupts(int pid)
>
>                 irq->pid = pid;
>         }
> -       irq_unlock(flags);
> +       spin_unlock_irqrestore(&irq_lock, flags);
>  }
>  #endif
>
> @@ -405,21 +407,6 @@ int um_request_irq(unsigned int irq, int
>  EXPORT_SYMBOL(um_request_irq);
>  EXPORT_SYMBOL(reactivate_fd);
>
> -static DEFINE_SPINLOCK(irq_spinlock);
> -
> -unsigned long irq_lock(void)
> -{
> -       unsigned long flags;
> -
> -       spin_lock_irqsave(&irq_spinlock, flags);
> -       return flags;
> -}
> -
> -void irq_unlock(unsigned long flags)
> -{
> -       spin_unlock_irqrestore(&irq_spinlock, flags);
> -}
> -
>  /* hw_interrupt_type must define (startup || enable) &&
>   * (shutdown || disable) && end */
>  static void dummy(unsigned int irq)
>
>
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>  http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> User-mode-linux-devel mailing list
>  User-mode-linux-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
>



-- 
Alessandro Salvatori

-- 
Alessandro Salvatori

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

* Re: [uml-devel] [PATCH 10/19] UML - Remove spinlock wrapper functions
       [not found] ` <517e86fb0608040600n52f36b8ci60f4e219f8cd4b5a@mail.gmail.com>
  2006-08-04 13:02   ` [uml-devel] " alessandro salvatori
@ 2006-08-04 14:14   ` Jeff Dike
  2006-08-05 11:47   ` Blaisorblade
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Dike @ 2006-08-04 14:14 UTC (permalink / raw)
  To: alessandro salvatori; +Cc: akpm, linux-kernel, user-mode-linux-devel

On Fri, Aug 04, 2006 at 01:00:43PM +0000, alessandro salvatori wrote:
>   the new lock irq_lock is still static, but we now have preprocessor
> macros to be included from a header file instead of non-static functions in
> the same module as the static irq_lock.

I don't understand.  The changes in this patch are -
	remove two functions and their declarations
	replace calls to those functions with spin_lock_irq_save and
spin_unlock_irqsave
	move the spinlock declaration above the spin_(un)lock_irq_save
calls

Which of these are you talking about?

				Jeff

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

* Re: [uml-devel] [PATCH 10/19] UML - Remove spinlock wrapper functions
       [not found] ` <517e86fb0608040600n52f36b8ci60f4e219f8cd4b5a@mail.gmail.com>
  2006-08-04 13:02   ` [uml-devel] " alessandro salvatori
  2006-08-04 14:14   ` Jeff Dike
@ 2006-08-05 11:47   ` Blaisorblade
  2 siblings, 0 replies; 4+ messages in thread
From: Blaisorblade @ 2006-08-05 11:47 UTC (permalink / raw)
  To: user-mode-linux-devel, sandr8; +Cc: Jeff Dike, linux-kernel

On Friday 04 August 2006 15:00, alessandro salvatori wrote:
> Jeff,
>
>    the new lock irq_lock is still static, but we now have preprocessor
> macros to be included from a header file

Are you talking about spin_lock_irqsave & co? In that case you have maybe 
missed that the removed functions were simply wrappers for spin_lock_irqsave. 
Those wrappers existed to be used in files which can't include kernel headers 
(long story).

> instead of non-static functions in 
> the same module as the static irq_lock.

> Am I missing something?
-- 
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 

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

end of thread, other threads:[~2006-08-05 11:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-07  0:33 [PATCH 10/19] UML - Remove spinlock wrapper functions Jeff Dike
     [not found] ` <517e86fb0608040600n52f36b8ci60f4e219f8cd4b5a@mail.gmail.com>
2006-08-04 13:02   ` [uml-devel] " alessandro salvatori
2006-08-04 14:14   ` Jeff Dike
2006-08-05 11:47   ` Blaisorblade

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).