Changeset d70fc74 in mainline
- Timestamp:
- 2012-07-06T12:58:58Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ef1603b
- Parents:
- 1f8c11f
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/smp/smp_call.c
r1f8c11f rd70fc74 54 54 * 55 55 * If @a cpu_id is the local CPU, the function will be invoked 56 * directly. 56 * directly. If the destination cpu id @a cpu_id is invalid 57 * or denotes an inactive cpu, the call is discarded immediately. 57 58 * 58 59 * Interrupts must be enabled. Otherwise you run the risk 59 60 * of a deadlock. 60 61 * 61 * @param cpu_id Destination CPU's logical id (eg CPU->id) 62 * @param cpu_id Destination CPU's logical id (eg CPU->id). 62 63 * @param func Function to call. 63 64 * @param arg Argument to pass to the user supplied function @a func. … … 73 74 74 75 /* Discard invalid calls. */ 75 if (config.cpu_count <= cpu_id ) {76 if (config.cpu_count <= cpu_id || !cpus[cpu_id].active) { 76 77 call_start(call_info, func, arg); 77 78 call_done(call_info); … … 81 82 /* Protect cpu->id against migration. */ 82 83 preemption_disable(); 83 84 84 85 call_start(call_info, func, arg); 85 86 … … 89 90 list_append(&call_info->calls_link, &cpus[cpu_id].smp_pending_calls); 90 91 spinlock_unlock(&cpus[cpu_id].smp_calls_lock); 91 92 93 /* 94 * If a platform supports SMP it must implement arch_smp_call_ipi(). 95 * It should issue an IPI an cpu_id and invoke smp_call_ipi_recv() 96 * on cpu_id in turn. 97 * 98 * Do not implement as just an empty dummy function. Instead 99 * consider providing a full implementation or at least a version 100 * that panics if invoked. Note that smp_call_async() never 101 * calls arch_smp_call_ipi() on uniprocessors even if CONFIG_SMP. 102 */ 92 103 arch_smp_call_ipi(cpu_id); 93 104 #endif … … 131 142 /** Architecture independent smp call IPI handler. 132 143 * 133 * Interrupts must be disabled. 144 * Interrupts must be disabled. Tolerates spurious calls. 134 145 */ 135 146 void smp_call_ipi_recv(void) -
kernel/test/smpcall/smpcall1.c
r1f8c11f rd70fc74 14 14 /* 15 15 * Maximum total number of smp_calls in the system is: 16 * 1 28000 == 8^2 * 1000 * 216 * 162000 == 9^2 * 1000 * 2 17 17 * == MAX_CPUS^2 * ITERATIONS * EACH_CPU_INC_PER_ITER 18 18 */ 19 #define MAX_CPUS 819 #define MAX_CPUS 9 20 20 #define ITERATIONS 1000 21 21 #define EACH_CPU_INC_PER_ITER 2 … … 40 40 smp_call_t call_info[MAX_CPUS]; 41 41 42 size_t cpu_count = min(config.cpu_count, MAX_CPUS);42 unsigned int cpu_count = min(config.cpu_active, MAX_CPUS); 43 43 44 44 for (int iter = 0; iter < ITERATIONS; ++iter) { … … 75 75 } 76 76 77 static size_t calc_exp_calls(size_t thread_cnt) 78 { 79 return thread_cnt * ITERATIONS * EACH_CPU_INC_PER_ITER; 80 } 77 81 78 82 const char *test_smpcall1(void) … … 82 86 thread_t *thread[MAX_CPUS] = {0}; 83 87 84 unsigned int cpu_count = min(config.cpu_ count, MAX_CPUS);88 unsigned int cpu_count = min(config.cpu_active, MAX_CPUS); 85 89 size_t running_thread_cnt = 0; 86 90 … … 100 104 } 101 105 102 TPRINTF("Running %u wired threads.\n", running_thread_cnt); 106 size_t exp_calls = calc_exp_calls(running_thread_cnt); 107 size_t exp_calls_sum = exp_calls * cpu_count; 108 109 TPRINTF("Running %zu wired threads. Expecting %zu calls. Be patient.\n", 110 running_thread_cnt, exp_calls_sum); 103 111 104 112 for (unsigned int i = 0; i < cpu_count; ++i) { … … 112 120 if (thread[i] != NULL) { 113 121 thread_join(thread[i]); 122 thread_detach(thread[i]); 114 123 } 115 124 } 116 125 117 126 TPRINTF("Threads finished. Checking number of smp_call()s.\n"); 118 119 size_t exp_calls = running_thread_cnt * ITERATIONS * EACH_CPU_INC_PER_ITER;120 size_t exp_calls_sum = exp_calls * cpu_count;121 127 122 128 bool ok = true; … … 127 133 if (call_cnt[i] != exp_calls) { 128 134 ok = false; 129 TPRINTF("Error: % u instead of %u cpu%u's calls were"135 TPRINTF("Error: %zu instead of %zu cpu%u's calls were" 130 136 " acknowledged.\n", call_cnt[i], exp_calls, i); 131 137 } … … 136 142 137 143 if (calls_sum != exp_calls_sum) { 138 TPRINTF("Error: total acknowledged sum: % u instead of %u.\n",144 TPRINTF("Error: total acknowledged sum: %zu instead of %zu.\n", 139 145 calls_sum, exp_calls_sum); 140 146 … … 143 149 144 150 if (ok) { 145 TPRINTF("Success: number of received smp_calls is as expected (% u).\n",151 TPRINTF("Success: number of received smp_calls is as expected (%zu).\n", 146 152 exp_calls_sum); 147 153 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.