From 98a57511b687ce1365140481d0c8cf597b6a5d43 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 29 Jul 2021 08:34:45 +0200 Subject: score: Add _Per_CPU_Submit_job() --- cpukit/include/rtems/score/percpu.h | 20 ++++++++++++++++---- cpukit/libtest/t-test-interrupt.c | 4 +--- cpukit/score/src/percpujobs.c | 9 ++++++++- cpukit/score/src/smpmulticastaction.c | 3 +-- cpukit/score/src/smpunicastaction.c | 3 +-- testsuites/smptests/smpfatal01/init.c | 7 +------ testsuites/smptests/smpipi01/init.c | 6 ++---- 7 files changed, 30 insertions(+), 22 deletions(-) diff --git a/cpukit/include/rtems/score/percpu.h b/cpukit/include/rtems/score/percpu.h index f72339620d..6081653a86 100644 --- a/cpukit/include/rtems/score/percpu.h +++ b/cpukit/include/rtems/score/percpu.h @@ -841,11 +841,10 @@ bool _Per_CPU_State_wait_for_non_initial_state( void _Per_CPU_Perform_jobs( Per_CPU_Control *cpu ); /** - * @brief Adds the job to the tail of the processing list of the specified - * processor. + * @brief Adds the job to the tail of the processing list of the processor. * - * This function does not send the SMP_MESSAGE_PERFORM_JOBS message the - * specified processor. + * This function does not send the ::SMP_MESSAGE_PERFORM_JOBS message to the + * processor, see also _Per_CPU_Submit_job(). * * @param[in, out] cpu The processor to add the job. * @param[in, out] job The job. The Per_CPU_Job::context member must be @@ -853,6 +852,19 @@ void _Per_CPU_Perform_jobs( Per_CPU_Control *cpu ); */ void _Per_CPU_Add_job( Per_CPU_Control *cpu, Per_CPU_Job *job ); +/** + * @brief Adds the job to the tail of the processing list of the processor and + * notifies the processor to process the job. + * + * This function sends the ::SMP_MESSAGE_PERFORM_JOBS message to the processor + * if it is in the ::PER_CPU_STATE_UP state, see also _Per_CPU_Add_job(). + * + * @param[in, out] cpu The processor to add the job. + * @param[in, out] job The job. The Per_CPU_Job::context member must be + * initialized by the caller. + */ +void _Per_CPU_Submit_job( Per_CPU_Control *cpu, Per_CPU_Job *job ); + /** * @brief Waits for the job carried out by the specified processor. * diff --git a/cpukit/libtest/t-test-interrupt.c b/cpukit/libtest/t-test-interrupt.c index cbdc603802..5d83b7876a 100644 --- a/cpukit/libtest/t-test-interrupt.c +++ b/cpukit/libtest/t-test-interrupt.c @@ -305,9 +305,7 @@ T_interrupt_thread_switch(Thread_Control *executing, Thread_Control *heir) * context of the inter-processor interrupt. */ cpu_self = _Per_CPU_Get(); - _Per_CPU_Add_job(cpu_self, &ctx->job); - _SMP_Send_message(_Per_CPU_Get_index(cpu_self), - SMP_MESSAGE_PERFORM_JOBS); + _Per_CPU_Submit_job(cpu_self, &ctx->job); #else (*ctx->blocked)(ctx->arg); #endif diff --git a/cpukit/score/src/percpujobs.c b/cpukit/score/src/percpujobs.c index 4ce96dc738..5aa2f8eb8b 100644 --- a/cpukit/score/src/percpujobs.c +++ b/cpukit/score/src/percpujobs.c @@ -6,7 +6,8 @@ * @ingroup RTEMSScorePerCPU * * @brief This source file contains the implementation of _Per_CPU_Add_job(), - * _Per_CPU_Perform_jobs(), and _Per_CPU_Wait_for_job(). + * _Per_CPU_Perform_jobs(), _Per_CPU_Submit_job(), and + * _Per_CPU_Wait_for_job(). */ /* @@ -90,6 +91,12 @@ void _Per_CPU_Add_job( Per_CPU_Control *cpu, Per_CPU_Job *job ) _Per_CPU_Jobs_release_and_ISR_enable( cpu, &lock_context ); } +void _Per_CPU_Submit_job( Per_CPU_Control *cpu, Per_CPU_Job *job ) +{ + _Per_CPU_Add_job( cpu, job ); + _SMP_Send_message( _Per_CPU_Get_index( cpu ), SMP_MESSAGE_PERFORM_JOBS ); +} + void _Per_CPU_Wait_for_job( const Per_CPU_Control *cpu, const Per_CPU_Job *job diff --git a/cpukit/score/src/smpmulticastaction.c b/cpukit/score/src/smpmulticastaction.c index 6b9e9a30db..b4068c23c9 100644 --- a/cpukit/score/src/smpmulticastaction.c +++ b/cpukit/score/src/smpmulticastaction.c @@ -63,8 +63,7 @@ static void _SMP_Issue_action_jobs( job->context = &jobs->Context; cpu = _Per_CPU_Get_by_index( cpu_index ); - _Per_CPU_Add_job( cpu, job ); - _SMP_Send_message( cpu_index, SMP_MESSAGE_PERFORM_JOBS ); + _Per_CPU_Submit_job( cpu, job ); } } } diff --git a/cpukit/score/src/smpunicastaction.c b/cpukit/score/src/smpunicastaction.c index bc481eb4a4..fa5b5bb7c6 100644 --- a/cpukit/score/src/smpunicastaction.c +++ b/cpukit/score/src/smpunicastaction.c @@ -54,7 +54,6 @@ void _SMP_Unicast_action( context.arg = arg; job.context = &context; cpu = _Per_CPU_Get_by_index( cpu_index ); - _Per_CPU_Add_job( cpu, &job ); - _SMP_Send_message( cpu_index, SMP_MESSAGE_PERFORM_JOBS ); + _Per_CPU_Submit_job( cpu, &job ); _Per_CPU_Wait_for_job( cpu, &job ); } diff --git a/testsuites/smptests/smpfatal01/init.c b/testsuites/smptests/smpfatal01/init.c index 6ee08cf653..431d71dd65 100644 --- a/testsuites/smptests/smpfatal01/init.c +++ b/testsuites/smptests/smpfatal01/init.c @@ -136,12 +136,7 @@ static rtems_status_code test_driver_init( if (cpu_count > 1) { Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( other_cpu ); - _Per_CPU_Add_job(per_cpu, &shutdown_job); - _Atomic_Fetch_or_ulong( - &per_cpu->message, - SMP_MESSAGE_PERFORM_JOBS, - ATOMIC_ORDER_RELEASE - ); + _Per_CPU_Submit_job(per_cpu, &shutdown_job); } else { TEST_END(); exit(0); diff --git a/testsuites/smptests/smpipi01/init.c b/testsuites/smptests/smpipi01/init.c index 18b7a9ae17..e815911539 100644 --- a/testsuites/smptests/smpipi01/init.c +++ b/testsuites/smptests/smpipi01/init.c @@ -121,8 +121,7 @@ static void test_send_message_while_processing_a_message( Per_CPU_Control *cpu_self; ctx->jobs[0][0].context = &barrier_0_job_context; - _Per_CPU_Add_job(_Per_CPU_Get_by_index(cpu_index), &ctx->jobs[0][0]); - _SMP_Send_message(cpu_index, SMP_MESSAGE_PERFORM_JOBS); + _Per_CPU_Submit_job(_Per_CPU_Get_by_index(cpu_index), &ctx->jobs[0][0]); /* (A) */ barrier(ctx, bs); @@ -196,8 +195,7 @@ static void test_send_message_flood( ctx->jobs[cpu_index][0].context = &counter_0_job_context; ctx->jobs[cpu_index][1].context = &counter_1_job_context; - _Per_CPU_Add_job(cpu, &ctx->jobs[cpu_index][0]); - _SMP_Send_message(cpu_index, SMP_MESSAGE_PERFORM_JOBS); + _Per_CPU_Submit_job(cpu, &ctx->jobs[cpu_index][0]); } for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) { -- cgit v1.2.3