diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-12-12 14:45:17 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-12-12 14:46:15 -0500 |
commit | 9207c7f874e7754391fdf184187fc763455466c5 (patch) | |
tree | 6294bb80fa85c37d780266cadb624d9054e5e915 | |
parent | c8483ef0959672310bf4ebb72e1a308b00543f74 (diff) |
Cluster assignment of nv klmirqd threads.
-rw-r--r-- | include/litmus/sched_plugin.h | 8 | ||||
-rw-r--r-- | litmus/nvidia_info.c | 15 | ||||
-rw-r--r-- | litmus/sched_cedf.c | 22 | ||||
-rw-r--r-- | litmus/sched_gsn_edf.c | 10 | ||||
-rw-r--r-- | litmus/sched_plugin.c | 14 |
5 files changed, 62 insertions, 7 deletions
diff --git a/include/litmus/sched_plugin.h b/include/litmus/sched_plugin.h index a13d1a2992fe..cfa218504d75 100644 --- a/include/litmus/sched_plugin.h +++ b/include/litmus/sched_plugin.h | |||
@@ -102,6 +102,10 @@ typedef int (*__higher_prio_t)(struct task_struct* a, comparison_mode_t a_mod, | |||
102 | struct task_struct* b, comparison_mode_t b_mod); | 102 | struct task_struct* b, comparison_mode_t b_mod); |
103 | #endif | 103 | #endif |
104 | 104 | ||
105 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) | ||
106 | typedef int (*default_cpu_for_gpu_t)(int gpu, int num_gpus); | ||
107 | #endif | ||
108 | |||
105 | 109 | ||
106 | /********************* sys call backends ********************/ | 110 | /********************* sys call backends ********************/ |
107 | /* This function causes the caller to sleep until the next release */ | 111 | /* This function causes the caller to sleep until the next release */ |
@@ -165,6 +169,10 @@ struct sched_plugin { | |||
165 | change_prio_pai_tasklet_t change_prio_pai_tasklet; | 169 | change_prio_pai_tasklet_t change_prio_pai_tasklet; |
166 | run_tasklets_t run_tasklets; | 170 | run_tasklets_t run_tasklets; |
167 | #endif | 171 | #endif |
172 | |||
173 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) | ||
174 | default_cpu_for_gpu_t map_gpu_to_cpu; | ||
175 | #endif | ||
168 | } __attribute__ ((__aligned__(SMP_CACHE_BYTES))); | 176 | } __attribute__ ((__aligned__(SMP_CACHE_BYTES))); |
169 | 177 | ||
170 | 178 | ||
diff --git a/litmus/nvidia_info.c b/litmus/nvidia_info.c index b29f4d3f0dac..0b39dcc84115 100644 --- a/litmus/nvidia_info.c +++ b/litmus/nvidia_info.c | |||
@@ -449,13 +449,16 @@ static int init_nv_device_reg(void) | |||
449 | INIT_BINHEAP_HANDLE(&NV_DEVICE_REG[i].owners, gpu_owner_max_priority_order); | 449 | INIT_BINHEAP_HANDLE(&NV_DEVICE_REG[i].owners, gpu_owner_max_priority_order); |
450 | 450 | ||
451 | #ifdef CONFIG_LITMUS_SOFTIRQD | 451 | #ifdef CONFIG_LITMUS_SOFTIRQD |
452 | // TODO: Make thread spawning this a litmus plugin call. | 452 | { |
453 | NV_DEVICE_REG[i].callback.func = nvidia_klmirqd_cb; | 453 | int default_cpu = litmus->map_gpu_to_cpu(i, NV_DEVICE_NUM); |
454 | NV_DEVICE_REG[i].callback.arg = (void*)(long long)(i); | 454 | |
455 | mb(); | 455 | NV_DEVICE_REG[i].callback.func = nvidia_klmirqd_cb; |
456 | NV_DEVICE_REG[i].callback.arg = (void*)(long long)(i); | ||
457 | mb(); | ||
456 | 458 | ||
457 | if(launch_klmirqd_thread(0, &NV_DEVICE_REG[i].callback) != 0) { | 459 | if(launch_klmirqd_thread(default_cpu, &NV_DEVICE_REG[i].callback) != 0) { |
458 | TRACE("Failed to create klmirqd thread for GPU %d\n", i); | 460 | TRACE("Failed to create klmirqd thread for GPU %d\n", i); |
461 | } | ||
459 | } | 462 | } |
460 | #endif | 463 | #endif |
461 | } | 464 | } |
diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c index 84aafca78cde..35ea1544ce69 100644 --- a/litmus/sched_cedf.c +++ b/litmus/sched_cedf.c | |||
@@ -1652,6 +1652,25 @@ static void cleanup_cedf(void) | |||
1652 | } | 1652 | } |
1653 | } | 1653 | } |
1654 | 1654 | ||
1655 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) | ||
1656 | static int cedf_map_gpu_to_cpu(int gpu, int num_gpus) | ||
1657 | { | ||
1658 | /* TODO: Some sort of smart clustering on the PCIe bus topology */ | ||
1659 | int num_gpu_clusters = num_clusters; | ||
1660 | unsigned int gpu_cluster_size = num_gpus / num_gpu_clusters; | ||
1661 | int cpu_cluster = gpu / gpu_cluster_size; | ||
1662 | int default_cpu = cedf[cpu_cluster].cpus[0]->cpu; // first CPU in given cluster | ||
1663 | |||
1664 | if(num_gpus % num_gpu_clusters != 0) { | ||
1665 | TRACE("GPU clusters are of non-uniform size!\n"); | ||
1666 | } | ||
1667 | |||
1668 | TRACE("CPU %d is default for GPU %d interrupt threads.\n", default_cpu, gpu); | ||
1669 | |||
1670 | return default_cpu; | ||
1671 | } | ||
1672 | #endif | ||
1673 | |||
1655 | static long cedf_activate_plugin(void) | 1674 | static long cedf_activate_plugin(void) |
1656 | { | 1675 | { |
1657 | int i, j, cpu, ccpu, cpu_count; | 1676 | int i, j, cpu, ccpu, cpu_count; |
@@ -1826,6 +1845,9 @@ static struct sched_plugin cedf_plugin __cacheline_aligned_in_smp = { | |||
1826 | .change_prio_pai_tasklet = cedf_change_prio_pai_tasklet, | 1845 | .change_prio_pai_tasklet = cedf_change_prio_pai_tasklet, |
1827 | .run_tasklets = cedf_run_tasklets, | 1846 | .run_tasklets = cedf_run_tasklets, |
1828 | #endif | 1847 | #endif |
1848 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) | ||
1849 | .map_gpu_to_cpu = cedf_map_gpu_to_cpu, | ||
1850 | #endif | ||
1829 | }; | 1851 | }; |
1830 | 1852 | ||
1831 | static struct proc_dir_entry *cluster_file = NULL, *cedf_dir = NULL; | 1853 | static struct proc_dir_entry *cluster_file = NULL, *cedf_dir = NULL; |
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c index f27c104ea027..1b5d8d73dc16 100644 --- a/litmus/sched_gsn_edf.c +++ b/litmus/sched_gsn_edf.c | |||
@@ -1835,7 +1835,12 @@ UNSUPPORTED_AFF_OBS: | |||
1835 | #endif | 1835 | #endif |
1836 | 1836 | ||
1837 | 1837 | ||
1838 | 1838 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) | |
1839 | static int gsnedf_map_gpu_to_cpu(int gpu, int num_gpus) | ||
1840 | { | ||
1841 | return 0; // CPU_0 is default in all cases. | ||
1842 | } | ||
1843 | #endif | ||
1839 | 1844 | ||
1840 | 1845 | ||
1841 | static long gsnedf_activate_plugin(void) | 1846 | static long gsnedf_activate_plugin(void) |
@@ -1918,6 +1923,9 @@ static struct sched_plugin gsn_edf_plugin __cacheline_aligned_in_smp = { | |||
1918 | .change_prio_pai_tasklet = gsnedf_change_prio_pai_tasklet, | 1923 | .change_prio_pai_tasklet = gsnedf_change_prio_pai_tasklet, |
1919 | .run_tasklets = gsnedf_run_tasklets, | 1924 | .run_tasklets = gsnedf_run_tasklets, |
1920 | #endif | 1925 | #endif |
1926 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) | ||
1927 | .map_gpu_to_cpu = gsnedf_map_gpu_to_cpu, | ||
1928 | #endif | ||
1921 | }; | 1929 | }; |
1922 | 1930 | ||
1923 | 1931 | ||
diff --git a/litmus/sched_plugin.c b/litmus/sched_plugin.c index 30c216fd6fdc..ea89f5fedcab 100644 --- a/litmus/sched_plugin.c +++ b/litmus/sched_plugin.c | |||
@@ -222,6 +222,13 @@ static long litmus_dummy_allocate_aff_obs(struct affinity_observer **aff_obs, | |||
222 | } | 222 | } |
223 | #endif | 223 | #endif |
224 | 224 | ||
225 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) | ||
226 | static int litmus_dummy_map_gpu_to_cpu(int gpu, int num_gpus) | ||
227 | { | ||
228 | return 0; | ||
229 | } | ||
230 | #endif | ||
231 | |||
225 | 232 | ||
226 | /* The default scheduler plugin. It doesn't do anything and lets Linux do its | 233 | /* The default scheduler plugin. It doesn't do anything and lets Linux do its |
227 | * job. | 234 | * job. |
@@ -262,6 +269,9 @@ struct sched_plugin linux_sched_plugin = { | |||
262 | #ifdef CONFIG_LITMUS_AFFINITY_LOCKING | 269 | #ifdef CONFIG_LITMUS_AFFINITY_LOCKING |
263 | .allocate_aff_obs = litmus_dummy_allocate_aff_obs, | 270 | .allocate_aff_obs = litmus_dummy_allocate_aff_obs, |
264 | #endif | 271 | #endif |
272 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) | ||
273 | .map_gpu_to_cpu = litmus_dummy_map_gpu_to_cpu, | ||
274 | #endif | ||
265 | 275 | ||
266 | .admit_task = litmus_dummy_admit_task | 276 | .admit_task = litmus_dummy_admit_task |
267 | }; | 277 | }; |
@@ -322,6 +332,10 @@ int register_sched_plugin(struct sched_plugin* plugin) | |||
322 | #ifdef CONFIG_LITMUS_AFFINITY_LOCKING | 332 | #ifdef CONFIG_LITMUS_AFFINITY_LOCKING |
323 | CHECK(allocate_aff_obs); | 333 | CHECK(allocate_aff_obs); |
324 | #endif | 334 | #endif |
335 | #if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) | ||
336 | CHECK(map_gpu_to_cpu); | ||
337 | #endif | ||
338 | |||
325 | CHECK(admit_task); | 339 | CHECK(admit_task); |
326 | 340 | ||
327 | if (!plugin->release_at) | 341 | if (!plugin->release_at) |