Print this page
11909 THREAD_KPRI_RELEASE does nothing of the sort
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/ia32/ml/lock_prim.s
          +++ new/usr/src/uts/intel/ia32/ml/lock_prim.s
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + * Copyright 2019 Joyent, Inc.
  24   25   */
  25   26  
  26      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  27      -
  28   27  #if defined(lint) || defined(__lint)
  29   28  #include <sys/types.h>
  30   29  #include <sys/thread.h>
  31   30  #include <sys/cpuvar.h>
  32   31  #include <vm/page.h>
  33   32  #else   /* __lint */
  34   33  #include "assym.h"
  35   34  #endif  /* __lint */
  36   35  
  37   36  #include <sys/mutex_impl.h>
↓ open down ↓ 277 lines elided ↑ open up ↑
 315  314          leave                           /* unwind stack */
 316  315          jmp     lock_set_spl_spin
 317  316          SET_SIZE(lock_set_spl)
 318  317  
 319  318  #else
 320  319  
 321  320          ENTRY(lock_set_spl)
 322  321          movl    8(%esp), %eax           /* get priority level */
 323  322          pushl   %eax
 324  323          call    splr                    /* raise priority level */
 325      -        movl    8(%esp), %ecx           /* ecx = lock addr */
      324 +        movl    8(%esp), %ecx           /* ecx = lock addr */
 326  325          movl    $-1, %edx
 327  326          addl    $4, %esp
 328  327          xchgb   %dl, (%ecx)             /* try to set lock */
 329  328          testb   %dl, %dl                /* did we get the lock? ... */
 330  329          movl    12(%esp), %edx          /* edx = olp pil addr (ZF unaffected) */
 331  330          jnz     .lss_miss               /* ... no, go to C for the hard case */
 332  331          movw    %ax, (%edx)             /* store old pil */
 333  332  .lock_set_spl_lockstat_patch_point:
 334  333          ret
 335  334          movl    %gs:CPU_THREAD, %edx    /* edx = thread addr*/
↓ open down ↓ 226 lines elided ↑ open up ↑
 562  561          xorl    %eax, %eax                      /* rax = 0 (unheld adaptive) */
 563  562          lock
 564  563          cmpxchgq %rdx, (%rdi)
 565  564          jnz     mutex_vector_enter
 566  565  .mutex_enter_lockstat_patch_point:
 567  566  #if defined(OPTERON_WORKAROUND_6323525)
 568  567  .mutex_enter_6323525_patch_point:
 569  568          ret                                     /* nop space for lfence */
 570  569          nop
 571  570          nop
 572      -.mutex_enter_lockstat_6323525_patch_point:      /* new patch point if lfence */ 
      571 +.mutex_enter_lockstat_6323525_patch_point:      /* new patch point if lfence */
 573  572          nop
 574  573  #else   /* OPTERON_WORKAROUND_6323525 */
 575  574          ret
 576  575  #endif  /* OPTERON_WORKAROUND_6323525 */
 577  576          movq    %rdi, %rsi
 578  577          movl    $LS_MUTEX_ENTER_ACQUIRE, %edi
 579  578  /*
 580  579   * expects %rdx=thread, %rsi=lock, %edi=lockstat event
 581  580   */
 582  581          ALTENTRY(lockstat_wrapper)
↓ open down ↓ 328 lines elided ↑ open up ↑
 911  910  /* ARGSUSED */
 912  911  void
 913  912  rw_exit(krwlock_t *lp)
 914  913  {}
 915  914  
 916  915  #else   /* __lint */
 917  916  
 918  917  #if defined(__amd64)
 919  918  
 920  919          ENTRY(rw_enter)
 921      -        movq    %gs:CPU_THREAD, %rdx            /* rdx = thread ptr */
 922  920          cmpl    $RW_WRITER, %esi
 923  921          je      .rw_write_enter
 924      -        incl    T_KPRI_REQ(%rdx)                /* THREAD_KPRI_REQUEST() */
 925  922          movq    (%rdi), %rax                    /* rax = old rw_wwwh value */
 926  923          testl   $RW_WRITE_LOCKED|RW_WRITE_WANTED, %eax
 927  924          jnz     rw_enter_sleep
 928  925          leaq    RW_READ_LOCK(%rax), %rdx        /* rdx = new rw_wwwh value */
 929  926          lock
 930  927          cmpxchgq %rdx, (%rdi)                   /* try to grab read lock */
 931  928          jnz     rw_enter_sleep
 932  929  .rw_read_enter_lockstat_patch_point:
 933  930          ret
 934  931          movq    %gs:CPU_THREAD, %rcx            /* rcx = thread ptr */
 935  932          movq    %rdi, %rsi                      /* rsi = lock ptr */
 936  933          movl    $LS_RW_ENTER_ACQUIRE, %edi
 937  934          movl    $RW_READER, %edx
 938  935          jmp     lockstat_wrapper_arg
 939  936  .rw_write_enter:
      937 +        movq    %gs:CPU_THREAD, %rdx
 940  938          orq     $RW_WRITE_LOCKED, %rdx          /* rdx = write-locked value */
 941  939          xorl    %eax, %eax                      /* rax = unheld value */
 942  940          lock
 943  941          cmpxchgq %rdx, (%rdi)                   /* try to grab write lock */
 944  942          jnz     rw_enter_sleep
 945  943  
 946  944  #if defined(OPTERON_WORKAROUND_6323525)
 947  945  .rw_write_enter_lockstat_patch_point:
 948  946  .rw_write_enter_6323525_patch_point:
 949  947          ret
