If you set a bit in a nodemask_t everytime ____cache_alloc_node() fails in the previous for_each_zone_zonelist() iteration, you could just iterate that nodemask here without duplicating the zone_to_nid() and cache->nodelists[nid] != NULL check. nid = numa_node_id(); if (!cache->nodelists[nid]) for_each_node_mask(nid, allowed_nodes) { obj = kmem_getpages(cache, local_flags, nid); if (obj) break; } else obj = kmem_getpages(cache, local_flags, nid);This way you can try all allowed nodes for memory instead of just one when cache->nodelists[numa_node_id()] == NULL.