*
                 * Compute add/delete mask to/from effective_cpus
                 *
-                * addmask = effective_xcpus & ~newmask & parent->effective_xcpus
-                * delmask = newmask & ~cs->effective_xcpus
-                *                   & parent->effective_xcpus
+                * For valid partition:
+                *   addmask = exclusive_cpus & ~newmask
+                *                            & parent->effective_xcpus
+                *   delmask = newmask & ~exclusive_cpus
+                *                     & parent->effective_xcpus
+                *
+                * For invalid partition:
+                *   delmask = newmask & parent->effective_xcpus
                 */
-               cpumask_andnot(tmp->addmask, xcpus, newmask);
-               adding = cpumask_and(tmp->addmask, tmp->addmask,
-                                    parent->effective_xcpus);
+               if (is_prs_invalid(old_prs)) {
+                       adding = false;
+                       deleting = cpumask_and(tmp->delmask,
+                                       newmask, parent->effective_xcpus);
+               } else {
+                       cpumask_andnot(tmp->addmask, xcpus, newmask);
+                       adding = cpumask_and(tmp->addmask, tmp->addmask,
+                                            parent->effective_xcpus);
 
-               cpumask_andnot(tmp->delmask, newmask, xcpus);
-               deleting = cpumask_and(tmp->delmask, tmp->delmask,
-                                      parent->effective_xcpus);
+                       cpumask_andnot(tmp->delmask, newmask, xcpus);
+                       deleting = cpumask_and(tmp->delmask, tmp->delmask,
+                                              parent->effective_xcpus);
+               }
                /*
                 * Make partition invalid if parent's effective_cpus could
                 * become empty and there are tasks in the parent.
 
        /*
         * Transitioning between invalid to valid or vice versa may require
-        * changing CS_CPU_EXCLUSIVE.
+        * changing CS_CPU_EXCLUSIVE. In the case of partcmd_update,
+        * validate_change() has already been successfully called and
+        * CPU lists in cs haven't been updated yet. So defer it to later.
         */
-       if (old_prs != new_prs) {
+       if ((old_prs != new_prs) && (cmd != partcmd_update))  {
                int err = update_partition_exclusive(cs, new_prs);
 
                if (err)
 
        spin_unlock_irq(&callback_lock);
 
+       if ((old_prs != new_prs) && (cmd == partcmd_update))
+               update_partition_exclusive(cs, new_prs);
+
        if (adding || deleting) {
                update_tasks_cpumask(parent, tmp->addmask);
                update_sibling_cpumasks(parent, cs, tmp);
        if (alloc_cpumasks(NULL, &tmp))
                return -ENOMEM;
 
-       if (is_partition_valid(cs)) {
-               if (cpumask_empty(trialcs->effective_xcpus)) {
+       if (old_prs) {
+               if (is_partition_valid(cs) &&
+                   cpumask_empty(trialcs->effective_xcpus)) {
                        invalidate = true;
                        cs->prs_err = PERR_INVCPUS;
                } else if (prstate_housekeeping_conflict(old_prs, trialcs->effective_xcpus)) {
                 */
                invalidate = true;
                rcu_read_lock();
-               cpuset_for_each_child(cp, css, parent)
+               cpuset_for_each_child(cp, css, parent) {
+                       struct cpumask *xcpus = fetch_xcpus(trialcs);
+
                        if (is_partition_valid(cp) &&
-                           cpumask_intersects(trialcs->effective_xcpus, cp->effective_xcpus)) {
+                           cpumask_intersects(xcpus, cp->effective_xcpus)) {
                                rcu_read_unlock();
                                update_parent_effective_cpumask(cp, partcmd_invalidate, NULL, &tmp);
                                rcu_read_lock();
                        }
+               }
                rcu_read_unlock();
                retval = 0;
        }
        if (retval < 0)
                goto out_free;
 
-       if (is_partition_valid(cs)) {
+       if (is_partition_valid(cs) ||
+          (is_partition_invalid(cs) && !invalidate)) {
+               struct cpumask *xcpus = trialcs->effective_xcpus;
+
+               if (cpumask_empty(xcpus) && is_partition_invalid(cs))
+                       xcpus = trialcs->cpus_allowed;
+
                /*
                 * Call remote_cpus_update() to handle valid remote partition
                 */
                if (is_remote_partition(cs))
-                       remote_cpus_update(cs, trialcs->effective_xcpus, &tmp);
+                       remote_cpus_update(cs, xcpus, &tmp);
                else if (invalidate)
                        update_parent_effective_cpumask(cs, partcmd_invalidate,
                                                        NULL, &tmp);
                else
                        update_parent_effective_cpumask(cs, partcmd_update,
-                                               trialcs->effective_xcpus, &tmp);
+                                                       xcpus, &tmp);
        } else if (!cpumask_empty(cs->exclusive_cpus)) {
                /*
                 * Use trialcs->effective_cpus as a temp cpumask
        if (retval)
                return retval;
 
-       if (is_partition_valid(cs)) {
+       if (old_prs) {
                if (cpumask_empty(trialcs->effective_xcpus)) {
                        invalidate = true;
                        cs->prs_err = PERR_INVCPUS;
                return 0;
 
        /*
-        * For a previously invalid partition root with valid partition root
-        * parent, treat it as if it is a "member". Otherwise, reject it as
-        * remote partition cannot currently self-recover from an invalid
-        * state.
+        * Treat a previously invalid partition root as if it is a "member".
         */
-       if (new_prs && is_prs_invalid(old_prs)) {
-               if (is_partition_valid(parent)) {
-                       old_prs = PRS_MEMBER;
-               } else {
-                       cs->partition_root_state = -new_prs;
-                       return 0;
-               }
-       }
+       if (new_prs && is_prs_invalid(old_prs))
+               old_prs = PRS_MEMBER;
 
        if (alloc_cpumasks(NULL, &tmpmask))
                return -ENOMEM;
 
 #      +- B1
 #
 #  P<v> = set cpus.partition (0:member, 1:root, 2:isolated)
-#  C<l> = add cpu-list
+#  C<l> = add cpu-list to cpuset.cpus
+#  X<l> = add cpu-list to cpuset.cpus.exclusive
 #  S<p> = use prefix in subtree_control
 #  T    = put a task into cgroup
 #  O<c>=<v> = Write <v> to CPU online file of <c>
        " C0-3:S+ C1-3:S+  C2      .    X2-3   X2-3   T:P2:O2=0 O2=1 0 A1:0-3,A2:1-3,A3:2 A1:P0,A3:P-2"
 
        # cpus.exclusive.effective clearing test
-       " C0-3:S+ C1-3:S+  C2      .   X2-3:X    .      .      .      0 A1:0-3,A2:1-3,A3:2,XA1:"
+       " C0-3:S+ C1-3:S+  C2      .   X2-3:X    .      .      .     0 A1:0-3,A2:1-3,A3:2,XA1:"
 
-       # Invalid to valid remote partition indirect transition test via member
-       " C0-3:S+   C1-3    .      .      .    X3:P2    .      .      0 A1:0-3,A2:1-3,XA2: A2:P-2"
+       # Invalid to valid remote partition transition test
+       " C0-3:S+   C1-3    .      .      .    X3:P2    .      .     0 A1:0-3,A2:1-3,XA2: A2:P-2"
        " C0-3:S+ C1-3:X3:P2
-                           .      .    X2-3   P0:P2    .      .      0 A1:0-2,A2:3,XA2:3 A2:P2 3"
+                           .      .    X2-3    P2      .      .     0 A1:0-2,A2:3,XA2:3 A2:P2 3"
 
        # Invalid to valid local partition direct transition tests
-       " C1-3:S+:P2 C2-3:X1:P2 .  .      .      .      .      .      0 A1:1-3,XA1:1-3,A2:2-3:XA2: A1:P2,A2:P-2 1-3"
-       " C1-3:S+:P2 C2-3:X1:P2 .  .      .    X3:P2    .      .      0 A1:1-2,XA1:1-3,A2:3:XA2:3 A1:P2,A2:P2 1-3"
+       " C1-3:S+:P2 C2-3:X1:P2 .  .      .      .      .      .     0 A1:1-3,XA1:1-3,A2:2-3:XA2: A1:P2,A2:P-2 1-3"
+       " C1-3:S+:P2 C2-3:X1:P2 .  .      .    X3:P2    .      .     0 A1:1-2,XA1:1-3,A2:3:XA2:3 A1:P2,A2:P2 1-3"
+       "  C0-3:P2   .      .    C4-6   C0-4     .      .      .     0 A1:0-4,B1:4-6 A1:P-2,B1:P0"
+       "  C0-3:P2   .      .    C4-6 C0-4:C0-3  .      .      .     0 A1:0-3,B1:4-6 A1:P2,B1:P0 0-3"
+       "  C0-3:P2   .      .  C3-5:C4-5  .      .      .      .     0 A1:0-3,B1:4-5 A1:P2,B1:P0 0-3"
 
        # Local partition invalidation tests
        " C0-3:X1-3:S+:P2 C1-3:X2-3:S+:P2 C2-3:X3:P2 \
                                   .      .     X4      .      .     0 A1:1-3,A2:1-3,A3:2-3,XA2:,XA3: A1:P2,A2:P-2,A3:P-2 1-3"
        " C0-3:X1-3:S+:P2 C1-3:X2-3:S+:P2 C2-3:X3:P2 \
                                   .      .     C4      .      .     0 A1:1-3,A2:1-3,A3:2-3,XA2:,XA3: A1:P2,A2:P-2,A3:P-2 1-3"
+       # Local partition CPU change tests
+       " C0-5:S+:P2 C4-5:S+:P1 .  .      .    C3-5     .      .     0 A1:0-2,A2:3-5 A1:P2,A2:P1 0-2"
+       " C0-5:S+:P2 C4-5:S+:P1 .  .    C1-5     .      .      .     0 A1:1-3,A2:4-5 A1:P2,A2:P1 1-3"
 
        # cpus_allowed/exclusive_cpus update tests
        " C0-3:X2-3:S+ C1-3:X2-3:S+ C2-3:X2-3 \