↓ open down ↓ 15 lines elided ↑ open up ↑
 965  963  
 966  964          ENTRY(rw_exit)
 967  965          movq    (%rdi), %rax                    /* rax = old rw_wwwh value */
 968  966          cmpl    $RW_READ_LOCK, %eax             /* single-reader, no waiters? */
 969  967          jne     .rw_not_single_reader
 970  968          xorl    %edx, %edx                      /* rdx = new value (unheld) */
 971  969  .rw_read_exit:
 972  970          lock
 973  971          cmpxchgq %rdx, (%rdi)                   /* try to drop read lock */
 974  972          jnz     rw_exit_wakeup
 975      -        movq    %gs:CPU_THREAD, %rcx            /* rcx = thread ptr */
 976      -        decl    T_KPRI_REQ(%rcx)                /* THREAD_KPRI_RELEASE() */
 977  973  .rw_read_exit_lockstat_patch_point:
 978  974          ret
      975 +        movq    %gs:CPU_THREAD, %rcx            /* rcx = thread ptr */
 979  976          movq    %rdi, %rsi                      /* rsi = lock ptr */
 980  977          movl    $LS_RW_EXIT_RELEASE, %edi
 981  978          movl    $RW_READER, %edx
 982  979          jmp     lockstat_wrapper_arg
 983  980  .rw_not_single_reader:
 984  981          testl   $RW_WRITE_LOCKED, %eax  /* write-locked or write-wanted? */
 985  982          jnz     .rw_write_exit
 986  983          leaq    -RW_READ_LOCK(%rax), %rdx       /* rdx = new value */
 987  984          cmpl    $RW_READ_LOCK, %edx
 988  985          jge     .rw_read_exit           /* not last reader, safe to drop */
↓ open down ↓ 10 lines elided ↑ open up ↑
 999  996          movq    %gs:CPU_THREAD, %rcx            /* rcx = thread ptr */
1000  997          movq    %rdi, %rsi                      /* rsi - lock ptr */
1001  998          movl    $LS_RW_EXIT_RELEASE, %edi
1002  999          movl    $RW_WRITER, %edx
1003 1000          jmp     lockstat_wrapper_arg
1004 1001          SET_SIZE(rw_exit)
1005 1002  
1006 1003  #else
1007 1004  
1008 1005          ENTRY(rw_enter)
1009      -        movl    %gs:CPU_THREAD, %edx            /* edx = thread ptr */
1010 1006          movl    4(%esp), %ecx                   /* ecx = lock ptr */
1011 1007          cmpl    $RW_WRITER, 8(%esp)
1012 1008          je      .rw_write_enter
1013      -        incl    T_KPRI_REQ(%edx)                /* THREAD_KPRI_REQUEST() */
1014 1009          movl    (%ecx), %eax                    /* eax = old rw_wwwh value */
1015 1010          testl   $RW_WRITE_LOCKED|RW_WRITE_WANTED, %eax
1016 1011          jnz     rw_enter_sleep
1017 1012          leal    RW_READ_LOCK(%eax), %edx        /* edx = new rw_wwwh value */
1018 1013          lock
1019 1014          cmpxchgl %edx, (%ecx)                   /* try to grab read lock */
1020 1015          jnz     rw_enter_sleep
1021 1016  .rw_read_enter_lockstat_patch_point:
1022 1017          ret
1023 1018          movl    %gs:CPU_THREAD, %edx            /* edx = thread ptr */
1024 1019          movl    $LS_RW_ENTER_ACQUIRE, %eax
1025 1020          pushl   $RW_READER
1026 1021          jmp     lockstat_wrapper_arg
1027 1022  .rw_write_enter:
     1023 +        movl    %gs:CPU_THREAD, %edx
