On Wed, 18 Dec 2002, John Baldwin wrote:

> On 18-Dec-2002 Terry Lambert wrote:
> > The pessimization that was being discussed right before that happened
> > was "harvesting entropy for /dev/random".  I can provide mailing list
> > quotes about that bracketing those dates.
>
> No, the pessimization is:
>
> #if defined(I386_CPU) || defined(CPU_DISABLE_CMPXCHG)
>
> static __inline int
> atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
> {
>         int res = exp;
>
>         __asm __volatile(
>         "       pushfl ;                "
>         "       cli ;                   "
>         "       cmpl    %0,%2 ;         "
>         "       jne     1f ;            "
>         "       movl    %1,%2 ;         "
>         "1:                             "
>         "       sete    %%al;           "
>         "       movzbl  %%al,%0 ;       "
>         "       popfl ;                 "
>         "# atomic_cmpset_int"
>         : "+a" (res)                    /* 0 (result) */
>         : "r" (src),                    /* 1 */
>           "m" (*(dst))                  /* 2 */
>         : "memory");
>
>         return (res);
> }
>
> #else /* defined(I386_CPU) */
>
> static __inline int
> atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
> {
>         int res = exp;
>
>         __asm __volatile (
>         "       " __XSTRING(MPLOCKED) " "
>         "       cmpxchgl %1,%2 ;        "
>         "       setz    %%al ;          "
>         "       movzbl  %%al,%0 ;       "
>         "1:                             "
>         "# atomic_cmpset_int"
>         : "+a" (res)                    /* 0 (result) */
>         : "r" (src),                    /* 1 */
>           "m" (*(dst))                  /* 2 */
>         : "memory");
>
>         return (res);
> }
>
> #endif /* defined(I386_CPU) */
>
> > Was there a particular pessimization other than /dev/random that you
> > were thinking of when you made the commit comment?
>
> Yes, the one above.  It came in as part of SMPng.

I think this is an insignificant pessimization (except for vmware).  The
main issue is that the i386 version doesn't actually work for SMP.  It
would need to be more comlicated and pessimal to work.

BTW, I have micro-optimized the above (to usually avoid the movzbl and
to allocate registers better, especially the hard register %al).  One
reason that I haven't committed the changes is that I haven't got around
to testing them for the CPU_I386 case.

Bruce


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to