Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

neel-samsung
Copy link
Contributor

No description provided.


int sched_getcpucount(void)
{
return CONFIG_SMP_NCPUS;
Copy link
Contributor

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.

Copy link
Contributor

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;

Copy link
Contributor Author

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.

TizenRT/os/tools/mkconfig.c

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];
Copy link
Contributor

@jeongarmy jeongarmy Jan 17, 2025

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@kishore-sn
Copy link
Contributor

Please modify commit descriptions. This work is for ps and cpuload commands.
In app side commit, pls add the output of each of these commands for smp and no smp case.


int sched_getcpucount(void)
{
return CONFIG_SMP_NCPUS;
Copy link
Contributor

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

@@ -296,6 +296,10 @@ const struct tasklist_s g_tasklisttable[NUM_TASK_STATES] =
&g_readytorun,
TLIST_ATTR_PRIORITIZED | TLIST_ATTR_RUNNABLE
},
{ /* TSTATE_TASK_ASSIGNED */
Copy link
Contributor

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

Copy link
Contributor

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)

@kishore-sn
Copy link
Contributor

kishore-sn commented Jan 22, 2025

Please change commit title remove config dependency to fix ps command issue >>> Remove ssytem commands dependency on CONFIG_SMPxxx

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]>
@neel-samsung
Copy link
Contributor Author

Please change commit title remove config dependency to fix ps command issue >>> Remove ssytem commands dependency on CONFIG_SMPxxx

Updated

kishore-sn
kishore-sn previously approved these changes Feb 5, 2025
@kishore-sn
Copy link
Contributor

@sunghan-chang
Please let me know if I can merge this.

sunghan-chang
sunghan-chang previously approved these changes Feb 5, 2025
@sunghan-chang
Copy link
Contributor

@kishore-sn Let's merge.
And let's apply this to syscall as well. I want to remove all conditionals in the syscall.

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]>
@sunghan-chang
Copy link
Contributor

sunghan-chang commented Feb 6, 2025

@kishore-sn Let's merge.
And let's apply this to syscall as well. I want to remove all conditionals in the syscall.

What I mean above is removing all conditionals (not smp only) with new PR.
This is not related with this PR.

@sunghan-chang
Copy link
Contributor

@kishore-sn Let's merge this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants