-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove config dependency to fix ps command issue #6634
base: master
Are you sure you want to change the base?
Conversation
65b699c
to
c1afe15
Compare
os/kernel/sched/sched_getcpu.c
Outdated
|
||
int sched_getcpucount(void) | ||
{ | ||
return CONFIG_SMP_NCPUS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this value is not present?
I think we need to define values for when config is not existing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like
#if defined(CONFIG_SMP_NCPUS)
return CONFIG_SMP_NCPUS;
#else
return 0
or
In the file,
#if defined(CONFIG_SMP_NCPUS)
#define NCPUS CONFIG_SMP_NCPUS
#else
#define NCPUS 0
...
in sched_getcpucount()
return NCPUS;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are already defining the config if it is not present.
Lines 302 to 304 in e28022b
printf("#ifndef CONFIG_SMP_NCPUS\n"); | |
printf("# define CONFIG_SMP_NCPUS 1\n"); | |
printf("#endif\n\n"); |
@@ -179,32 +177,24 @@ static void cpuload_print_pid_value(char *buf, void *arg) | |||
} else { | |||
#ifdef CONFIG_SCHED_MULTI_CPULOAD | |||
for (i = PROC_STAT_CPULOAD_SHORT; i <= PROC_STAT_CPULOAD_LONG; i++) { | |||
#ifdef CONFIG_SMP | |||
char * avgload[CONFIG_SMP_NCPUS + 1]; | |||
char * avgload[ncpus + 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ncpus
is not static value. you define array with not defined value.. Is it ok? I think it makes warning or error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, this also shouldn't create issue as syscall will return a constant value based on CONFIG_SMP_NCPUS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we are not supposed to delare array using a variable as the array size.
In this case, it might not cause issue because the array is local to the for loop and the ncpus variable is outside of the loop. However, pls check again to make sure you dont get any warning or error during build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made sure that it doesn't give any warning or failure.
Please modify commit descriptions. This work is for ps and cpuload commands. |
os/kernel/sched/sched_getcpu.c
Outdated
|
||
int sched_getcpucount(void) | ||
{ | ||
return CONFIG_SMP_NCPUS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coding rule violation, should use a tab instead of spaces
os/kernel/init/os_start.c
Outdated
@@ -296,6 +296,10 @@ const struct tasklist_s g_tasklisttable[NUM_TASK_STATES] = | |||
&g_readytorun, | |||
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_RUNNABLE | |||
}, | |||
{ /* TSTATE_TASK_ASSIGNED */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coding rule violations. Same as other lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To split different topic of change, in this commit, please modify lines you added only. And please add one more commit to modify other lines violations. (or new pr)
c1afe15
to
783f8be
Compare
Please change commit title |
Due to config dependency, system commands don't give correct output. So, this patch fix the issue by removing config dependency for CONFIG_SMP and CONFIG_SMP_NCPUS. It fixes the ps command issue completely but it doesn't completely resolve cpuload command issue. ps output smp disabled: PID | PRIO | FLAG | TYPE | NP | STATUS | CPU | NAME ------|------|------|---------|----|----------|-----|---- 0 | 0 | FIFO | KTHREAD | N | READY | 0 | Idle Task 1 | 201 | RR | KTHREAD | | WAITSIG | 0 | hpwork 2 | 50 | RR | KTHREAD | | WAITSIG | 0 | lpwork 4 | 200 | RR | KTHREAD | | MQNEMPTY | 0 | km4_log_task 5 | 107 | RR | KTHREAD | | WAITSEM | 0 | inic_msg_q_task 6 | 104 | RR | KTHREAD | | WAITSEM | 0 | inic_host_rx_tasklet 7 | 103 | RR | KTHREAD | | WAITSEM | 0 | inic_ipc_api_host_task 9 | 105 | RR | KTHREAD | | WAITSEM | 0 | LWIP_TCP/IP 10 | 100 | RR | KTHREAD | | WAITSEM | 0 | netmgr_event_handler 11 | 200 | RR | KTHREAD | | MQNEMPTY | 0 | log_dump 12 | 203 | RR | KTHREAD | | MQNEMPTY | 0 | binary_manager 15 | 180 | RR | TASK | | WAITSIG | 0 | app1 16 | 100 | RR | TASK | | WAITSIG | 0 | uwork 17 | 125 | RR | TASK | | RUNNING | 0 | tash 18 | 100 | RR | TASK | | WAITSEM | 0 | wifi msg handler 19 | 100 | RR | TASK | | WAITSEM | 0 | ble msg handler ps output smp enabled: PID | PRIO | FLAG | TYPE | NP | STATUS | CPU | NAME ------|------|------|---------|----|----------|-----|---- 0 | 0 | FIFO | KTHREAD | N | ASSIGNED | 0 | CPU0 IDLE 1 | 0 | FIFO | KTHREAD | N | RUNNING | 1 | CPU1 IDLE 2 | 201 | FIFO | KTHREAD | | WAITSIG | 0 | hpwork 3 | 50 | FIFO | KTHREAD | | WAITSIG | 0 | lpwork 5 | 200 | FIFO | KTHREAD | | MQNEMPTY | 0 | km4_log_task 6 | 107 | FIFO | KTHREAD | | WAITSEM | 0 | inic_msg_q_task 7 | 104 | FIFO | KTHREAD | | WAITSEM | 0 | inic_host_rx_tasklet 8 | 103 | FIFO | KTHREAD | | WAITSEM | 0 | inic_ipc_api_host_task 10 | 105 | FIFO | KTHREAD | | WAITSEM | 0 | LWIP_TCP/IP 11 | 100 | FIFO | KTHREAD | | WAITSEM | 0 | netmgr_event_handler 12 | 200 | FIFO | KTHREAD | | MQNEMPTY | 0 | log_dump 13 | 203 | FIFO | KTHREAD | | MQNEMPTY | 0 | binary_manager 16 | 180 | FIFO | TASK | | WAITSIG | 0 | app1 17 | 100 | FIFO | TASK | | WAITSIG | 0 | uwork 18 | 125 | FIFO | TASK | | RUNNING | 0 | tash 19 | 100 | FIFO | TASK | | WAITSEM | 0 | wifi msg handler 20 | 100 | FIFO | TASK | | WAITSEM | 0 | ble msg handler Signed-off-by: neel-samsung <[email protected]>
783f8be
to
8728416
Compare
Updated |
@sunghan-chang |
@kishore-sn Let's merge. |
Due to config dependency, system commands don't give correct output. So, this patch fix the ps command issue by removing config dependency for CONFIG_SMP and CONFIG_SMP_NCPUS between Kernel and application. We handle it by introducing the syscall for obtaining the number of CPUs while runtime. Signed-off-by: neel-samsung <[email protected]>
This patch fixes the indentation from 2 space indent to tab indent. Signed-off-by: neel-samsung <[email protected]>
b29bcbd
8728416
to
b29bcbd
Compare
What I mean above is removing all conditionals (not smp only) with new PR. |
@kishore-sn Let's merge this PR. |
No description provided.