Re: [PATCH] sched/proc: Print user_cpus_ptr for task status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 5/7/24 02:57, Xuewen Yan wrote:
These changes essentially reverts commit 851a723e45d1c("sched: Always
clear user_cpus_ptr in do_set_cpus_allowed()") except the additional
caller in the cpuset code.

How about the following less invasive change?

   diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 7019a40457a6..646837eab70c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2796,21 +2796,24 @@ __do_set_cpus_allowed(struct task_struct *p,
struct affinity_context *ctx)
   }

   /*
- * Used for kthread_bind() and select_fallback_rq(), in both cases the user
- * affinity (if any) should be destroyed too.
+ * Used for kthread_bind() and select_fallback_rq(). Destroy user affinity
+ * if no intersection with the new mask.
    */
   void do_set_cpus_allowed(struct task_struct *p, const struct cpumask
*new_mask)
   {
          struct affinity_context ac = {
                  .new_mask  = new_mask,
                  .user_mask = NULL,
-               .flags     = SCA_USER,  /* clear the user requested mask */
+               .flags     = 0,
          };
          union cpumask_rcuhead {
                  cpumask_t cpumask;
                  struct rcu_head rcu;
          };

+       if (current->user_cpus_ptr &&
!cpumask_intersects(current->user_cpus_ptr, new_mask))
Thanks for your suggestion, and I try it and as for me, it works well,
but I change the "current" to p.
I think “current” is inappropriate because what is changed here is the
mask of p.
It is possible that “p” and “current” are not equal.

I would send the next patch later and add your Suggested-by. Thanks
again for your advice!

You are right. It should be "p" instead of "current".

Thanks,
Longman





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux