Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Jun 1999 23:22:33 -0500
From:      Alan Cox <alc@cs.rice.edu>
To:        smp@freebsd.org
Subject:   try this...
Message-ID:  <19990627232233.K2738@cs.rice.edu>

next in thread | raw e-mail | index | archive | help

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii

This patch eliminates pointless lock acquires/releases from critical
sections in the ipl code that consist of single atomic read-modify-write
instruction.

When I hear a few positive reports, I'll commit this patch.

Alan

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ipl_funcs.c.patch"

Index: i386/isa/ipl_funcs.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/isa/ipl_funcs.c,v
retrieving revision 1.20
diff -c -r1.20 ipl_funcs.c
*** ipl_funcs.c	1999/05/09 23:40:29	1.20
--- ipl_funcs.c	1999/06/27 18:30:02
***************
*** 35,62 ****
  /*
   * The volatile bitmap variables must be set atomically.  This normally
   * involves using a machine-dependent bit-set or `or' instruction.
   */
- #ifndef SMP
- 
  #define DO_SETBITS(name, var, bits) \
  void name(void)					\
  {						\
  	setbits(var, bits);			\
  }
  
  #else /* !SMP */
! 
! #define DO_SETBITS(name, var, bits)		\
! void name(void)					\
! {						\
! 	IFCPL_LOCK();				\
! 	setbits(var, bits);			\
! 	IFCPL_UNLOCK();				\
  }
- 
  #endif /* !SMP */
  
- DO_SETBITS(setdelayed,   &ipending, loadandclear(&idelayed))
  DO_SETBITS(setsoftast,   &ipending, SWI_AST_PENDING)
  DO_SETBITS(setsoftcamnet,&ipending, SWI_CAMNET_PENDING)
  DO_SETBITS(setsoftcambio,&ipending, SWI_CAMBIO_PENDING)
--- 35,60 ----
  /*
   * The volatile bitmap variables must be set atomically.  This normally
   * involves using a machine-dependent bit-set or `or' instruction.
+  *
+  * If setbits is atomic, this is MP-safe.
   */
  #define DO_SETBITS(name, var, bits) \
  void name(void)					\
  {						\
  	setbits(var, bits);			\
  }
  
+ #ifndef SMP
+ DO_SETBITS(setdelayed,   &ipending, loadandclear(&idelayed))
  #else /* !SMP */
! void setdelayed(void)
! {
! 	IFCPL_LOCK();
! 	setbits(&ipending, loadandclear(&idelayed));
! 	IFCPL_UNLOCK();
  }
  #endif /* !SMP */
  
  DO_SETBITS(setsoftast,   &ipending, SWI_AST_PENDING)
  DO_SETBITS(setsoftcamnet,&ipending, SWI_CAMNET_PENDING)
  DO_SETBITS(setsoftcambio,&ipending, SWI_CAMBIO_PENDING)
***************
*** 71,84 ****
  DO_SETBITS(schedsofttty, &idelayed, SWI_TTY_PENDING)
  DO_SETBITS(schedsoftvm,	&idelayed, SWI_VM_PENDING)
  
- #ifndef SMP
- 
  unsigned
  softclockpending(void)
  {
  	return (ipending & SWI_CLOCK_PENDING);
  }
  
  #define	GENSPL(name, set_cpl) \
  unsigned name(void)				\
  {						\
--- 69,82 ----
  DO_SETBITS(schedsofttty, &idelayed, SWI_TTY_PENDING)
  DO_SETBITS(schedsoftvm,	&idelayed, SWI_VM_PENDING)
  
  unsigned
  softclockpending(void)
  {
  	return (ipending & SWI_CLOCK_PENDING);
  }
  
+ #ifndef SMP
+ 
  #define	GENSPL(name, set_cpl) \
  unsigned name(void)				\
  {						\
***************
*** 142,160 ****
  #define POSTCODE_LO(X)
  #define POSTCODE_HI(X)
  #endif /* SPL_DEBUG_POSTCODE */
- 
- 
- unsigned
- softclockpending(void)
- {
- 	unsigned x;
- 
- 	IFCPL_LOCK();
- 	x = ipending & SWI_CLOCK_PENDING;
- 	IFCPL_UNLOCK();
- 
- 	return (x);
- }
  
  
  /*
--- 140,145 ----

--J2SCkAp4GZ/dPZZf--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-smp" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990627232233.K2738>