]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm: use nodes_and() return value to simplify client code
authorYury Norov <ynorov@nvidia.com>
Wed, 14 Jan 2026 17:22:14 +0000 (12:22 -0500)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 27 Jan 2026 04:02:36 +0000 (20:02 -0800)
establish_demotion_targets() and kernel_migrate_pages() call node_empty()
immediately after calling nodes_and().  Now that nodes_and() return false
if nodemask is empty, drop the latter.

Link: https://lkml.kernel.org/r/20260114172217.861204-3-ynorov@nvidia.com
Signed-off-by: Yury Norov <ynorov@nvidia.com>
Reviewed-by: Gregory Price <gourry@gourry.net>
Reviewed-by: Joshua Hahn <joshua.hahnjy@gmail.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: David Hildenbrand (Red Hat) <david@kernel.org>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Byungchul Park <byungchul@sk.com>
Cc: "Huang, Ying" <ying.huang@linux.alibaba.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Mathew Brost <matthew.brost@intel.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Rakie Kim <rakie.kim@sk.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Waiman Long <longman@redhat.com>
Cc: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memory-tiers.c
mm/mempolicy.c

index 20aab9c19c5e578ca689e8a48a475999386e77cc..7ec4427765741f516be9d284575e97ee4dd8eeb8 100644 (file)
@@ -475,8 +475,7 @@ static void establish_demotion_targets(void)
         */
        list_for_each_entry_reverse(memtier, &memory_tiers, list) {
                tier_nodes = get_memtier_nodemask(memtier);
-               nodes_and(tier_nodes, node_states[N_CPU], tier_nodes);
-               if (!nodes_empty(tier_nodes)) {
+               if (nodes_and(tier_nodes, node_states[N_CPU], tier_nodes)) {
                        /*
                         * abstract distance below the max value of this memtier
                         * is considered toptier.
index 76da504257123bcd2895222ff39a59bba9868957..dbd48502ac240c919b89213a875e79398914deaf 100644 (file)
@@ -1909,8 +1909,7 @@ static int kernel_migrate_pages(pid_t pid, unsigned long maxnode,
        }
 
        task_nodes = cpuset_mems_allowed(current);
-       nodes_and(*new, *new, task_nodes);
-       if (nodes_empty(*new))
+       if (!nodes_and(*new, *new, task_nodes))
                goto out_put;
 
        err = security_task_movememory(task);