diff --git a/study/arch/cache/MESI/MESI.excalidraw b/study/arch/cache/MESI/MESI.excalidraw new file mode 100644 index 0000000..8f806a0 --- /dev/null +++ b/study/arch/cache/MESI/MESI.excalidraw @@ -0,0 +1,1615 @@ +{ + "type": "excalidraw", + "version": 2, + "source": "https://excalidraw.com", + "elements": [ + { + "type": "rectangle", + "version": 1007, + "versionNonce": 1339165786, + "isDeleted": false, + "id": "CNq3PGOAC9jr2aHgKrbG_", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 745.5, + "y": 323.2607469935061, + "strokeColor": "#000000", + "backgroundColor": "#e64980", + "width": 114.99999999999997, + "height": 59.00000000000001, + "seed": 1765051590, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB", + "QN25t4_XOP7-HRxAuV7Y2", + "DhBK1onobgdtoteMzJ3RY", + "EVuGS3oXm7jYXCy8DsY2V", + "7-zXi5_a33f7uUIc7_j_9", + "OWrGRSWgDTVld8aCb9xUP", + "E-FoU4T3WQM9Nik2oNqPM", + "3V9yHghrlRnpZ2-Gi6Pe0", + "OHu38dElAmMCwUtShaCwn" + ], + "updated": 1638367642123 + }, + { + "type": "rectangle", + "version": 829, + "versionNonce": 1466367558, + "isDeleted": false, + "id": "bEPljKT1QjIs-yG7VaRlm", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1140.5, + "y": 317.2607469935061, + "strokeColor": "#000000", + "backgroundColor": "#7950f2", + "width": 114.99999999999997, + "height": 59.00000000000001, + "seed": 1539050138, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB", + "QN25t4_XOP7-HRxAuV7Y2", + "DhBK1onobgdtoteMzJ3RY", + "EVuGS3oXm7jYXCy8DsY2V", + "7-zXi5_a33f7uUIc7_j_9", + "OWrGRSWgDTVld8aCb9xUP", + "E-FoU4T3WQM9Nik2oNqPM", + "2i0QSCxasOTq6N5sjdJWl", + "QWTrRjvIJMVbYjUOWAacR", + "t3OtENppztxvn0dyhHoAP" + ], + "updated": 1638367642123 + }, + { + "type": "text", + "version": 566, + "versionNonce": 1967354138, + "isDeleted": false, + "id": "-o2by5PrLDjgZmQxJSdz0", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 0, + "opacity": 100, + "angle": 0, + "x": 752.5, + "y": 325.7607469935061, + "strokeColor": "#000000", + "backgroundColor": "transparent", + "width": 101, + "height": 54, + "seed": 1439892486, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "-EmWpA2nW8UJxM6P5Jbs0", + "k8JNte_hwxkqg2BjJfc__", + "9FEdzAYah8pitSTf-LGQk", + "H227UL8DO58PoultG-rD8", + "B-RXA7KF8_NZ9Sf0teY41", + "lcE8G6b2mne9PdkVZRlo4", + "b7_BiCxtIYCGQCm9gq7Wu", + "u1b59y0ux8NpxUcDXQid6", + "lFm2K2wCiDp_pEonxUOBP", + "aXRsUQU5bs8xZdJHsXu4M", + "AHx3ER4u8btQqE9uX5rHb", + "JsUn8E2tYCdzcoDY7swV9" + ], + "updated": 1638367642123, + "fontSize": 20, + "fontFamily": 1, + "text": "M\n(modified)", + "baseline": 47, + "textAlign": "center", + "verticalAlign": "top" + }, + { + "type": "rectangle", + "version": 1015, + "versionNonce": 129713542, + "isDeleted": false, + "id": "Fl53F-jvn6e-CU3SN7XdI", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1140.75, + "y": 626.135746993506, + "strokeColor": "#000000", + "backgroundColor": "#868e96", + "width": 114.99999999999997, + "height": 59.00000000000001, + "seed": 1741924186, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB", + "QN25t4_XOP7-HRxAuV7Y2", + "DhBK1onobgdtoteMzJ3RY", + "EVuGS3oXm7jYXCy8DsY2V", + "7-zXi5_a33f7uUIc7_j_9", + "OWrGRSWgDTVld8aCb9xUP", + "E-FoU4T3WQM9Nik2oNqPM", + "3V9yHghrlRnpZ2-Gi6Pe0", + "OHu38dElAmMCwUtShaCwn", + "WCTdApSdr_ZQuHJqO4iUn", + "alLmUwc7SYTmHc-oNNwps", + "_1jCLdW2s9UwJ_ByaV9KZ", + "lFm2K2wCiDp_pEonxUOBP", + "aXRsUQU5bs8xZdJHsXu4M" + ], + "updated": 1638367642123 + }, + { + "type": "rectangle", + "version": 1077, + "versionNonce": 1487551962, + "isDeleted": false, + "id": "32Yo7NViUgvde8AJCckWY", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 751.75, + "y": 622.135746993506, + "strokeColor": "#000000", + "backgroundColor": "#82c91e", + "width": 114.99999999999997, + "height": 59.00000000000001, + "seed": 1847628614, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB", + "QN25t4_XOP7-HRxAuV7Y2", + "DhBK1onobgdtoteMzJ3RY", + "EVuGS3oXm7jYXCy8DsY2V", + "7-zXi5_a33f7uUIc7_j_9", + "OWrGRSWgDTVld8aCb9xUP", + "E-FoU4T3WQM9Nik2oNqPM", + "3V9yHghrlRnpZ2-Gi6Pe0", + "OHu38dElAmMCwUtShaCwn", + "WCTdApSdr_ZQuHJqO4iUn", + "H227UL8DO58PoultG-rD8", + "a62Wf715yk51SS1rAEUWR", + "EFXdz_kL5zHrlcWGEkWuc", + "iww4j6dseqijDCXxo8GK7" + ], + "updated": 1638367642123 + }, + { + "type": "arrow", + "version": 1086, + "versionNonce": 210019526, + "isDeleted": false, + "id": "nI5724TfjqH6Qe3Yy_wpp", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1219.9825179720428, + "y": 378.94267158948804, + "strokeColor": "#c92a2a", + "backgroundColor": "#e64980", + "width": 0.5193957591786784, + "height": 246.9850190137326, + "seed": 1884924954, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642123, + "startBinding": { + "elementId": "xsLMoxFY35BgnSQOjZh6X", + "focus": -0.4292249019556205, + "gap": 5.181924595981968 + }, + "endBinding": { + "elementId": "j0gEw4aVULhx4QaLE5ilT", + "focus": 0.5787409740105682, + "gap": 2.7080563902853783 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + 0.5193957591786784, + 246.9850190137326 + ] + ] + }, + { + "type": "text", + "version": 176, + "versionNonce": 1729720986, + "isDeleted": false, + "id": "xsLMoxFY35BgnSQOjZh6X", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1147, + "y": 319.7607469935061, + "strokeColor": "#000000", + "backgroundColor": "#fd7e14", + "width": 102, + "height": 54, + "seed": 477772422, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "nI5724TfjqH6Qe3Yy_wpp", + "lcE8G6b2mne9PdkVZRlo4", + "rWpu9PUWrDndMLEXiNNeW", + "a62Wf715yk51SS1rAEUWR", + "gN7sS95jZrLd2HWIdF8b2", + "T0vHf8UrBwS_HXXuK-e7L" + ], + "updated": 1638367642123, + "fontSize": 20, + "fontFamily": 1, + "text": "E\n(exclusive)", + "baseline": 47, + "textAlign": "center", + "verticalAlign": "middle" + }, + { + "type": "text", + "version": 164, + "versionNonce": 1197480966, + "isDeleted": false, + "id": "iZqFfKURoULr2fHLs__hj", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 768.75, + "y": 624.635746993506, + "strokeColor": "#000000", + "backgroundColor": "#fd7e14", + "width": 81, + "height": 54, + "seed": 725686490, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "b7_BiCxtIYCGQCm9gq7Wu", + "u1b59y0ux8NpxUcDXQid6", + "a62Wf715yk51SS1rAEUWR", + "EFXdz_kL5zHrlcWGEkWuc", + "1sEijr9iwDW-nRH9a7cmy", + "iww4j6dseqijDCXxo8GK7" + ], + "updated": 1638367642123, + "fontSize": 20, + "fontFamily": 1, + "text": "S\n(shared)", + "baseline": 47, + "textAlign": "center", + "verticalAlign": "middle" + }, + { + "type": "text", + "version": 168, + "versionNonce": 1933840218, + "isDeleted": false, + "id": "j0gEw4aVULhx4QaLE5ilT", + "fillStyle": "hachure", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1159.75, + "y": 628.635746993506, + "strokeColor": "#000000", + "backgroundColor": "#fd7e14", + "width": 77, + "height": 54, + "seed": 2006776262, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "nI5724TfjqH6Qe3Yy_wpp", + "rWpu9PUWrDndMLEXiNNeW", + "-g-ZavXqyfzdNHvwjbxEv", + "lFm2K2wCiDp_pEonxUOBP", + "RtFBOi0VbNpAdT3MYSXwl", + "XdPxk36EiXVTIyp3_nW9u" + ], + "updated": 1638367642123, + "fontSize": 20, + "fontFamily": 1, + "text": "I\n(invalid)", + "baseline": 47, + "textAlign": "center", + "verticalAlign": "middle" + }, + { + "type": "arrow", + "version": 1106, + "versionNonce": 1581951814, + "isDeleted": false, + "id": "rWpu9PUWrDndMLEXiNNeW", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 0, + "x": 1176.490302120411, + "y": 377.14323748663963, + "strokeColor": "#5c940d", + "backgroundColor": "#e64980", + "width": 0.5193957591786784, + "height": 246.9850190137326, + "seed": 404549018, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "xsLMoxFY35BgnSQOjZh6X", + "focus": 0.4225411547563918, + "gap": 3.3824904931335595 + }, + "endBinding": { + "elementId": "j0gEw4aVULhx4QaLE5ilT", + "focus": -0.549165254349737, + "gap": 4.507490493133787 + }, + "lastCommittedPoint": null, + "startArrowhead": "triangle", + "endArrowhead": null, + "points": [ + [ + 0, + 0 + ], + [ + 0.5193957591786784, + 246.9850190137326 + ] + ] + }, + { + "type": "arrow", + "version": 1179, + "versionNonce": 24974362, + "isDeleted": false, + "id": "lcE8G6b2mne9PdkVZRlo4", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 0, + "x": 1140.640953231547, + "y": 351.72263244046206, + "strokeColor": "#364fc7", + "backgroundColor": "#e64980", + "width": 278.4459381522131, + "height": 0.22017033520518225, + "seed": 916836614, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "xsLMoxFY35BgnSQOjZh6X", + "focus": -0.1851767556252177, + "gap": 6.359046768453027 + }, + "endBinding": { + "elementId": "-o2by5PrLDjgZmQxJSdz0", + "focus": -0.04826532495382532, + "gap": 8.69501507933387 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + -278.4459381522131, + -0.22017033520518225 + ] + ] + }, + { + "type": "arrow", + "version": 1456, + "versionNonce": 799101574, + "isDeleted": false, + "id": "b7_BiCxtIYCGQCm9gq7Wu", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 820.0590630443312, + "y": 383.3615244782821, + "strokeColor": "#e67700", + "backgroundColor": "#e64980", + "width": 3.2531712799749357, + "height": 236.1062054981253, + "seed": 794209286, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "-o2by5PrLDjgZmQxJSdz0", + "focus": -0.32704487483453315, + "gap": 3.6007774847760174 + }, + "endBinding": { + "elementId": "iZqFfKURoULr2fHLs__hj", + "focus": 0.35489950815807353, + "gap": 5.168017017098691 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + 3.2531712799749357, + 236.1062054981253 + ] + ] + }, + { + "type": "arrow", + "version": 1504, + "versionNonce": 330793178, + "isDeleted": false, + "id": "u1b59y0ux8NpxUcDXQid6", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 0, + "x": 777.1234143600127, + "y": 383.58264424444343, + "strokeColor": "#364fc7", + "backgroundColor": "#e64980", + "width": 3.2531712799749357, + "height": 236.1062054981253, + "seed": 621920326, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "-o2by5PrLDjgZmQxJSdz0", + "focus": 0.5170084482399113, + "gap": 3.8218972509373543 + }, + "endBinding": { + "elementId": "iZqFfKURoULr2fHLs__hj", + "focus": -0.6956651094595264, + "gap": 4.946897250937354 + }, + "lastCommittedPoint": null, + "startArrowhead": "triangle", + "endArrowhead": null, + "points": [ + [ + 0, + 0 + ], + [ + 3.2531712799749357, + 236.1062054981253 + ] + ] + }, + { + "type": "arrow", + "version": 402, + "versionNonce": 1176572358, + "isDeleted": false, + "id": "a62Wf715yk51SS1rAEUWR", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1143.75, + "y": 376.6357469935061, + "strokeColor": "#e67700", + "backgroundColor": "#7950f2", + "width": 279.41707546059456, + "height": 245.3319040797303, + "seed": 1738024986, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "xsLMoxFY35BgnSQOjZh6X", + "focus": 0.24738851824407043, + "gap": 3.25 + }, + "endBinding": { + "elementId": "iZqFfKURoULr2fHLs__hj", + "focus": 0.2988424171837971, + "gap": 14.58292453940544 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + -279.41707546059456, + 245.3319040797303 + ] + ] + }, + { + "type": "arrow", + "version": 1180, + "versionNonce": 1971738010, + "isDeleted": false, + "id": "EFXdz_kL5zHrlcWGEkWuc", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1142.9729690761067, + "y": 651.7458321611086, + "strokeColor": "#c92a2a", + "backgroundColor": "#e64980", + "width": 278.4459381522131, + "height": 0.22017033520518225, + "seed": 381536134, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": null, + "endBinding": { + "elementId": "iZqFfKURoULr2fHLs__hj", + "focus": -0.005689301652229164, + "gap": 14.777030923893562 + }, + "lastCommittedPoint": null, + "startArrowhead": "triangle", + "endArrowhead": null, + "points": [ + [ + 0, + 0 + ], + [ + -278.4459381522131, + -0.22017033520518225 + ] + ] + }, + { + "type": "arrow", + "version": 1205, + "versionNonce": 1290201350, + "isDeleted": false, + "id": "-g-ZavXqyfzdNHvwjbxEv", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 0, + "x": 1144.9729690761064, + "y": 669.7458321611086, + "strokeColor": "#5c940d", + "backgroundColor": "#e64980", + "width": 278.4459381522131, + "height": 0.22017033520518225, + "seed": 131745734, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "j0gEw4aVULhx4QaLE5ilT", + "focus": -0.5235656788245363, + "gap": 14.777030923893562 + }, + "endBinding": null, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + -278.4459381522131, + -0.22017033520518225 + ] + ] + }, + { + "type": "arrow", + "version": 440, + "versionNonce": 136090202, + "isDeleted": false, + "id": "lFm2K2wCiDp_pEonxUOBP", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1156.0761007096771, + "y": 625.2349918977909, + "strokeColor": "#c92a2a", + "backgroundColor": "#7950f2", + "width": 295.3261007096771, + "height": 258.5992449042849, + "seed": 1541859014, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "j0gEw4aVULhx4QaLE5ilT", + "focus": -0.10753014064082901, + "gap": 3.673899290322879 + }, + "endBinding": { + "elementId": "-o2by5PrLDjgZmQxJSdz0", + "focus": -0.5152104996739859, + "gap": 7.25 + }, + "lastCommittedPoint": null, + "startArrowhead": "triangle", + "endArrowhead": null, + "points": [ + [ + 0, + 0 + ], + [ + -295.3261007096771, + -258.5992449042849 + ] + ] + }, + { + "type": "arrow", + "version": 511, + "versionNonce": 57661510, + "isDeleted": false, + "id": "aXRsUQU5bs8xZdJHsXu4M", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 0, + "x": 1140.0556485850927, + "y": 637.9165855590227, + "strokeColor": "#364fc7", + "backgroundColor": "#7950f2", + "width": 296.9686989399313, + "height": 254.580461017659, + "seed": 1735676058, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "Fl53F-jvn6e-CU3SN7XdI", + "focus": -0.40827076503704574, + "gap": 1 + }, + "endBinding": { + "elementId": "-o2by5PrLDjgZmQxJSdz0", + "focus": -0.053913902056617585, + "gap": 3.575377547857613 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + -296.9686989399313, + -254.580461017659 + ] + ] + }, + { + "type": "arrow", + "version": 422, + "versionNonce": 239941402, + "isDeleted": false, + "id": "AHx3ER4u8btQqE9uX5rHb", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 0, + "x": 750.3152475722445, + "y": 362.57088044642495, + "strokeColor": "#5c940d", + "backgroundColor": "#7950f2", + "width": 52.99991322979747, + "height": 80.06942714501845, + "seed": 891952646, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "-o2by5PrLDjgZmQxJSdz0", + "focus": -0.28243926462187896, + "gap": 2.184752427755484 + }, + "endBinding": { + "focus": 0.10705712914066251, + "gap": 1, + "elementId": "-o2by5PrLDjgZmQxJSdz0" + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + -34.56516080204183, + 1.127738410493217 + ], + [ + -23.043440534694554, + -78.94168873452523 + ], + [ + 18.434752427755644, + -41.72632118824905 + ] + ] + }, + { + "type": "arrow", + "version": 405, + "versionNonce": 832102278, + "isDeleted": false, + "id": "JsUn8E2tYCdzcoDY7swV9", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 0, + "x": 792.75, + "y": 324.98258476215614, + "strokeColor": "#364fc7", + "backgroundColor": "#7950f2", + "width": 65.99999999999997, + "height": 50.02149398701218, + "seed": 546516314, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "-o2by5PrLDjgZmQxJSdz0", + "focus": -0.26963810495989027, + "gap": 1 + }, + "endBinding": null, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + 7.4516129032258025, + -45.36833175566221 + ], + [ + 65.99999999999997, + -27.918973388099822 + ], + [ + 38.322580645161274, + 4.65316223134997 + ] + ] + }, + { + "type": "arrow", + "version": 383, + "versionNonce": 2022392794, + "isDeleted": false, + "id": "T0vHf8UrBwS_HXXuK-e7L", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 0, + "x": 1203.75, + "y": 319.37068516372113, + "strokeColor": "#5c940d", + "backgroundColor": "#7950f2", + "width": 85.01345306311752, + "height": 70.00000306679412, + "seed": 1199861062, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "xsLMoxFY35BgnSQOjZh6X", + "focus": -0.47714777195900876, + "gap": 1 + }, + "endBinding": { + "elementId": "xsLMoxFY35BgnSQOjZh6X", + "focus": -0.12831873343003766, + "gap": 5.22673775622593 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + 69.9589874165238, + -33.73494123700922 + ], + [ + 85.01345306311752, + 36.265061829784905 + ], + [ + 50.47673775622603, + 31.204820644233525 + ] + ] + }, + { + "type": "arrow", + "version": 335, + "versionNonce": 463404742, + "isDeleted": false, + "id": "RtFBOi0VbNpAdT3MYSXwl", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1240.75, + "y": 624.635746993506, + "strokeColor": "#c92a2a", + "backgroundColor": "#7950f2", + "width": 60, + "height": 65, + "seed": 859337242, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "j0gEw4aVULhx4QaLE5ilT", + "focus": -0.36639344262295076, + "gap": 4 + }, + "endBinding": { + "focus": -0.3837549933422104, + "gap": 13, + "elementId": "j0gEw4aVULhx4QaLE5ilT" + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + 59, + -22 + ], + [ + 60, + 43 + ], + [ + 9, + 30 + ] + ] + }, + { + "type": "arrow", + "version": 280, + "versionNonce": 820623514, + "isDeleted": false, + "id": "XdPxk36EiXVTIyp3_nW9u", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1223.75, + "y": 684.635746993506, + "strokeColor": "#e67700", + "backgroundColor": "#7950f2", + "width": 65, + "height": 52, + "seed": 273863814, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642124, + "startBinding": { + "elementId": "j0gEw4aVULhx4QaLE5ilT", + "focus": -0.6679226325043959, + "gap": 2 + }, + "endBinding": { + "elementId": "j0gEw4aVULhx4QaLE5ilT", + "focus": 0.4403409090909091, + "gap": 1 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + -1, + 51 + ], + [ + -65, + 37 + ], + [ + -54, + -1 + ] + ] + }, + { + "type": "arrow", + "version": 319, + "versionNonce": 1981756934, + "isDeleted": false, + "id": "1sEijr9iwDW-nRH9a7cmy", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 838.75, + "y": 679.635746993506, + "strokeColor": "#e67700", + "backgroundColor": "#7950f2", + "width": 63, + "height": 56, + "seed": 872138458, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642125, + "startBinding": { + "elementId": "iZqFfKURoULr2fHLs__hj", + "focus": -0.6106995884773662, + "gap": 1 + }, + "endBinding": { + "focus": 0.4002057613168724, + "gap": 1, + "elementId": "iZqFfKURoULr2fHLs__hj" + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + 6, + 56 + ], + [ + -57, + 44 + ], + [ + -51, + 0 + ] + ] + }, + { + "type": "arrow", + "version": 456, + "versionNonce": 1729860954, + "isDeleted": false, + "id": "iww4j6dseqijDCXxo8GK7", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 0, + "x": 750.75, + "y": 666.635746993506, + "strokeColor": "#5c940d", + "backgroundColor": "#7950f2", + "width": 65, + "height": 79, + "seed": 1498567622, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642125, + "startBinding": { + "elementId": "32Yo7NViUgvde8AJCckWY", + "focus": -0.5084745762711864, + "gap": 1 + }, + "endBinding": { + "elementId": "iZqFfKURoULr2fHLs__hj", + "focus": -0.057717616093250615, + "gap": 2 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + -49, + 0 + ], + [ + -30, + -79 + ], + [ + 16, + -44 + ] + ] + }, + { + "type": "rectangle", + "version": 1110, + "versionNonce": 1511425350, + "isDeleted": false, + "id": "ZEdf5Qpv9hh0mmHjwZdBe", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1365.75, + "y": 309.62499999999994, + "strokeColor": "#000000", + "backgroundColor": "#ced4da", + "width": 316.00000000000006, + "height": 218.00000000000003, + "seed": 1661613402, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB", + "QN25t4_XOP7-HRxAuV7Y2", + "DhBK1onobgdtoteMzJ3RY", + "EVuGS3oXm7jYXCy8DsY2V", + "7-zXi5_a33f7uUIc7_j_9", + "OWrGRSWgDTVld8aCb9xUP", + "E-FoU4T3WQM9Nik2oNqPM", + "3V9yHghrlRnpZ2-Gi6Pe0", + "OHu38dElAmMCwUtShaCwn" + ], + "updated": 1638367642125 + }, + { + "type": "arrow", + "version": 1178, + "versionNonce": 239147482, + "isDeleted": false, + "id": "ID-sqBmGKnmIwkNcOAJPv", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 0, + "x": 1526.4921837726151, + "y": 336.58343798760905, + "strokeColor": "#5c940d", + "backgroundColor": "#e64980", + "width": 124.53484715127843, + "height": 3.568523155211551, + "seed": 241622874, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367742429, + "startBinding": null, + "endBinding": null, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + 124.53484715127843, + -3.568523155211551 + ] + ] + }, + { + "type": "arrow", + "version": 1040, + "versionNonce": 171347782, + "isDeleted": false, + "id": "KpQBa4I3F8q2zhxMmGY5Z", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 2, + "opacity": 100, + "angle": 1.6003829170010793, + "x": 1590.2330244011725, + "y": 331.5049310929235, + "strokeColor": "#364fc7", + "backgroundColor": "#e64980", + "width": 3.656981982920115, + "height": 127.47118427252695, + "seed": 809888090, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367749184, + "startBinding": null, + "endBinding": null, + "lastCommittedPoint": null, + "startArrowhead": "triangle", + "endArrowhead": null, + "points": [ + [ + 0, + 0 + ], + [ + 3.656981982920115, + 127.47118427252695 + ] + ] + }, + { + "type": "arrow", + "version": 289, + "versionNonce": 1509481286, + "isDeleted": false, + "id": "FgeZ0ocV-uchZ1qU9FCYn", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1529.55536082207, + "y": 445.23748053072586, + "strokeColor": "#e67700", + "backgroundColor": "#7950f2", + "width": 129.98610144763256, + "height": 1.5534715091393991, + "seed": 1768758662, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367678878, + "startBinding": null, + "endBinding": null, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "triangle", + "points": [ + [ + 0, + 0 + ], + [ + 129.98610144763256, + 1.5534715091393991 + ] + ] + }, + { + "type": "arrow", + "version": 1123, + "versionNonce": 1354529158, + "isDeleted": false, + "id": "0uVOFWwQWXzX61PN8kCq6", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1664.4729690761064, + "y": 492.2350851676026, + "strokeColor": "#c92a2a", + "backgroundColor": "#e64980", + "width": 138.8444587457027, + "height": 1.0144742988954931, + "seed": 1030493274, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642125, + "startBinding": null, + "endBinding": null, + "lastCommittedPoint": null, + "startArrowhead": "triangle", + "endArrowhead": null, + "points": [ + [ + 0, + 0 + ], + [ + -138.8444587457027, + 1.0144742988954931 + ] + ] + }, + { + "type": "rectangle", + "version": 929, + "versionNonce": 1803930906, + "isDeleted": false, + "id": "ZHbj8jZV0bHoh7UsAtovF", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1375.75, + "y": 315.62499999999994, + "strokeColor": "#000000", + "backgroundColor": "#5c940d", + "width": 131.99999999999991, + "height": 37.000000000000014, + "seed": 401628102, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB", + "QN25t4_XOP7-HRxAuV7Y2", + "DhBK1onobgdtoteMzJ3RY", + "EVuGS3oXm7jYXCy8DsY2V", + "7-zXi5_a33f7uUIc7_j_9", + "OWrGRSWgDTVld8aCb9xUP", + "E-FoU4T3WQM9Nik2oNqPM", + "2i0QSCxasOTq6N5sjdJWl", + "QWTrRjvIJMVbYjUOWAacR", + "t3OtENppztxvn0dyhHoAP" + ], + "updated": 1638367738429 + }, + { + "type": "text", + "version": 42, + "versionNonce": 869220422, + "isDeleted": false, + "id": "ocGhWtSGmF9-LrByzMpWJ", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1389.75, + "y": 320.62499999999994, + "strokeColor": "#000000", + "backgroundColor": "#364fc7", + "width": 99, + "height": 27, + "seed": 1671676422, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367651006, + "fontSize": 20, + "fontFamily": 1, + "text": "local read", + "baseline": 20, + "textAlign": "center", + "verticalAlign": "middle" + }, + { + "type": "rectangle", + "version": 963, + "versionNonce": 1357945798, + "isDeleted": false, + "id": "rv_6aDEWrNuVlCrodQN2B", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1378.75, + "y": 377.62500000000006, + "strokeColor": "#000000", + "backgroundColor": "#364fc7", + "width": 128.99999999999994, + "height": 37.000000000000014, + "seed": 856612442, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB", + "QN25t4_XOP7-HRxAuV7Y2", + "DhBK1onobgdtoteMzJ3RY", + "EVuGS3oXm7jYXCy8DsY2V", + "7-zXi5_a33f7uUIc7_j_9", + "OWrGRSWgDTVld8aCb9xUP", + "E-FoU4T3WQM9Nik2oNqPM", + "2i0QSCxasOTq6N5sjdJWl", + "QWTrRjvIJMVbYjUOWAacR", + "t3OtENppztxvn0dyhHoAP" + ], + "updated": 1638367727888 + }, + { + "type": "rectangle", + "version": 990, + "versionNonce": 50979866, + "isDeleted": false, + "id": "cmP8vhjubcbL5My_3qr-4", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1379.75, + "y": 427.62499999999994, + "strokeColor": "#000000", + "backgroundColor": "#e67700", + "width": 126.99999999999993, + "height": 38.000000000000014, + "seed": 1329651418, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB", + "QN25t4_XOP7-HRxAuV7Y2", + "DhBK1onobgdtoteMzJ3RY", + "EVuGS3oXm7jYXCy8DsY2V", + "7-zXi5_a33f7uUIc7_j_9", + "OWrGRSWgDTVld8aCb9xUP", + "E-FoU4T3WQM9Nik2oNqPM", + "2i0QSCxasOTq6N5sjdJWl", + "QWTrRjvIJMVbYjUOWAacR", + "t3OtENppztxvn0dyhHoAP" + ], + "updated": 1638367678878 + }, + { + "type": "rectangle", + "version": 1006, + "versionNonce": 115989274, + "isDeleted": false, + "id": "RXMussIsr-hFZK7osS5KG", + "fillStyle": "solid", + "strokeWidth": 1, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1380.75, + "y": 474.62500000000006, + "strokeColor": "#000000", + "backgroundColor": "#c92a2a", + "width": 127.99999999999994, + "height": 37.99999999999996, + "seed": 1006657862, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [ + "hC97PmiA9GpSyZPfCGdGv", + "3SxvWp5giaQFb8YaHyiTB", + "QN25t4_XOP7-HRxAuV7Y2", + "DhBK1onobgdtoteMzJ3RY", + "EVuGS3oXm7jYXCy8DsY2V", + "7-zXi5_a33f7uUIc7_j_9", + "OWrGRSWgDTVld8aCb9xUP", + "E-FoU4T3WQM9Nik2oNqPM", + "2i0QSCxasOTq6N5sjdJWl", + "QWTrRjvIJMVbYjUOWAacR", + "t3OtENppztxvn0dyhHoAP" + ], + "updated": 1638367660322 + }, + { + "type": "text", + "version": 36, + "versionNonce": 981250970, + "isDeleted": false, + "id": "ccNlBZytoW2bcyVR5LTWZ", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1395.75, + "y": 382.62500000000006, + "strokeColor": "#000000", + "backgroundColor": "#ced4da", + "width": 99, + "height": 27, + "seed": 311575110, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367653900, + "fontSize": 20, + "fontFamily": 1, + "text": "local write", + "baseline": 20, + "textAlign": "center", + "verticalAlign": "middle" + }, + { + "type": "text", + "version": 46, + "versionNonce": 1496157402, + "isDeleted": false, + "id": "z4MkDRdsnWQZmA6vWwecv", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 1383.25, + "y": 432.62499999999994, + "strokeColor": "#000000", + "backgroundColor": "#c92a2a", + "width": 122, + "height": 27, + "seed": 1539957894, + "groupIds": [], + "strokeSharpness": "sharp", + "boundElementIds": [], + "updated": 1638367642126, + "fontSize": 20, + "fontFamily": 1, + "text": "remote read", + "baseline": 20, + "textAlign": "center", + "verticalAlign": "middle" + }, + { + "id": "c81M6eMQtboaS-gu1ZNfm", + "type": "text", + "x": 1383.75, + "y": 480.12500000000006, + "width": 122, + "height": 27, + "angle": 0, + "strokeColor": "#000000", + "backgroundColor": "#c92a2a", + "fillStyle": "hachure", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "groupIds": [], + "strokeSharpness": "sharp", + "seed": 1557812294, + "version": 13, + "versionNonce": 245098438, + "isDeleted": false, + "boundElementIds": null, + "updated": 1638367673825, + "text": "remote write", + "fontSize": 20, + "fontFamily": 1, + "textAlign": "center", + "verticalAlign": "middle", + "baseline": 20 + } + ], + "appState": { + "gridSize": null, + "viewBackgroundColor": "#ffffff" + }, + "files": {} +} \ No newline at end of file diff --git a/study/arch/cache/MESI/MESI.png b/study/arch/cache/MESI/MESI.png new file mode 100644 index 0000000..e305b31 Binary files /dev/null and b/study/arch/cache/MESI/MESI.png differ diff --git a/study/arch/cache/MESI/README.md b/study/arch/cache/MESI/README.md index 60103fe..2d5d2a1 100644 --- a/study/arch/cache/MESI/README.md +++ b/study/arch/cache/MESI/README.md @@ -66,29 +66,28 @@ MESI(Modified-Exclusive-Shared-Invalid) 协议是一种广为使用的缓存一 | S 共享 (Shared) | 该 Cache line 有效, 数据和内存中的数据一致, 数据存在于很多 Cache 中. | 当前缓存行必须监听其它缓存使该缓存行无效或者独享该缓存行的请求, 并将该缓存行变成无效(Invalid). | 当其他 CPU 修改该缓存行对应的内存时会使该缓存行变成 I 状态. | | I 无效 (Invalid) | 该 Cache line 无效. | 无 | 无 | +监听: + +1. 一个处于 M 状态的缓存行必须时刻监听所有试图读该缓存行相对就主存的操作, 这种操作必须在缓存将该缓存行写回主存并将状态变成 S 状态之前被延迟执行. + +2. 一个处于 S 状态的缓存行也必须监听其它缓存使该缓存行无效或者独享该缓存行的请求, 并将该缓存行变成无效(Invalid). + +3. 一个处于 E 状态的缓存行也必须监听其它缓存读主存中该缓存行的操作, 一旦有这种操作, 该缓存行需要变成 S 状态. + + ## 2.2 请求 ------- 首先不同 CPU 之间也是需要沟通的, 这里的沟通是通过在消息总线上传递 message 实现的. 这些在总线上传递的消息有如下几种: -| 请求 | 描述 | -|:---:|:----:| -| Read | 带上数据的物理内存地址发起的读请求消息 | -| Read Response | Read 请求的响应信息, 内部包含了读请求指向的数据 | -| Invalidate | 该消息包含数据的内存物理地址, 意思是要让其他如果持有该数据缓存行的 CPU 直接失效对应的缓存行 | -| Invalidate Acknowledge | CPU 对Invalidate 消息的响应, 目的是告知发起 Invalidate 消息的CPU, 这边已经失效了这个缓存行啦 | -| Read Invalidate | 这个消息其实是 Read 和 Invalidate 的组合消息, 与之对应的响应自然就是一个Read Response 和 一系列的 Invalidate Acknowledge | -| Writeback | 该消息包含一个物理内存地址和数据内容, 目的是把这块数据通过总线写回内存里. | - - | 消息 | 类型 | 描述 | |:---:|:----:|:---:| | Read | 请求 | 用来获取指定物理地址上的 cache line 数据. 通知其他处理器和内存, 当前 CPU 准备读取某个数据. 该消息内包含待读取数据的内存地址. | | Read Response | 响应 | Read 请求的响应信息, 该消息内包含了被请求读取的数据. 该消息可能是主内存返回的, 也可能是其他高速缓存嗅探到 Read 消息返回的. | | Invalidate | 请求 | 通知其他处理器删除(无效)指定内存地址的数据副本(缓存行中的数据). 该消息包含数据的内存物理地址. | | Invalidate Acknowledge | 响应 | 这是 CPU 对 Invalidate 消息的响应, 接收到 Invalidate 消息的处理器必须回复此消息, 表示已经无效掉了其高速缓存内对应的数据副本. | -| Read Invalidate | 请求 | 这个消息其实是 Read 和 Invalidate 消息组成的复合消息, 主要是用于通知其他 CPU 当前 CPU 准备更新一个数据了, 并请求其他处理器删除其高速缓存内对应的数据副本. 接收到该消息的处理器必须回复 Read Response 和 Invalidate Acknowledge 消息. | +| Read Invalidate | 请求 | 这个消息其实是 Read 和 Invalidate 消息组成的复合消息, 主要是用于通知其他 CPU 当前 CPU 准备更新一个数据了, 所以获取对该数据的独占权, 并请求其他处理器删除其高速缓存内对应的数据副本. 接收到该消息的处理器必须回复 Read Response 和 Invalidate Acknowledge 消息. | | Writeback | 响应 | 消息包含了需要写入内存的数据和其对应的内存地址, 一般用在 modified 状态的 cache line 被置换时发出, 用来将最新的数据写回 memory 或其他下一级 cache 中. | @@ -97,41 +96,65 @@ MESI(Modified-Exclusive-Shared-Invalid) 协议是一种广为使用的缓存一 那么这些请求如何动态的转换呢 ? +MESI 状态转换的规则如下: + +1. 一个缓存除在 Invalid 状态外都可以满足 CPU 的读请求, 一个 Invalid 的缓存行必须从主存中读取(变成 S 或者 E 状态)来满足该 CPU 的读请求. + +2. 一个写请求只有在该缓存行是 M 或者 E 状态时才能被执行, 如果缓存行处于 S 状态, 必须先将其它缓存中该缓存行变成 Invalid 状态(也既是不允许不同 CPU 同时修改同一缓存行, 即使修改该缓存行中不同位置的数据也不允许). 该操作经常作用广播的方式来完成, 例如: RequestFor Ownership (RFO). + +3. 缓存可以随时将一个非 M 状态的缓存行作废, 或者变成 Invalid 状态, 而一个 M 状态的缓存行必须先被写回主存. + +4. 从上面的意义看来 E 状态是一种投机性的优化: 如果一个 CPU 想修改一个处于 S 状态的缓存行, 总线事务需要将所有该缓存行的 copy 变成 Invalid 状态, 而修改 E 状态的缓存不需要使用总线事务. + +5. 对于 M 和 E 状态而言总是精确的, 他们和该缓存行的实际状态是一致的. 而 S 状态可能是非一致的, 如果一个缓存将处于 S 状态的缓存行作废了, 而另一个缓存实际上可能已经独享了该缓存行, 但是该缓存却不会将该缓存行升迁为 E 状态, 这是因为其它缓存不会广播他们作废掉该缓存行的通知, 同样由于缓存并没有保存该缓存行的 copy 的数量, 因此(即使有这种通知)也没有办法确定自己是否已经独享了该缓存行. 因此上述状态转换的表格中, 中间状态可能并不会发生. + + + local read 和 local write 分别代表本地CPU读写. remote read 和 remote write 分别代表其他CPU读写. -| 当前状态 | 事件 | 行为 | 请求 | 响应 | 下一个状态 | -|:------:|:----:|:---:|:----:|:---:|:--------:| -| I(invalid) | local read | 本 CPU 执行读操作, 发现 local cache 没有数据, 因此通过 read 发起一次 bus transaction, 来自其他的 CPU local cache 或者 memory 会通过 read response 回应, 从而将该 cache line 从 Invalid 状态迁移到 Shared 状态. -| S | -| I(invalid) | local write | CPU 想要进行 write 的操作但是数据不在 local cache 中, 因此, 该 CPU 首先发送了 read invalidate 启动了一次总线 transaction. 在收到 read response 回应拿到数据, 并且收集所有其他 CPU 发来的 invalidate acknowledge 之后(确保其他 CPU 没有 local copy), 完成整个 bus transaction. 当 write 操作完成之后, 该 cacheline的状态会从 I 状态迁移到 E 状态. | E | -| I(invalid) | local write | CPU 需要执行一个原子的 readmodify-write 操作, 并且其 cache 中没有缓存数据. 这时候 CPU 就会在总线上发送一个 read invalidate 消息来请求数据, 并试图独占该数据. CPU 可以通过收到的 read response 消息获取到数据, 并等待所有的 invalidate acknowledge 消息, 然后将状态设置为 modifie. | M | -| I(invalid) | remote read | remote read 不影响本地 cache 的状态 | I | -| I(invalid) | remote write | remote read 不影响本地 cache 的状态 | I | +![MESI 的状态转换图](./MESI.png) + +| 当前状态 | 事件 | 行为 | 当前所在核的 cache 状态 | 触发读写事件 CPU 的 cache 状态 | 其他 cache 状态 | +|:------:|:----:|:---:|:--------------------:|:----------------------------:|:-------------:| +| M(modified) | local read | 状态不变 | M | M | I | +| M(modified) | local write | 状态不变 | M | M | I | +| M(modified) | remote read | 在本 CPU 独自享受独占数据的时候, 其他的 CPU 发起 read 请求, 希望获取数据, 这时候, 本 CPU 必须以其 local cacheline 的数据回应, 并以 read response 回应之前总线上的 read 请求. 这时候, 本 CPU 失去了独占权, 该 cacheline 状态从 Modified 状态变成 Shared 状态(有可能也会进行写回的动作, 写会后, 可能存在中间状态 E). | M->E->S | I->S | I->S | +| M(modified) | remote write | ~~先把 cache 中的数据写到内存中, 其他 CPU 的 cache 再读取并修改后, 本地 cache 状态变为I. 修改的那个cache状态变为 M~~
CPU 收到一个 read invalidate 消息, 此时 CPU 必须将对应 cache line 设置成 invalid 状态, 并且响应一个 read response 消息和 invalidate acknowledge 消息. | I | M->E->S->I | I->S->E->M | I->S->I | +| M(modified) | write back | cache 通过 writeback 将数据回写到 memory 或者下一级 cache 中. 这时候状态由 modified 变成了 exclusive | E | E | I | |
*-*
|
*-*
|
*-*
|
*-*-*-*
| -| E(exclusive) | local read | 状态不变 | E | -| E(exclusive) | local write | CPU 直接将数据写入 cache line, 导致状态变为了 M | M | -| E(exclusive) | remote read | 这个迁移和(M-=>S)的转换类似, 只不过开始 cacheline 的状态是 exclusive, cacheline 和 memory 的数据都是最新的, 不存在写回的问题. 总线上的操作也是在收到 read 请求之后, 以read response 回应. 本 CPU 失去了独占权, 该 cacheline 状态从 Modified 状态变成 shared 状态(不会进行写回的动作) | S | -| E(exclusive) | remote write | 其他的 CPU 进行一个原子的 read-modify-write 操作, 但是, 数据在本 CPU 的 cacheline 中, 因此, 其他的那个 CPU 会发送 read invalidate, 请求对该数据以及独占权. 本 CPU 回送 read response 和 invalidate acknowledge, 一方面把数据转移到其他 CPU 的 cache 中, 另外一方面, 清空自己的cacheline. | I | +| E(exclusive) | local read | 状态不变 | E | E | I | +| E(exclusive) | local write | CPU 直接将数据写入 cache line, 导致状态变为了 M | E->M | E->M | I | +| E(exclusive) | remote read | 这个迁移和(M-=>S)的转换类似, 只不过开始 cacheline 的状态是 exclusive, cacheline 和 memory 的数据都是最新的, 不存在写回的问题. 总线上的操作也是在收到 read 请求之后, 以read response 回应. 本 CPU 失去了独占权, 该 cacheline 状态从 Modified 状态变成 shared 状态(不会进行写回的动作) | E->S | E->S | I->S | +| E(exclusive) | remote write | 其他的 CPU 进行一个原子的 read-modify-write 操作, 但是, 数据在本 CPU 的 cacheline 中, 因此, 其他的那个 CPU 会发送 read invalidate, 请求该数据(可能存在存在中间状态 S)以及获取独占权(可能存在存在中间状态 E). 本 CPU 回送 read response 和 invalidate acknowledge, 一方面把数据转移到其他 CPU 的 cache 中(存在中间状态 S), 另外一方面, 清空自己的 cacheline. | E->S->I | I->S->E->M | I->S->I | |
*-*
|
*-*
|
*-*
|
*-*-*-*
| -| S(shared) | local read | 不影响状态 | S | -| S(shared) | local write | CPU 需要执行一个原子的 readmodify-write 操作, 并且其 local cache 中有 read only 的缓存数据(cacheline处于shared状态), 这时候, CPU 就会在总线上发送一个 invalidate 请求其他 CPU 清空自己的 local copy, 以便完成其独自霸占对该数据的所有权的梦想. 同样的, 该 CPU 必须收集所有其他 CPU 发来的 invalidate acknowledge 之后才能更改状态为 modified. | M | -| S(shared) | remote read | 不影响状态 | S | -| S(shared) | remote write | 当 cache line 处于 shared 状态的时候, 说明在多个 CPU 的 local cache 中存在副本, 因此, 这些 cacheline 中的数据都是 read only 的, 一旦其中一个 CPU 想要执行数据写入的动作, 必须先通过 invalidate 获取该数据的独占权, 而其他的 CPU 会以 invalidate acknowledge 回应, 清空数据并将其 cacheline 从 shared 状态修改成 invalid 状态. | I | -| S | NA | 如果 CPU 认为自己很快就会启动对处于 shared 状态的 cacheline 进行 write 操作, 因此想提前先霸占上该数据. 因此, 该 CPU 会发送 invalidate 敦促其他 CPU 清空自己的 local copy, 当收到全部其他 CPU 的 invalidate acknowledge 之后, transaction 完成, 本 CPU 上对应的 cacheline 从 shared 状态切换 exclusive 状态.
还有另外一种方法也可以完成这个状态切换: 当所有其他的 CPU 对其 local copy 的 cacheline 进行写回操作, 同时将 cacheline 中的数据设为无效(主要是为了为新的数据腾些地方), 这时候, 本CPU坐享其成, 直接获得了对该数据的独占权. | E | +| S(shared) | local read | 不影响状态 | S | S | S | +| S(shared) | local write | CPU 需要执行一个原子的 readmodify-write 操作, 并且其 local cache 中有 read only 的缓存数据(cache line 处于 Shared 状态), 这时候, CPU 就会在总线上发送一个 invalidate 请求其他 CPU 清空自己的 local copy, 以便完成其独自霸占对该数据的所有权的梦想(存在中间状态 E). 同样的, 该 CPU 必须收集所有其他 CPU 发来的 invalidate acknowledge 之后才能更改状态为 modified. | S->E->M | S->E->M | S->I | +| S(shared) | remote read | 不影响状态 | S | S | S | +| S(shared) | remote write | 当 cache line 处于 shared 状态的时候, 说明在多个 CPU 的 local cache 中存在副本, 因此, 这些 cache line 中的数据都是 read only 的, 一旦其中一个 CPU 想要执行数据写入的动作, 必须先通过 invalidate 获取该数据的独占权(可能存在中间状态 E), 而其他的 CPU 会以 invalidate acknowledge 回应, 清空数据并将其 cacheline 从 shared 状态修改成 invalid 状态. 在写完成后, 本次 cache line 变成 modified 状态 | S->I | S->E->M | S->I | +| S(shared) | NA | 如果 CPU 认为自己很快就会启动对处于 shared 状态的 cacheline 进行 write 操作, 因此想提前先霸占上该数据. 因此, 该 CPU 会发送 invalidate 敦促其他 CPU 清空自己的 local copy, 当收到全部其他 CPU 的 invalidate acknowledge 之后, transaction 完成, 本 CPU 上对应的 cacheline 从 shared 状态切换 exclusive 状态.
还有另外一种方法也可以完成这个状态切换: 当所有其他的 CPU 对其 local copy 的 cacheline 进行写回操作, 同时将 cacheline 中的数据设为无效(主要是为了为新的数据腾些地方), 这时候, 本 CPU 坐享其成, 直接获得了对该数据的独占权. | E | E/I | I | |
*-*
|
*-*
|
*-*
|
*-*-*-*
| -| M(modified) | local read | 状态不变 | M | -| M(modified) | local write | 状态不变 | M | -| M(modified) | remote read | 在本 CPU 独自享受独占数据的时候, 其他的 CPU 发起 read 请求, 希望获取数据, 这时候, 本 CPU 必须以其 local cacheline 的数据回应, 并以 read response 回应之前总线上的 read 请求. 这时候, 本 CPU 失去了独占权, 该 cacheline 状态从 Modified 状态变成 shared 状态(有可能也会进行写回的动作). | S | -| M(modified) | remote write | ~~先把 cache 中的数据写到内存中, 其他 CPU 的 cache 再读取并修改后, 本地 cache 状态变为I. 修改的那个cache状态变为 M~~
CPU 收到一个 read invalidate 消息, 此时 CPU 必须将对应 cache line 设置成 invalid 状态, 并且响应一个 read response 消息和 invalidate acknowledge 消息. | I | -| M(modified) | write back | cache 通过 writeback 将数据回写到 memory 或者下一级 cache 中. 这时候状态由 modified 变成了 exclusive | E | +| I(invalid) | local read | 本 CPU 执行读操作, 发现 local cache 没有数据, 因此通过 read 发起一次 bus transaction, 来自其他的 CPU local cache 或者 memory 会通过 read response 回应,
1. 如果数据来自其他 CPU 的 cache, 将该 cache line 从 Invalid 状态迁移到 Shared 状态.
2. 如果来自于内存, 则本地从 Invalid 状态迁移到 Exclusive 状态. | I->S/I->E | I->S/I->E | E/M/I->S/I | +| I(invalid) | local write | CPU 想要进行 write 的操作但是数据不在 local cache 中, 因此, 该 CPU 首先发送了 read invalidate 启动了一次总线 transaction. 在收到 read response 回应拿到数据, 并且收集所有其他 CPU 发来的 invalidate acknowledge 之后(确保其他 CPU 没有 local copy), 完成整个 bus transaction. 当 write 操作完成之后, 该 cacheline的状态会从 I 状态迁移到 E 状态. | E | E | E | +| I(invalid) | local write | CPU 需要执行一个原子的 readmodify-write 操作, 并且其 cache 中没有缓存数据. 这时候 CPU 就会在总线上发送一个 read invalidate 消息来请求数据(可能存在中间状态 S), 并试图独占该数据(可能存在中间状态 E). CPU 可以通过收到的 read response 消息获取到数据, 并等待所有的 invalidate acknowledge 消息, 然后将状态设置为 modifie. | I->S->E->M | I->S->E->M | M,E,S->S->I | +| I(invalid) | remote read | remote read 不影响本地 cache 的状态 | I | NA | NA | +| I(invalid) | remote write | remote read 不影响本地 cache 的状态 | I | NA | NA | -4. +下图示意了,当本地 cache line 的调整的状态的时候, 其他 CPU 的 cache line 需要调整到的状态. -5. +| M | E | S | I | +|:-:|:-:|:-:|:-:| +| M | × | × | × | √ | +| E | × | × | × | √ | +| S | × | × | √ | √ | +| I | √ | √ | √ | √ | + +举个栗子来说: + +假设 CPU 1 的 cache line 中有一个变量 x = 0 的 cache line 处于 S 状态(共享). +那么其他拥有 x 变量的 CPU 2, CPU 3 等的 cache line 可能调整到的状态就是 S 状态(共享)或者调整为 I 状态(无效). -6. # 3 硬件的处理 ------- @@ -162,7 +185,7 @@ L3 缓存是所有CPU共享的一个缓存. 纵观刚才描述的MESI, 好像涉 个人猜测是如果描述MESI状态流转的时候引入L3缓存, 会造成描述会极其复杂. 所以一般的描述都好似有意地忽略了L3缓存. -# 1 参考资料 +# 4 参考资料 ------- | 编号 | 链接 | 描述 | @@ -193,11 +216,14 @@ L3 缓存是所有CPU共享的一个缓存. 纵观刚才描述的MESI, 好像涉 | 24 | [CPU 乱序执行与问题](https://blog.csdn.net/lizhihaoweiwei/article/details/50562732) | NA | | 25 | [store-queue VS store-buffer](https://stackoverflow.com/questions/24975540/what-is-the-difference-between-a-store-queue-and-a-store-buffer) | NA | | 26 | [《大话处理器》Cache一致性协议之MESI](https://blog.csdn.net/muxiqingyang/article/details/6615199) | NA | -| 27 | [并发吹剑录(一):CPU缓存一致性协议MESI](https://zhuanlan.zhihu.com/p/351550104) | NA | +| 27 | [并发吹剑录(一):CPU缓存一致性协议MESI](https://zhuanlan.zhihu.com/p/351550104) | NA | | 28 | [缓存一致性协议 MESI(转载)](https://zhuanlan.zhihu.com/p/147704505) | NA | | 29 | [CPU缓存一致性保障原理](https://zhuanlan.zhihu.com/p/54876718) | NA | | 30 | [Cache一致性的那些事儿 (3)--Directory方案](https://zhuanlan.zhihu.com/p/419722803) | NA | - +| 31 | [CPU缓存一致性协议MESI](https://www.cnblogs.com/yanlong300/p/8986041.html)
[知乎](https://zhuanlan.zhihu.com/p/79777058) | NA | +| 32 | [【并发编程】MESI--CPU缓存一致性协议](https://zhuanlan.zhihu.com/p/112605471) | NA | +| 33 | [MESI 缓存一致性协议引发的一些思考](https://zhuanlan.zhihu.com/p/435009820) | NA | +| 34 | [MESI Cache Coherency Protocol](https://www.scss.tcd.ie/Jeremy.Jones/vivio/caches/MESIHelp.htm?utm_source=wechat_session&utm_medium=social&utm_oi=714537833427136512) | 一个非常好的模拟网站, 模拟各种操作后, 多核之间 cache 和总线的交互以及状态变换 |
diff --git a/study/kernel/00-DESCRIPTION/SCHEDULER.md b/study/kernel/00-DESCRIPTION/SCHEDULER.md index 60fe17c..3b1a41e 100644 --- a/study/kernel/00-DESCRIPTION/SCHEDULER.md +++ b/study/kernel/00-DESCRIPTION/SCHEDULER.md @@ -1281,10 +1281,14 @@ schedtune 与 uclamp 都是由 ARM 公司的 Patrick Bellasi 主导开发. ## 8.2 NO_HZ ------- +[NO_HZ: 减少调度时钟的滴答](https://blog.csdn.net/zhoudawei/article/details/86427101) + NOHZ 社区测试用例 [frederic/dynticks-testing.git](https://git.kernel.org/pub/scm/linux/kernel/git/frederic/dynticks-testing.git) 仓库 : git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git + + 当前 NOHZ 有 3 种模式. | 选项 | select 选项 | 描述 |