History

Drivers: hv: vmbus: Resolve more races involving init_vp_index()

init_vp_index() uses the (per-node) hv_numa_map[] masks to record the CPUs allocated for channel interrupts at a given time, and distribute the performance-critical channels across the available CPUs: in part., the mask of "candidate" target CPUs in a given NUMA node, for a newly offered channel, is determined by XOR-ing the node's CPU mask and the node's hv_numa_map. This operation/mechanism assumes that no offline CPUs is set in the hv_numa_map mask, an assumption that does not hold since such mask is currently not updated when a channel is removed or assigned to a different CPU. To address the issues described above, this adds hooks in the channel removal path (hv_process_channel_removal()) and in target_cpu_store() in order to clear, resp. to update, the hv_numa_map[] masks as needed. This also adds a (missed) update of the masks in init_vp_index() (cf., e.g., the memory-allocation failure path in this function). Like in the case of init_vp_index(), such hooks require to determine if the given channel is performance critical. init_vp_index() does this by parsing the channel's offer, it can not rely on the device data structure (device_obj) to retrieve such information because the device data structure has not been allocated/linked with the channel by the time that init_vp_index() executes. A similar situation may hold in hv_is_alloced_cpu() (defined below); the adopted approach is to "cache" the device type of the channel, as computed by parsing the channel's offer, in the channel structure itself.

Andrea Parri (Microsoft) committed 6 years ago

Commit afaa33d1 parent a949e864 files · +84 −12Browse files

Showing the changes to include/linux (1 of 4 files). Show all

Unified · Split

include/linux/hyperv.h+7−0
@@ -901,6 +901,13 @@ struct vmbus_channel { · 900 unmodified lines
901901
902902 bool probe_done;
903903
904+ /*
905+ * Cache the device ID here for easy access; this is useful, in
906+ * particular, in situations where the channel's device_obj has
907+ * not been allocated/initialized yet.
908+ */
909+ u16 device_id;
910+
904911 /*
905912 * We must offload the handling of the primary/sub channels
906913 * from the single-threaded vmbus_connection.work_queue to