瀏覽代碼

rustsbi: faster IPI code path

slow down conditional legacy IPI procedure to speed up SBI v0.3+ faster IPI procedure

Signed-off-by: luojia65 <[email protected]>
luojia65 3 年之前
父節點
當前提交
5e19bb0a3c
共有 2 個文件被更改,包括 25 次插入7 次删除
  1. 13 0
      CHANGELOG.md
  2. 12 7
      src/hart_mask.rs

+ 13 - 0
CHANGELOG.md

@@ -11,6 +11,19 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ### Modified
 
+## [0.2.1] - 2022-02-14
+
+This update fixes a moderate bug on IPI module. The previous version of RustSBI did not follow the SBI definition of IPI
+module on SBI v0.3 format. Users are encouraged to use 0.2.1 and newer version instead of yanked 0.2.0 version.
+
+### Modified
+
+- Internal speed up to new SBI v0.3+ IPI procedure
+
+### Fixed
+
+- Severe bug on IPI does not follow new SBI version convention rule
+
 ## [0.2.0] - 2022-02-13
 
 ### Added

+ 12 - 7
src/hart_mask.rs

@@ -39,13 +39,7 @@ impl HartMask {
                 hart_mask & (1 << idx) != 0
             },
             MaskInner::Legacy { legacy_bit_vector } => {
-                fn split_index_usize(index: usize) -> (usize, usize) {
-                    let bits_in_usize = usize::BITS as usize;
-                    (index / bits_in_usize, index % bits_in_usize)
-                }
-                let (i, j) = split_index_usize(hart_id);
-                let cur_vector = unsafe { get_vaddr_usize(legacy_bit_vector.add(i)) };
-                cur_vector & (1 << j) != 0
+                slow_legacy_has_bit(legacy_bit_vector, hart_id)
             },
         }
     }
@@ -75,6 +69,17 @@ enum MaskInner {
     },
 }
 
+// not #[inline] to speed up new version bit vector
+fn slow_legacy_has_bit(legacy_bit_vector: *const usize, hart_id: usize) -> bool {
+    fn split_index_usize(index: usize) -> (usize, usize) {
+        let bits_in_usize = usize::BITS as usize;
+        (index / bits_in_usize, index % bits_in_usize)
+    }
+    let (i, j) = split_index_usize(hart_id);
+    let cur_vector = unsafe { get_vaddr_usize(legacy_bit_vector.add(i)) };
+    cur_vector & (1 << j) != 0
+}
+
 #[inline]
 unsafe fn get_vaddr_usize(vaddr_ptr: *const usize) -> usize {
     match () {