You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2021/07/15 23:38:02 UTC
[incubator-nuttx] branch master updated (da01a39 -> cee43ce)
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.
from da01a39 Revert "Kinetis:Serial No DMA Poll needed"
new bd74dc2 sched/init: Remove the unnessary CONFIG_SMP check
new a5ac446 sched/init: initialize all idle thread's tl_task
new cee43ce arch/sim: Initialize the idle thread stack info correctly
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
arch/sim/src/sim/up_cpuidlestack.c | 7 +---
arch/sim/src/sim/up_internal.h | 5 +--
arch/sim/src/sim/up_simsmp.c | 15 +++-----
arch/sim/src/sim/up_smpsignal.c | 35 ++++++++++++++++--
sched/Kconfig | 1 +
sched/init/nx_smpstart.c | 27 +-------------
sched/init/nx_start.c | 75 +++++++++++++++++++++-----------------
7 files changed, 83 insertions(+), 82 deletions(-)
[incubator-nuttx] 01/03: sched/init: Remove the unnessary
CONFIG_SMP check
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit bd74dc2b88fd613556ace75c9d2f2670f10198ef
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Jul 15 19:46:07 2021 +0800
sched/init: Remove the unnessary CONFIG_SMP check
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
Change-Id: I2afaf310b411993e37140b3d7977968a7fda5c3b
---
sched/init/nx_start.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c
index eb15485..eff067d 100644
--- a/sched/init/nx_start.c
+++ b/sched/init/nx_start.c
@@ -67,11 +67,9 @@
# define CONFIG_SMP_NCPUS 1
#endif
-#ifdef CONFIG_SMP
/* This set of all CPUs */
-# define SCHED_ALL_CPUS ((1 << CONFIG_SMP_NCPUS) - 1)
-#endif /* CONFIG_SMP */
+#define SCHED_ALL_CPUS ((1 << CONFIG_SMP_NCPUS) - 1)
/****************************************************************************
* Public Data
@@ -422,12 +420,7 @@ void nx_start(void)
TCB_FLAG_NONCANCELABLE |
TCB_FLAG_CPU_LOCKED);
g_idletcb[i].cmn.cpu = i;
-#else
- g_idletcb[i].cmn.flags = (TCB_FLAG_TTYPE_KERNEL |
- TCB_FLAG_NONCANCELABLE);
-#endif
-#ifdef CONFIG_SMP
/* Set the affinity mask to allow the thread to run on all CPUs. No,
* this IDLE thread can only run on its assigned CPU. That is
* enforced by the TCB_FLAG_CPU_LOCKED which overrides the affinity
@@ -437,6 +430,9 @@ void nx_start(void)
*/
g_idletcb[i].cmn.affinity = SCHED_ALL_CPUS;
+#else
+ g_idletcb[i].cmn.flags = (TCB_FLAG_TTYPE_KERNEL |
+ TCB_FLAG_NONCANCELABLE);
#endif
#if CONFIG_TASK_NAME_SIZE > 0
@@ -449,7 +445,6 @@ void nx_start(void)
strncpy(g_idletcb[i].cmn.name, g_idlename, CONFIG_TASK_NAME_SIZE);
g_idletcb[i].cmn.name[CONFIG_TASK_NAME_SIZE] = '\0';
# endif
-#endif
/* Configure the task name in the argument list. The IDLE task does
* not really have an argument list, but this name is still useful
@@ -459,7 +454,6 @@ void nx_start(void)
* stack and there is no support that yet.
*/
-#if CONFIG_TASK_NAME_SIZE > 0
g_idleargv[i][0] = g_idletcb[i].cmn.name;
#else
g_idleargv[i][0] = (FAR char *)g_idlename;
[incubator-nuttx] 03/03: arch/sim: Initialize the idle thread stack
info correctly
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit cee43ce280cfe1e704a16d860cf5087a8e014838
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Jul 16 02:23:59 2021 +0800
arch/sim: Initialize the idle thread stack info correctly
and change the default value of IDLETHREAD_STACKSIZE to 65536
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
Change-Id: Ia54efbbca4b69706150bc4178844b316688a104e
---
arch/sim/src/sim/up_cpuidlestack.c | 7 +------
arch/sim/src/sim/up_internal.h | 5 ++---
arch/sim/src/sim/up_simsmp.c | 15 ++++++---------
arch/sim/src/sim/up_smpsignal.c | 35 +++++++++++++++++++++++++++++++----
sched/Kconfig | 1 +
5 files changed, 41 insertions(+), 22 deletions(-)
diff --git a/arch/sim/src/sim/up_cpuidlestack.c b/arch/sim/src/sim/up_cpuidlestack.c
index 981fbc9..c9effa7 100644
--- a/arch/sim/src/sim/up_cpuidlestack.c
+++ b/arch/sim/src/sim/up_cpuidlestack.c
@@ -78,10 +78,5 @@
int up_cpu_idlestack(int cpu, FAR struct tcb_s *tcb, size_t stack_size)
{
- /* REVISIT: I don't think anything is needed here */
-
- tcb->adj_stack_size = 0;
- tcb->stack_alloc_ptr = NULL;
- tcb->stack_base_ptr = NULL;
- return OK;
+ return up_create_stack(tcb, stack_size, TCB_FLAG_TTYPE_KERNEL);
}
diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h
index 307d7aa..7506d19 100644
--- a/arch/sim/src/sim/up_internal.h
+++ b/arch/sim/src/sim/up_internal.h
@@ -165,16 +165,15 @@ void sim_sigdeliver(void);
#ifdef CONFIG_SMP
void sim_cpu0_start(void);
+int sim_cpu_start(int cpu, void *stack, size_t size);
+void sim_send_ipi(int cpu);
#endif
/* up_smpsignal.c ***********************************************************/
#ifdef CONFIG_SMP
void up_cpu_started(void);
-int up_cpu_paused(int cpu);
-struct tcb_s *up_this_task(void);
int up_cpu_set_pause_handler(int irq);
-void sim_send_ipi(int cpu);
#endif
/* up_oneshot.c *************************************************************/
diff --git a/arch/sim/src/sim/up_simsmp.c b/arch/sim/src/sim/up_simsmp.c
index 90ff1cb..e91917f 100644
--- a/arch/sim/src/sim/up_simsmp.c
+++ b/arch/sim/src/sim/up_simsmp.c
@@ -260,17 +260,12 @@ int up_cpu_index(void)
*
****************************************************************************/
-int up_cpu_start(int cpu)
+int sim_cpu_start(int cpu, void *stack, size_t size)
{
struct sim_cpuinfo_s cpuinfo;
+ pthread_attr_t attr;
int ret;
-#ifdef CONFIG_SCHED_INSTRUMENTATION
- /* Notify of the start event */
-
- sched_note_cpu_start(up_this_task(), cpu);
-#endif
-
/* Initialize the CPU info */
cpuinfo.cpu = cpu;
@@ -283,11 +278,13 @@ int up_cpu_start(int cpu)
* in a multi-CPU hardware model.
*/
+ pthread_attr_init(&attr);
+ pthread_attr_setstack(&attr, stack, size);
ret = pthread_create(&g_cpu_thread[cpu],
- NULL, sim_idle_trampoline, &cpuinfo);
+ &attr, sim_idle_trampoline, &cpuinfo);
+ pthread_attr_destroy(&attr);
if (ret != 0)
{
- ret = -ret; /* REVISIT: That is a host errno value. */
goto errout_with_cond;
}
diff --git a/arch/sim/src/sim/up_smpsignal.c b/arch/sim/src/sim/up_smpsignal.c
index cad6cca..249bbc6 100644
--- a/arch/sim/src/sim/up_smpsignal.c
+++ b/arch/sim/src/sim/up_smpsignal.c
@@ -233,16 +233,43 @@ void up_cpu_started(void)
}
/****************************************************************************
- * Name: up_this_task
+ * Name: up_cpu_start
*
* Description:
- * Return the currrent task tcb.
+ * In an SMP configution, only one CPU is initially active (CPU 0). System
+ * initialization occurs on that single thread. At the completion of the
+ * initialization of the OS, just before beginning normal multitasking,
+ * the additional CPUs would be started by calling this function.
+ *
+ * Each CPU is provided the entry point to is IDLE task when started. A
+ * TCB for each CPU's IDLE task has been initialized and placed in the
+ * CPU's g_assignedtasks[cpu] list. A stack has also been allocateded and
+ * initialized.
+ *
+ * The OS initialization logic calls this function repeatedly until each
+ * CPU has been started, 1 through (CONFIG_SMP_NCPUS-1).
+ *
+ * Input Parameters:
+ * cpu - The index of the CPU being started. This will be a numeric
+ * value in the range of from one to (CONFIG_SMP_NCPUS-1). (CPU
+ * 0 is already active)
+ *
+ * Returned Value:
+ * Zero on success; a negated errno value on failure.
*
****************************************************************************/
-struct tcb_s *up_this_task(void)
+int up_cpu_start(int cpu)
{
- return this_task();
+ FAR struct tcb_s *tcb = current_task(cpu);
+
+#ifdef CONFIG_SCHED_INSTRUMENTATION
+ /* Notify of the start event */
+
+ sched_note_cpu_start(this_task(), cpu);
+#endif
+
+ return sim_cpu_start(cpu, tcb->stack_base_ptr, tcb->adj_stack_size);
}
/****************************************************************************
diff --git a/sched/Kconfig b/sched/Kconfig
index 4f694be..c14a088 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -1800,6 +1800,7 @@ config DEFAULT_TASK_STACKSIZE
config IDLETHREAD_STACKSIZE
int "Idle thread stack size"
+ default DEFAULT_TASK_STACKSIZE if ARCH_SIM
default 1024
---help---
The size of the initial stack used by the IDLE thread. The IDLE thread
[incubator-nuttx] 02/03: sched/init: initialize all idle thread's
tl_task
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit a5ac4463c28a0583df320cd294875a3fa2bea57b
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Jul 15 18:25:48 2021 +0800
sched/init: initialize all idle thread's tl_task
since this patch forget to initialize the idle tls info:
commit 50c08bf45b1adcafc409480f300ac49a4b2c689c
Author: Huang Qi <hu...@xiaomi.com>
Date: Tue Jun 29 16:01:02 2021 +0800
libc: Move pthread_key_destructor to task_info_s
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
Change-Id: If7d0c0118323fa3dcf44081d675cd57b14eba75a
---
sched/init/nx_smpstart.c | 27 +--------------------
sched/init/nx_start.c | 61 +++++++++++++++++++++++++++++-------------------
2 files changed, 38 insertions(+), 50 deletions(-)
diff --git a/sched/init/nx_smpstart.c b/sched/init/nx_smpstart.c
index 4bcb712..bb7675d 100644
--- a/sched/init/nx_smpstart.c
+++ b/sched/init/nx_smpstart.c
@@ -34,7 +34,6 @@
#include <nuttx/kmalloc.h>
#include <nuttx/sched.h>
#include <nuttx/sched_note.h>
-#include <nuttx/tls.h>
#include "group/group.h"
#include "sched/sched.h"
@@ -113,31 +112,7 @@ int nx_smp_start(void)
int ret;
int cpu;
- /* Create a stack for all CPU IDLE threads (except CPU0 which already has
- * a stack).
- */
-
- for (cpu = 1; cpu < CONFIG_SMP_NCPUS; cpu++)
- {
- FAR struct tcb_s *tcb = current_task(cpu);
- DEBUGASSERT(tcb != NULL);
-
- ret = up_cpu_idlestack(cpu, tcb, CONFIG_IDLETHREAD_STACKSIZE);
- if (ret < 0)
- {
- serr("ERROR: Failed to allocate stack for CPU%d\n", cpu);
- return ret;
- }
-
- /* Initialize the processor-specific portion of the TCB */
-
- up_initial_state(tcb);
- up_stack_frame(tcb, sizeof(struct task_info_s));
- }
-
- /* Then start all of the other CPUs after we have completed the memory
- * allocations. CPU0 is already running.
- */
+ /* Start all of the other CPUs. CPU0 is already running. */
for (cpu = 1; cpu < CONFIG_SMP_NCPUS; cpu++)
{
diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c
index eff067d..f54095f 100644
--- a/sched/init/nx_start.c
+++ b/sched/init/nx_start.c
@@ -475,16 +475,6 @@ void nx_start(void)
/* Mark the idle task as the running task */
g_running_tasks[i] = &g_idletcb[i].cmn;
-
- /* Initialize the 1st processor-specific portion of the TCB
- * Note: other idle thread get initialized in nx_smpstart
- */
-
- if (i == 0)
- {
- up_initial_state(&g_idletcb[i].cmn);
- up_stack_frame(&g_idletcb[i].cmn, sizeof(struct task_info_s));
- }
}
/* Task lists are initialized */
@@ -566,8 +556,11 @@ void nx_start(void)
g_pidhash[i].pid = INVALID_PROCESS_ID;
}
+ /* IDLE Group Initialization **********************************************/
+
for (i = 0; i < CONFIG_SMP_NCPUS; i++)
{
+ FAR struct tls_info_s *info;
int hashndx;
/* Assign the process ID(s) of ZERO to the idle task(s) */
@@ -575,6 +568,39 @@ void nx_start(void)
hashndx = PIDHASH(i);
g_pidhash[hashndx].tcb = &g_idletcb[i].cmn;
g_pidhash[hashndx].pid = i;
+
+ /* Allocate the IDLE group */
+
+ DEBUGVERIFY(group_allocate(&g_idletcb[i], g_idletcb[i].cmn.flags));
+
+#ifdef CONFIG_SMP
+ /* Create a stack for all CPU IDLE threads (except CPU0 which already
+ * has a stack).
+ */
+
+ if (i > 0)
+ {
+ DEBUGVERIFY(up_cpu_idlestack(i, &g_idletcb[i].cmn,
+ CONFIG_IDLETHREAD_STACKSIZE));
+ }
+#endif
+
+ /* Initialize the processor-specific portion of the TCB */
+
+ up_initial_state(&g_idletcb[i].cmn);
+
+ /* Initialize the thread local storage */
+
+ info = up_stack_frame(&g_idletcb[i].cmn, sizeof(struct tls_info_s));
+ DEBUGASSERT(info == g_idletcb[i].cmn.stack_alloc_ptr);
+ info->tl_task = g_idletcb[i].cmn.group->tg_info;
+
+ /* Complete initialization of the IDLE group. Suppress retention
+ * of child status in the IDLE group.
+ */
+
+ DEBUGVERIFY(group_initialize(&g_idletcb[i]));
+ g_idletcb[i].cmn.group->tg_flags = GROUP_FLAG_NOCLDWAIT;
}
g_lastpid = CONFIG_SMP_NCPUS - 1;
@@ -703,20 +729,14 @@ void nx_start(void)
binfmt_initialize();
#endif
- /* IDLE Group Initialization **********************************************/
-
/* Announce that the CPU0 IDLE task has started */
sched_note_start(&g_idletcb[0].cmn);
- /* Initialize the IDLE group for the IDLE task of each CPU */
+ /* Initialize stdio for the IDLE task of each CPU */
for (i = 0; i < CONFIG_SMP_NCPUS; i++)
{
- /* Allocate the IDLE group */
-
- DEBUGVERIFY(group_allocate(&g_idletcb[i], g_idletcb[i].cmn.flags));
-
if (i > 0)
{
/* Clone stdout, stderr, stdin from the CPU0 IDLE task. */
@@ -732,13 +752,6 @@ void nx_start(void)
DEBUGVERIFY(group_setupidlefiles(&g_idletcb[i]));
}
-
- /* Complete initialization of the IDLE group. Suppress retention
- * of child status in the IDLE group.
- */
-
- DEBUGVERIFY(group_initialize(&g_idletcb[i]));
- g_idletcb[i].cmn.group->tg_flags = GROUP_FLAG_NOCLDWAIT;
}
/* Start SYSLOG ***********************************************************/