This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 0985b8a864b sched/group: guard capabilities field by Kconfig
0985b8a864b is described below

commit 0985b8a864b5b17eedac337126487ae1a4db62c5
Author: chao an <[email protected]>
AuthorDate: Tue Oct 20 14:28:17 2026 +0800

    sched/group: guard capabilities field by Kconfig
    
    The task group capability byte is only used when
    CONFIG_SCHED_CAPABILITIES is enabled.  nxsched_capable() already folds
    to true when that option is disabled, so keeping tg_caps in every task
    group wastes space in configurations that do not support scheduler
    capability checks.
    
    Guard tg_caps and the corresponding initialization paths with
    CONFIG_SCHED_CAPABILITIES.  This reduces struct task_group_s for small
    flat configurations without changing behavior when capabilities are
    disabled.
    
    Signed-off-by: chao an <[email protected]>
---
 include/nuttx/sched.h      | 2 ++
 sched/group/group_create.c | 4 ++++
 sched/init/nx_start.c      | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 59e06a686c9..04747b34428 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -462,7 +462,9 @@ struct task_group_s
   pid_t tg_pid;                     /* The ID of the task within the group     
 */
   pid_t tg_ppid;                    /* This is the ID of the parent thread     
 */
   uint8_t tg_flags;                 /* See GROUP_FLAG_* definitions            
 */
+#ifdef CONFIG_SCHED_CAPABILITIES
   uint8_t tg_caps;                  /* See PR_CAP_* definitions                
 */
+#endif
   mode_t  tg_umask;                 /* File mode creation mask (umask())       
 */
 
   /* Resource limits (getrlimit() and setrlimit()) **************************/
diff --git a/sched/group/group_create.c b/sched/group/group_create.c
index bda2f876a22..ddbf0fce9fe 100644
--- a/sched/group/group_create.c
+++ b/sched/group/group_create.c
@@ -196,7 +196,9 @@ int group_allocate(FAR struct tcb_s *tcb, uint8_t ttype)
     {
       group = &g_kthread_group;
       tcb->group = group;
+#ifdef CONFIG_SCHED_CAPABILITIES
       group->tg_caps = PR_CAP_ALL;
+#endif
       if (group->tg_info)
         {
           return OK;
@@ -251,8 +253,10 @@ int group_allocate(FAR struct tcb_s *tcb, uint8_t ttype)
       goto errout_with_group;
     }
 
+#ifdef CONFIG_SCHED_CAPABILITIES
   group->tg_caps = this_task()->group != NULL ?
                    this_task()->group->tg_caps : PR_CAP_ALL;
+#endif
 
   /* Inherit the resource limits from the parent task group */
 
diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c
index c019ec76a14..7dc7d1a918a 100644
--- a/sched/init/nx_start.c
+++ b/sched/init/nx_start.c
@@ -442,7 +442,9 @@ static void idle_group_initialize(void)
 
       group_initialize(tcb);
       tcb->group->tg_flags = GROUP_FLAG_NOCLDWAIT | GROUP_FLAG_PRIVILEGED;
+#ifdef CONFIG_SCHED_CAPABILITIES
       tcb->group->tg_caps  = PR_CAP_ALL;
+#endif
     }
 }
 

Reply via email to