1028 1024          orl     $RW_WRITE_LOCKED, %edx          /* edx = write-locked value */
1029 1025          xorl    %eax, %eax                      /* eax = unheld value */
1030 1026          lock
1031 1027          cmpxchgl %edx, (%ecx)                   /* try to grab write lock */
1032 1028          jnz     rw_enter_sleep
1033 1029  
1034 1030  #if defined(OPTERON_WORKAROUND_6323525)
1035 1031  .rw_write_enter_lockstat_patch_point:
1036 1032  .rw_write_enter_6323525_patch_point:
1037 1033          ret
↓ open down ↓ 15 lines elided ↑ open up ↑
1053 1049          ENTRY(rw_exit)
1054 1050          movl    4(%esp), %ecx                   /* ecx = lock ptr */
1055 1051          movl    (%ecx), %eax                    /* eax = old rw_wwwh value */
1056 1052          cmpl    $RW_READ_LOCK, %eax             /* single-reader, no waiters? */
1057 1053          jne     .rw_not_single_reader
1058 1054          xorl    %edx, %edx                      /* edx = new value (unheld) */
1059 1055  .rw_read_exit:
1060 1056          lock
1061 1057          cmpxchgl %edx, (%ecx)                   /* try to drop read lock */
1062 1058          jnz     rw_exit_wakeup
1063      -        movl    %gs:CPU_THREAD, %edx            /* edx = thread ptr */
1064      -        decl    T_KPRI_REQ(%edx)                /* THREAD_KPRI_RELEASE() */
1065 1059  .rw_read_exit_lockstat_patch_point:
1066 1060          ret
1067 1061          movl    $LS_RW_EXIT_RELEASE, %eax
1068 1062          pushl   $RW_READER
1069 1063          jmp     lockstat_wrapper_arg
1070 1064  .rw_not_single_reader:
1071 1065          testl   $RW_WRITE_LOCKED, %eax  /* write-locked or write-wanted? */
1072 1066          jnz     .rw_write_exit
1073 1067          leal    -RW_READ_LOCK(%eax), %edx       /* edx = new value */
1074 1068          cmpl    $RW_READ_LOCK, %edx
↓ open down ↓ 104 lines elided ↑ open up ↑
1179 1173  
1180 1174  
1181 1175  #else   /* __amd64 */
1182 1176  
1183 1177  #define HOT_MUTEX_PATCH(srcaddr, dstaddr, size) \
1184 1178          movl    $size, %ebx;                    \
1185 1179          movl    $srcaddr, %esi;                 \
1186 1180          addl    %ebx, %esi;                     \
1187 1181          movl    $dstaddr, %edi;                 \
1188 1182          addl    %ebx, %edi;                     \
1189      -0:                                              \
     1183 +0:                                              \
1190 1184          decl    %esi;                           \
1191 1185          decl    %edi;                           \
1192 1186          pushl   $1;                             \
1193 1187          movzbl  (%esi), %eax;                   \
1194 1188          pushl   %eax;                           \
1195 1189          pushl   %edi;                           \
1196 1190          call    hot_patch_kernel_text;          \
1197 1191          addl    $12, %esp;                      \
1198 1192          decl    %ebx;                           \
1199 1193          testl   %ebx, %ebx;                     \
↓ open down ↓ 38 lines elided ↑ open up ↑
1238 1232  {}
1239 1233  
1240 1234  #else
1241 1235  
1242 1236  #if defined(__amd64)
1243 1237  
1244 1238  #define HOT_PATCH(addr, event, active_instr, normal_instr, len) \
1245 1239          movq    $normal_instr, %rsi;            \
1246 1240          movq    $active_instr, %rdi;            \
1247 1241          leaq    lockstat_probemap(%rip), %rax;  \
1248      -        movl    _MUL(event, DTRACE_IDSIZE)(%rax), %eax; \
     1242 +        movl    _MUL(event, DTRACE_IDSIZE)(%rax), %eax; \
1249 1243          testl   %eax, %eax;                     \
1250 1244          jz      9f;                             \
1251 1245          movq    %rdi, %rsi;                     \
1252 1246  9:                                              \
1253 1247          movq    $len, %rdx;                     \
1254 1248          movq    $addr, %rdi;                    \
1255 1249          call    hot_patch_kernel_text
1256 1250  
1257 1251  #else
1258 1252  
↓ open down ↓ 241 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX