linux/mm/mempolicy.c
<<
>>
Prefs
   1/*
   2 * Simple NUMA memory policy for the Linux kernel.
   3 *
   4 * Copyright 2003,2004 Andi Kleen, SuSE Labs.
   5 * (C) Copyright 2005 Christoph Lameter, Silicon Graphics, Inc.
   6 * Subject to the GNU Public License, version 2.
   7 *
   8 * NUMA policy allows the user to give hints in which node(s) memory should
   9 * be allocated.
  10 *
  11 * Support four policies per VMA and per process:
  12 *
  13 * The VMA policy has priority over the process policy for a page fault.
  14 *
  15 * interleave     Allocate memory interleaved over a set of nodes,
  16 *                with normal fallback if it fails.
  17 *                For VMA based allocations this interleaves based on the
  18 *                offset into the backing object or offset into the mapping
  19 *                for anonymous memory. For process policy an process counter
  20 *                is used.
  21 *
  22 * bind           Only allocate memory on a specific set of nodes,
  23 *                no fallback.
  24 *                FIXME: memory is allocated starting with the first node
  25 *                to the last. It would be better if bind would truly restrict
  26 *                the allocation to memory nodes instead
  27 *
  28 * preferred       Try a specific node first before normal fallback.
  29 *                As a special case node -1 here means do the allocation
  30 *                on the local CPU. This is normally identical to default,
  31 *                but useful to set in a VMA when you have a non default
  32 *                process policy.
  33 *
  34 * default        Allocate on the local node first, or when on a VMA
  35 *                use the process policy. This is what Linux always did
  36 *                in a NUMA aware kernel and still does by, ahem, default.
  37 *
  38 * The process policy is applied for most non interrupt memory allocations
  39 * in that process' context. Interrupts ignore the policies and always
  40 * try to allocate on the local CPU. The VMA policy is only applied for memory
  41 * allocations for a VMA in the VM.
  42 *
  43 * Currently there are a few corner cases in swapping where the policy
  44 * is not applied, but the majority should be handled. When process policy
  45 * is used it is not remembered over swap outs/swap ins.
  46 *
  47 * Only the highest zone in the zone hierarchy gets policied. Allocations
  48 * requesting a lower zone just use default policy. This implies that
  49 * on systems with highmem kernel lowmem allocation don't get policied.
  50 * Same with GFP_DMA allocations.
  51 *
  52 * For shmfs/tmpfs/hugetlbfs shared memory the policy is shared between
  53 * all users and remembered even when nobody has memory mapped.
  54 */
  55
  56/* Notebook:
  57   fix mmap readahead to honour policy and enable policy for any page cache
  58   object
  59   statistics for bigpages
  60   global policy for page cache? currently it uses process policy. Requires
  61   first item above.
  62   handle mremap for shared memory (currently ignored for the policy)
  63   grows down?
  64   make bind policy root only? It can trigger oom much faster and the
  65   kernel is not always grateful with that.
  66*/
  67
  68#include <linux/mempolicy.h>
  69#include <linux/mm.h>
  70#include <linux/highmem.h>
  71#include <linux/hugetlb.h>
  72#include <linux/kernel.h>
  73#include <linux/sched.h>
  74#include <linux/nodemask.h>
  75#include <linux/cpuset.h>
  76#include <linux/slab.h>
  77#include <linux/string.h>
  78#include <linux/export.h>
  79#include <linux/nsproxy.h>
  80#include <linux/interrupt.h>
  81#include <linux/init.h>
  82#include <linux/compat.h>
  83#include <linux/swap.h>
  84#include <linux/seq_file.h>
  85#include <linux/proc_fs.h>
  86#include <linux/migrate.h>
  87#include <linux/ksm.h>
  88#include <linux/rmap.h>
  89#include <linux/security.h>
  90#include <linux/syscalls.h>
  91#include <linux/ctype.h>
  92#include <linux/mm_inline.h>
  93
  94#include <asm/tlbflush.h>
  95#include <asm/uaccess.h>
  96#include <linux/random.h>
  97
  98#include "internal.h"
  99
 100/* Internal flags */
 101#define MPOL_MF_DISCONTIG_OK (MPOL_MF_INTERNAL << 0)    /* Skip checks for continuous vmas */
 102#define MPOL_MF_INVERT (MPOL_MF_INTERNAL << 1)          /* Invert check for nodemask */
 103
 104static struct kmem_cache *policy_cache;
 105static struct kmem_cache *sn_cache;
 106
 107/* Highest zone. An specific allocation for a zone below that is not
 108   policied. */
 109enum zone_type policy_zone = 0;
 110
 111/*
 112 * run-time system-wide default policy => local allocation
 113 */
 114static struct mempolicy default_policy = {
 115        .refcnt = ATOMIC_INIT(1), /* never free it */
 116        .mode = MPOL_PREFERRED,
 117        .flags = MPOL_F_LOCAL,
 118};
 119
 120static const struct mempolicy_operations {
 121        int (*create)(struct mempolicy *pol, const nodemask_t *nodes);
 122        /*
 123         * If read-side task has no lock to protect task->mempolicy, write-side
 124         * task will rebind the task->mempolicy by two step. The first step is
 125         * setting all the newly nodes, and the second step is cleaning all the
 126         * disallowed nodes. In this way, we can avoid finding no node to alloc
 127         * page.
 128         * If we have a lock to protect task->mempolicy in read-side, we do
 129         * rebind directly.
 130         *
 131         * step:
 132         *      MPOL_REBIND_ONCE - do rebind work at once
 133         *      MPOL_REBIND_STEP1 - set all the newly nodes
 134         *      MPOL_REBIND_STEP2 - clean all the disallowed nodes
 135         */
 136        void (*rebind)(struct mempolicy *pol, const nodemask_t *nodes,
 137                        enum mpol_rebind_step step);
 138} mpol_ops[MPOL_MAX];
 139
 140/* Check that the nodemask contains at least one populated zone */
 141static int is_valid_nodemask(const nodemask_t *nodemask)
 142{
 143        int nd, k;
 144
 145        for_each_node_mask(nd, *nodemask) {
 146                struct zone *z;
 147
 148                for (k = 0; k <= policy_zone; k++) {
 149                        z = &NODE_DATA(nd)->node_zones[k];
 150                        if (z->present_pages > 0)
 151                                return 1;
 152                }
 153        }
 154
 155        return 0;
 156}
 157
 158static inline int mpol_store_user_nodemask(const struct mempolicy *pol)
 159{
 160        return pol->flags & MPOL_MODE_FLAGS;
 161}
 162
 163static void mpol_relative_nodemask(nodemask_t *ret, const nodemask_t *orig,
 164                                   const nodemask_t *rel)
 165{
 166        nodemask_t tmp;
 167        nodes_fold(tmp, *orig, nodes_weight(*rel));
 168        nodes_onto(*ret, tmp, *rel);
 169}
 170
 171static int mpol_new_interleave(struct mempolicy *pol, const nodemask_t *nodes)
 172{
 173        if (nodes_empty(*nodes))
 174                return -EINVAL;
 175        pol->v.nodes = *nodes;
 176        return 0;
 177}
 178
 179static int mpol_new_preferred(struct mempolicy *pol, const nodemask_t *nodes)
 180{
 181        if (!nodes)
 182                pol->flags |= MPOL_F_LOCAL;     /* local allocation */
 183        else if (nodes_empty(*nodes))
 184                return -EINVAL;                 /*  no allowed nodes */
 185        else
 186                pol->v.preferred_node = first_node(*nodes);
 187        return 0;
 188}
 189
 190static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)
 191{
 192        if (!is_valid_nodemask(nodes))
 193                return -EINVAL;
 194        pol->v.nodes = *nodes;
 195        return 0;
 196}
 197
 198/*
 199 * mpol_set_nodemask is called after mpol_new() to set up the nodemask, if
 200 * any, for the new policy.  mpol_new() has already validated the nodes
 201 * parameter with respect to the policy mode and flags.  But, we need to
 202 * handle an empty nodemask with MPOL_PREFERRED here.
 203 *
 204 * Must be called holding task's alloc_lock to protect task's mems_allowed
 205 * and mempolicy.  May also be called holding the mmap_semaphore for write.
 206 */
 207static int mpol_set_nodemask(struct mempolicy *pol,
 208                     const nodemask_t *nodes, struct nodemask_scratch *nsc)
 209{
 210        int ret;
 211
 212        /* if mode is MPOL_DEFAULT, pol is NULL. This is right. */
 213        if (pol == NULL)
 214                return 0;
 215        /* Check N_HIGH_MEMORY */
 216        nodes_and(nsc->mask1,
 217                  cpuset_current_mems_allowed, node_states[N_HIGH_MEMORY]);
 218
 219        VM_BUG_ON(!nodes);
 220        if (pol->mode == MPOL_PREFERRED && nodes_empty(*nodes))
 221                nodes = NULL;   /* explicit local allocation */
 222        else {
 223                if (pol->flags & MPOL_F_RELATIVE_NODES)
 224                        mpol_relative_nodemask(&nsc->mask2, nodes,&nsc->mask1);
 225                else
 226                        nodes_and(nsc->mask2, *nodes, nsc->mask1);
 227
 228                if (mpol_store_user_nodemask(pol))
 229                        pol->w.user_nodemask = *nodes;
 230                else
 231                        pol->w.cpuset_mems_allowed =
 232                                                cpuset_current_mems_allowed;
 233        }
 234
 235        if (nodes)
 236                ret = mpol_ops[pol->mode].create(pol, &nsc->mask2);
 237        else
 238                ret = mpol_ops[pol->mode].create(pol, NULL);
 239        return ret;
 240}
 241
 242/*
 243 * This function just creates a new policy, does some check and simple
 244 * initialization. You must invoke mpol_set_nodemask() to set nodes.
 245 */
 246static struct mempolicy *mpol_new(unsigned short mode, unsigned short flags,
 247                                  nodemask_t *nodes)
 248{
 249        struct mempolicy *policy;
 250
 251        pr_debug("setting mode %d flags %d nodes[0] %lx\n",
 252                 mode, flags, nodes ? nodes_addr(*nodes)[0] : -1);
 253
 254        if (mode == MPOL_DEFAULT) {
 255                if (nodes && !nodes_empty(*nodes))
 256                        return ERR_PTR(-EINVAL);
 257                return NULL;    /* simply delete any existing policy */
 258        }
 259        VM_BUG_ON(!nodes);
 260
 261        /*
 262         * MPOL_PREFERRED cannot be used with MPOL_F_STATIC_NODES or
 263         * MPOL_F_RELATIVE_NODES if the nodemask is empty (local allocation).
 264         * All other modes require a valid pointer to a non-empty nodemask.
 265         */
 266        if (mode == MPOL_PREFERRED) {
 267                if (nodes_empty(*nodes)) {
 268                        if (((flags & MPOL_F_STATIC_NODES) ||
 269                             (flags & MPOL_F_RELATIVE_NODES)))
 270                                return ERR_PTR(-EINVAL);
 271                }
 272        } else if (nodes_empty(*nodes))
 273                return ERR_PTR(-EINVAL);
 274        policy = kmem_cache_alloc(policy_cache, GFP_KERNEL);
 275        if (!policy)
 276                return ERR_PTR(-ENOMEM);
 277        atomic_set(&policy->refcnt, 1);
 278        policy->mode = mode;
 279        policy->flags = flags;
 280
 281        return policy;
 282}
 283
 284/* Slow path of a mpol destructor. */
 285void __mpol_put(struct mempolicy *p)
 286{
 287        if (!atomic_dec_and_test(&p->refcnt))
 288                return;
 289        kmem_cache_free(policy_cache, p);
 290}
 291
 292static void mpol_rebind_default(struct mempolicy *pol, const nodemask_t *nodes,
 293                                enum mpol_rebind_step step)
 294{
 295}
 296
 297/*
 298 * step:
 299 *      MPOL_REBIND_ONCE  - do rebind work at once
 300 *      MPOL_REBIND_STEP1 - set all the newly nodes
 301 *      MPOL_REBIND_STEP2 - clean all the disallowed nodes
 302 */
 303static void mpol_rebind_nodemask(struct mempolicy *pol, const nodemask_t *nodes,
 304                                 enum mpol_rebind_step step)
 305{
 306        nodemask_t tmp;
 307
 308        if (pol->flags & MPOL_F_STATIC_NODES)
 309                nodes_and(tmp, pol->w.user_nodemask, *nodes);
 310        else if (pol->flags & MPOL_F_RELATIVE_NODES)
 311                mpol_relative_nodemask(&tmp, &pol->w.user_nodemask, nodes);
 312        else {
 313                /*
 314                 * if step == 1, we use ->w.cpuset_mems_allowed to cache the
 315                 * result
 316                 */
 317                if (step == MPOL_REBIND_ONCE || step == MPOL_REBIND_STEP1) {
 318                        nodes_remap(tmp, pol->v.nodes,
 319                                        pol->w.cpuset_mems_allowed, *nodes);
 320                        pol->w.cpuset_mems_allowed = step ? tmp : *nodes;
 321                } else if (step == MPOL_REBIND_STEP2) {
 322                        tmp = pol->w.cpuset_mems_allowed;
 323                        pol->w.cpuset_mems_allowed = *nodes;
 324                } else
 325                        BUG();
 326        }
 327
 328        if (nodes_empty(tmp))
 329                tmp = *nodes;
 330
 331        if (step == MPOL_REBIND_STEP1)
 332                nodes_or(pol->v.nodes, pol->v.nodes, tmp);
 333        else if (step == MPOL_REBIND_ONCE || step == MPOL_REBIND_STEP2)
 334                pol->v.nodes = tmp;
 335        else
 336                BUG();
 337
 338        if (!node_isset(current->il_next, tmp)) {
 339                current->il_next = next_node(current->il_next, tmp);
 340                if (current->il_next >= MAX_NUMNODES)
 341                        current->il_next = first_node(tmp);
 342                if (current->il_next >= MAX_NUMNODES)
 343                        current->il_next = numa_node_id();
 344        }
 345}
 346
 347static void mpol_rebind_preferred(struct mempolicy *pol,
 348                                  const nodemask_t *nodes,
 349                                  enum mpol_rebind_step step)
 350{
 351        nodemask_t tmp;
 352
 353        if (pol->flags & MPOL_F_STATIC_NODES) {
 354                int node = first_node(pol->w.user_nodemask);
 355
 356                if (node_isset(node, *nodes)) {
 357                        pol->v.preferred_node = node;
 358                        pol->flags &= ~MPOL_F_LOCAL;
 359                } else
 360                        pol->flags |= MPOL_F_LOCAL;
 361        } else if (pol->flags & MPOL_F_RELATIVE_NODES) {
 362                mpol_relative_nodemask(&tmp, &pol->w.user_nodemask, nodes);
 363                pol->v.preferred_node = first_node(tmp);
 364        } else if (!(pol->flags & MPOL_F_LOCAL)) {
 365                pol->v.preferred_node = node_remap(pol->v.preferred_node,
 366                                                   pol->w.cpuset_mems_allowed,
 367                                                   *nodes);
 368                pol->w.cpuset_mems_allowed = *nodes;
 369        }
 370}
 371
 372/*
 373 * mpol_rebind_policy - Migrate a policy to a different set of nodes
 374 *
 375 * If read-side task has no lock to protect task->mempolicy, write-side
 376 * task will rebind the task->mempolicy by two step. The first step is
 377 * setting all the newly nodes, and the second step is cleaning all the
 378 * disallowed nodes. In this way, we can avoid finding no node to alloc
 379 * page.
 380 * If we have a lock to protect task->mempolicy in read-side, we do
 381 * rebind directly.
 382 *
 383 * step:
 384 *      MPOL_REBIND_ONCE  - do rebind work at once
 385 *      MPOL_REBIND_STEP1 - set all the newly nodes
 386 *      MPOL_REBIND_STEP2 - clean all the disallowed nodes
 387 */
 388static void mpol_rebind_policy(struct mempolicy *pol, const nodemask_t *newmask,
 389                                enum mpol_rebind_step step)
 390{
 391        if (!pol)
 392                return;
 393        if (!mpol_store_user_nodemask(pol) && step == MPOL_REBIND_ONCE &&
 394            nodes_equal(pol->w.cpuset_mems_allowed, *newmask))
 395                return;
 396
 397        if (step == MPOL_REBIND_STEP1 && (pol->flags & MPOL_F_REBINDING))
 398                return;
 399
 400        if (step == MPOL_REBIND_STEP2 && !(pol->flags & MPOL_F_REBINDING))
 401                BUG();
 402
 403        if (step == MPOL_REBIND_STEP1)
 404                pol->flags |= MPOL_F_REBINDING;
 405        else if (step == MPOL_REBIND_STEP2)
 406                pol->flags &= ~MPOL_F_REBINDING;
 407        else if (step >= MPOL_REBIND_NSTEP)
 408                BUG();
 409
 410        mpol_ops[pol->mode].rebind(pol, newmask, step);
 411}
 412
 413/*
 414 * Wrapper for mpol_rebind_policy() that just requires task
 415 * pointer, and updates task mempolicy.
 416 *
 417 * Called with task's alloc_lock held.
 418 */
 419
 420void mpol_rebind_task(struct task_struct *tsk, const nodemask_t *new,
 421                        enum mpol_rebind_step step)
 422{
 423        mpol_rebind_policy(tsk->mempolicy, new, step);
 424}
 425
 426/*
 427 * Rebind each vma in mm to new nodemask.
 428 *
 429 * Call holding a reference to mm.  Takes mm->mmap_sem during call.
 430 */
 431
 432void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new)
 433{
 434        struct vm_area_struct *vma;
 435
 436        down_write(&mm->mmap_sem);
 437        for (vma = mm->mmap; vma; vma = vma->vm_next)
 438                mpol_rebind_policy(vma->vm_policy, new, MPOL_REBIND_ONCE);
 439        up_write(&mm->mmap_sem);
 440}
 441
 442static const struct mempolicy_operations mpol_ops[MPOL_MAX] = {
 443        [MPOL_DEFAULT] = {
 444                .rebind = mpol_rebind_default,
 445        },
 446        [MPOL_INTERLEAVE] = {
 447                .create = mpol_new_interleave,
 448                .rebind = mpol_rebind_nodemask,
 449        },
 450        [MPOL_PREFERRED] = {
 451                .create = mpol_new_preferred,
 452                .rebind = mpol_rebind_preferred,
 453        },
 454        [MPOL_BIND] = {
 455                .create = mpol_new_bind,
 456                .rebind = mpol_rebind_nodemask,
 457        },
 458};
 459
 460static void migrate_page_add(struct page *page, struct list_head *pagelist,
 461                                unsigned long flags);
 462
 463/* Scan through pages checking if pages follow certain conditions. */
 464static int check_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
 465                unsigned long addr, unsigned long end,
 466                const nodemask_t *nodes, unsigned long flags,
 467                void *private)
 468{
 469        pte_t *orig_pte;
 470        pte_t *pte;
 471        spinlock_t *ptl;
 472
 473        orig_pte = pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
 474        do {
 475                struct page *page;
 476                int nid;
 477
 478                if (!pte_present(*pte))
 479                        continue;
 480                page = vm_normal_page(vma, addr, *pte);
 481                if (!page)
 482                        continue;
 483                /*
 484                 * vm_normal_page() filters out zero pages, but there might
 485                 * still be PageReserved pages to skip, perhaps in a VDSO.
 486                 * And we cannot move PageKsm pages sensibly or safely yet.
 487                 */
 488                if (PageReserved(page) || PageKsm(page))
 489                        continue;
 490                nid = page_to_nid(page);
 491                if (node_isset(nid, *nodes) == !!(flags & MPOL_MF_INVERT))
 492                        continue;
 493
 494                if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL))
 495                        migrate_page_add(page, private, flags);
 496                else
 497                        break;
 498        } while (pte++, addr += PAGE_SIZE, addr != end);
 499        pte_unmap_unlock(orig_pte, ptl);
 500        return addr != end;
 501}
 502
 503static inline int check_pmd_range(struct vm_area_struct *vma, pud_t *pud,
 504                unsigned long addr, unsigned long end,
 505                const nodemask_t *nodes, unsigned long flags,
 506                void *private)
 507{
 508        pmd_t *pmd;
 509        unsigned long next;
 510
 511        pmd = pmd_offset(pud, addr);
 512        do {
 513                next = pmd_addr_end(addr, end);
 514                split_huge_page_pmd(vma->vm_mm, pmd);
 515                if (pmd_none_or_trans_huge_or_clear_bad(pmd))
 516                        continue;
 517                if (check_pte_range(vma, pmd, addr, next, nodes,
 518                                    flags, private))
 519                        return -EIO;
 520        } while (pmd++, addr = next, addr != end);
 521        return 0;
 522}
 523
 524static inline int check_pud_range(struct vm_area_struct *vma, pgd_t *pgd,
 525                unsigned long addr, unsigned long end,
 526                const nodemask_t *nodes, unsigned long flags,
 527                void *private)
 528{
 529        pud_t *pud;
 530        unsigned long next;
 531
 532        pud = pud_offset(pgd, addr);
 533        do {
 534                next = pud_addr_end(addr, end);
 535                if (pud_none_or_clear_bad(pud))
 536                        continue;
 537                if (check_pmd_range(vma, pud, addr, next, nodes,
 538                                    flags, private))
 539                        return -EIO;
 540        } while (pud++, addr = next, addr != end);
 541        return 0;
 542}
 543
 544static inline int check_pgd_range(struct vm_area_struct *vma,
 545                unsigned long addr, unsigned long end,
 546                const nodemask_t *nodes, unsigned long flags,
 547                void *private)
 548{
 549        pgd_t *pgd;
 550        unsigned long next;
 551
 552        pgd = pgd_offset(vma->vm_mm, addr);
 553        do {
 554                next = pgd_addr_end(addr, end);
 555                if (pgd_none_or_clear_bad(pgd))
 556                        continue;
 557                if (check_pud_range(vma, pgd, addr, next, nodes,
 558                                    flags, private))
 559                        return -EIO;
 560        } while (pgd++, addr = next, addr != end);
 561        return 0;
 562}
 563
 564/*
 565 * Check if all pages in a range are on a set of nodes.
 566 * If pagelist != NULL then isolate pages from the LRU and
 567 * put them on the pagelist.
 568 */
 569static struct vm_area_struct *
 570check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
 571                const nodemask_t *nodes, unsigned long flags, void *private)
 572{
 573        int err;
 574        struct vm_area_struct *first, *vma, *prev;
 575
 576
 577        first = find_vma(mm, start);
 578        if (!first)
 579                return ERR_PTR(-EFAULT);
 580        prev = NULL;
 581        for (vma = first; vma && vma->vm_start < end; vma = vma->vm_next) {
 582                if (!(flags & MPOL_MF_DISCONTIG_OK)) {
 583                        if (!vma->vm_next && vma->vm_end < end)
 584                                return ERR_PTR(-EFAULT);
 585                        if (prev && prev->vm_end < vma->vm_start)
 586                                return ERR_PTR(-EFAULT);
 587                }
 588                if (!is_vm_hugetlb_page(vma) &&
 589                    ((flags & MPOL_MF_STRICT) ||
 590                     ((flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) &&
 591                                vma_migratable(vma)))) {
 592                        unsigned long endvma = vma->vm_end;
 593
 594                        if (endvma > end)
 595                                endvma = end;
 596                        if (vma->vm_start > start)
 597                                start = vma->vm_start;
 598                        err = check_pgd_range(vma, start, endvma, nodes,
 599                                                flags, private);
 600                        if (err) {
 601                                first = ERR_PTR(err);
 602                                break;
 603                        }
 604                }
 605                prev = vma;
 606        }
 607        return first;
 608}
 609
 610/* Step 2: apply policy to a range and do splits. */
 611static int mbind_range(struct mm_struct *mm, unsigned long start,
 612                       unsigned long end, struct mempolicy *new_pol)
 613{
 614        struct vm_area_struct *next;
 615        struct vm_area_struct *prev;
 616        struct vm_area_struct *vma;
 617        int err = 0;
 618        pgoff_t pgoff;
 619        unsigned long vmstart;
 620        unsigned long vmend;
 621
 622        vma = find_vma(mm, start);
 623        if (!vma || vma->vm_start > start)
 624                return -EFAULT;
 625
 626        prev = vma->vm_prev;
 627        if (start > vma->vm_start)
 628                prev = vma;
 629
 630        for (; vma && vma->vm_start < end; prev = vma, vma = next) {
 631                next = vma->vm_next;
 632                vmstart = max(start, vma->vm_start);
 633                vmend   = min(end, vma->vm_end);
 634
 635                if (mpol_equal(vma_policy(vma), new_pol))
 636                        continue;
 637
 638                pgoff = vma->vm_pgoff +
 639                        ((vmstart - vma->vm_start) >> PAGE_SHIFT);
 640                prev = vma_merge(mm, prev, vmstart, vmend, vma->vm_flags,
 641                                  vma->anon_vma, vma->vm_file, pgoff,
 642                                  new_pol);
 643                if (prev) {
 644                        vma = prev;
 645                        next = vma->vm_next;
 646                        continue;
 647                }
 648                if (vma->vm_start != vmstart) {
 649                        err = split_vma(vma->vm_mm, vma, vmstart, 1);
 650                        if (err)
 651                                goto out;
 652                }
 653                if (vma->vm_end != vmend) {
 654                        err = split_vma(vma->vm_mm, vma, vmend, 0);
 655                        if (err)
 656                                goto out;
 657                }
 658
 659                /*
 660                 * Apply policy to a single VMA. The reference counting of
 661                 * policy for vma_policy linkages has already been handled by
 662                 * vma_merge and split_vma as necessary. If this is a shared
 663                 * policy then ->set_policy will increment the reference count
 664                 * for an sp node.
 665                 */
 666                pr_debug("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n",
 667                        vma->vm_start, vma->vm_end, vma->vm_pgoff,
 668                        vma->vm_ops, vma->vm_file,
 669                        vma->vm_ops ? vma->vm_ops->set_policy : NULL);
 670                if (vma->vm_ops && vma->vm_ops->set_policy) {
 671                        err = vma->vm_ops->set_policy(vma, new_pol);
 672                        if (err)
 673                                goto out;
 674                }
 675        }
 676
 677 out:
 678        return err;
 679}
 680
 681/*
 682 * Update task->flags PF_MEMPOLICY bit: set iff non-default
 683 * mempolicy.  Allows more rapid checking of this (combined perhaps
 684 * with other PF_* flag bits) on memory allocation hot code paths.
 685 *
 686 * If called from outside this file, the task 'p' should -only- be
 687 * a newly forked child not yet visible on the task list, because
 688 * manipulating the task flags of a visible task is not safe.
 689 *
 690 * The above limitation is why this routine has the funny name
 691 * mpol_fix_fork_child_flag().
 692 *
 693 * It is also safe to call this with a task pointer of current,
 694 * which the static wrapper mpol_set_task_struct_flag() does,
 695 * for use within this file.
 696 */
 697
 698void mpol_fix_fork_child_flag(struct task_struct *p)
 699{
 700        if (p->mempolicy)
 701                p->flags |= PF_MEMPOLICY;
 702        else
 703                p->flags &= ~PF_MEMPOLICY;
 704}
 705
 706static void mpol_set_task_struct_flag(void)
 707{
 708        mpol_fix_fork_child_flag(current);
 709}
 710
 711/* Set the process memory policy */
 712static long do_set_mempolicy(unsigned short mode, unsigned short flags,
 713                             nodemask_t *nodes)
 714{
 715        struct mempolicy *new, *old;
 716        struct mm_struct *mm = current->mm;
 717        NODEMASK_SCRATCH(scratch);
 718        int ret;
 719
 720        if (!scratch)
 721                return -ENOMEM;
 722
 723        new = mpol_new(mode, flags, nodes);
 724        if (IS_ERR(new)) {
 725                ret = PTR_ERR(new);
 726                goto out;
 727        }
 728        /*
 729         * prevent changing our mempolicy while show_numa_maps()
 730         * is using it.
 731         * Note:  do_set_mempolicy() can be called at init time
 732         * with no 'mm'.
 733         */
 734        if (mm)
 735                down_write(&mm->mmap_sem);
 736        task_lock(current);
 737        ret = mpol_set_nodemask(new, nodes, scratch);
 738        if (ret) {
 739                task_unlock(current);
 740                if (mm)
 741                        up_write(&mm->mmap_sem);
 742                mpol_put(new);
 743                goto out;
 744        }
 745        old = current->mempolicy;
 746        current->mempolicy = new;
 747        mpol_set_task_struct_flag();
 748        if (new && new->mode == MPOL_INTERLEAVE &&
 749            nodes_weight(new->v.nodes))
 750                current->il_next = first_node(new->v.nodes);
 751        task_unlock(current);
 752        if (mm)
 753                up_write(&mm->mmap_sem);
 754
 755        mpol_put(old);
 756        ret = 0;
 757out:
 758        NODEMASK_SCRATCH_FREE(scratch);
 759        return ret;
 760}
 761
 762/*
 763 * Return nodemask for policy for get_mempolicy() query
 764 *
 765 * Called with task's alloc_lock held
 766 */
 767static void get_policy_nodemask(struct mempolicy *p, nodemask_t *nodes)
 768{
 769        nodes_clear(*nodes);
 770        if (p == &default_policy)
 771                return;
 772
 773        switch (p->mode) {
 774        case MPOL_BIND:
 775                /* Fall through */
 776        case MPOL_INTERLEAVE:
 777                *nodes = p->v.nodes;
 778                break;
 779        case MPOL_PREFERRED:
 780                if (!(p->flags & MPOL_F_LOCAL))
 781                        node_set(p->v.preferred_node, *nodes);
 782                /* else return empty node mask for local allocation */
 783                break;
 784        default:
 785                BUG();
 786        }
 787}
 788
 789static int lookup_node(struct mm_struct *mm, unsigned long addr)
 790{
 791        struct page *p;
 792        int err;
 793
 794        err = get_user_pages(current, mm, addr & PAGE_MASK, 1, 0, 0, &p, NULL);
 795        if (err >= 0) {
 796                err = page_to_nid(p);
 797                put_pagd(p);
vmsta0"> 710
7978       >}
7959        return err;
8060}
8061
8062/* Rerieve NUMAy policy */
8703static long dogset_mempolicy int *, nodemask_t *,
8054                             unsigned long addr, unsigned long flags)
87058096        int err;
8097        struct mm_struct *mm = current->mm;
8708        struct  *vma = NULL;
8097        struct mempolicy * = current->mempolicy;
8710
8191        if (flags &>
8182               ~( unsigned lon) (MPOL_F>NOD2MPOL_FADDR2MPOL_FMEMS_ALLOWREL))
8713                return -;
8154
8195        if (flags & MPOL_FMEMS_ALLOWREL) {
8196                if (flags & (MPOL_F>NOD2MPOL_FADDR2))
8167                        return -;
8178                * = 0    >/*just so itk's iniializned */
8139                task_lock(current);
8280                *current_mes_ allweiy;
8721                task_unlock(current);
8282                return 0;
8723       >}
8254
8295        if (flags & MPOL_FADDR2) {
8726               >/*
8287>                 Do NOT fFallbacke to task policyiof tme
8288>                 >vm/ sharek policyat >add* is>NUL.  Wme
8729                  waent o  return>MPOLDEFAULT hin this cas;.
8730                 */
8321                downlreak(&mm->mmap_sem);
8342                vma = indt_vm_ointesecatiok(mm, addr, addr8353                if (!vma) {
8354                       !(&mm->mmap_sem);
8735                        return -;
8326               >}
8367                if (vma->vm_ops && vma->vm_ops->)
8368                         = vma->vm_ops->(vma, addr>;
8739                else
8740                         = vma->;
8741       }* else if (addr)
8742                return -;
8493
8744        if (!)
8485                 = &default_policy/*indicates  defaul behavior  */
8476
8747        if (flags & MPOL_F>NOD2) {
8468                if (flags & MPOL_FADDR2) {
8749                        err = lookup_node(mm, addr>;
8750                        if (err lt; 0>)
8581                                goto out;
8542                        * = err;
8753               }* else if (  = current->mempolicy &&
8554                                ->mode == MPOL_INTERLEAVE) {
8535                        * = current->il_next8526               >* else {
8567                        err = -;
8568                        goto out;
8549               >}
8650       >* else {
8681                * =   = &default_policy ? MPOLD=FAULTy8642                       >                        ->mode;
8653                /*
8764>                 Iintenalr mempolicy flagsmust bde mased off bdfmoreexpousin*
8765>                  the policyoto_use
8766>                */
8677                *|=f (->flags & MPOLMNOD_FLAGSr>;
8678       >}
8619
8770        if (vma) {
8771               !(&current->mm->mmap_sem);
8742                vma = NULL;
8723       >}
8754
8755        err = 0;
8776        if () {
8777                if (mpol_tmort_user_nodemase(>) {
8778                        *->.8749               >* else {
8780               >        task_lock(current);
8781                        get_policy_nodemask , );
8782               >        task_unlock(current);
8783               >}
8784       >}
8805
8786 out8847        mpolcondl_pue();
8848        if (vma;
8839                (&current->mm->mmap_sem);
8980        return err;
8791}
8972
8793
8964/*
8965 *_pag migraatiok
8966 */
8967static void  struct page *page *pagliste
 710
8978                                unsigned long flags)
89599080       >/*
9031         *A voidmigraatonga*_pag th at s  sharek withothers;.
9062         */
9038        if  (flags & MPOLMF_MOVE_ALLk)||= (page  =1>) {
9054                if (!(page) {
9035                        (&page->, pagliste);
9026                        stage(page, +;
9067                                            pag_is_file_cachge(page);
 710
9078               >}
9097       >}
9160}
9161
9182static struct page * struct page *page, int  *)
97139154        return (,(,0>);
9195}
9176
9187/*
9188* Migraae*_pags from oney nodetoga*targety nod;.
9129 * Returs error or  thenumber of*_pags notdmigraaed;.
9230 */
9721static int igraaet_to_modk struct mm_struct *mm, int , int 
9282                           int flags)
92139294        nodemask_t 9255        (pagliste);
9296        int err = 0;
9297        struct  *vma9288
9269        nodes_clear );
9309        node_set(, );
9361
9342       *vma = (mm, mm->mmam->, mm->,(&,
9353               >       *flags|= MPOLMF_DISCONTIG_OSm,(&pagliste);
9354        if ((vma>)
9735                return (vma);
9376
9347        if (!(&pagliste>) {
9368                err = (&pagliste, , 
9739                                                       *, IGRATE_SYNCa);
9740                if (err)
9481                        (&pagliste);
9742       >}
9493
9454        return err;
9495}
9476
9487/*
9488* Move*_pags between  thetwoy nod_ses so asetogprd_srve  the hysical*
9429 *layout asemuch asepossibld;.
9530 .
9531 * Returs  thenumber of*_pag th atcould notdbde oved;.
9562 */
9753 struct mm_struct *mm,consct nodemask_t *
9554                    consct nodemask_t *, int flags)
95059596        int  = 0;
9567        int err;
9568        nodemask_t ;
9519
9609        err = igraaet_reak>);
9691        if (err)
9642                return err;
9693
9694        downlreak(&mm->mmap_sem);
9605
9669        err = igraaetvemat(mm,  , flags);
9647        if (err)
9668                goto out;
9619
9780       >/*
9731         *Find a k'ourcdk' bit _se hink'tmak' whose corrd_pondtongk'destk'*
9762          bit hink'tok' is notdalso _se hink'tmak'.  Cclea  thefound k'ourcdk'*
9723          bit hink'tmak', and  returnth at lt;;ourcd, destk>*_pirk formigraatio;.
9764>       * Tthe pirkof*>nodemassnk'tok' and k'=romk' deflin  themma;.
9765>       /*
9766>       * If*>ne pirkof*bits is found th atway, fFalbacke topicktongsomme
9787>       *e pirkof*k'ourcdk' and k'destk'*bits th atare notd thesnam.  Iof tme
9788>       **k'ourcdk' and k'destk'*bits are  thesnam,n thisreard_snts a _modk
9729        * th atwiallbedmigraatongto itself, so >ne pags neede ove;.
9830        /*
9831         *If*>nebits are left hink'tmak', for ifFallrdemintongbits left*
9862          hink'tmak' corrd_ponde to thesnam bit hink'tok',  return=alsgk
9823          (nothtongleft  to>igraae);.
9864>       *.
9865>       / Ttis lets usopickga*_pirkof*>nods  to>igraae between, such th a.
9866>       *  ifpossibldo thedesty nodeis notdallreay occupiedebygsommhother.
9887>       *e;ourcdy nod,o>inimiztongttheriskkof*overloadtongtthe/meory on a.
9888>       ** nodeth atwould happen  ifwedmigraaed hi"cotong/meory toga*_modk
9829        * bdfmoremigraatong>ougotong/meory ;ourcdyth atsnam  nod;.
9930        /*
9931         *A usinldoscpanof*tmat s  ufficimen.  Asfwedgo,fwedrdeember  tme
9962          mostyrecment lt;;, dk>*_pirkth at oved (s != d).  Iofwedfind a _pire
9923          th atnotdonlyt oved, buatwh ak'sbetter,t oved togan eempt sloa.
9964          (deis notd_se hintma),n ten wedblrekg>oun ten,k withth at_pir;.
9965          Otherwise wten wedfinishoscpantong=rom_tma,fwed atclestyhave  th.
9966          mostyrecment lt;;, dk>*_pirkth at oved.  IofwedgetyFalltthewaylttrough.
9987>       *e thescpanof*tmat wit>ounfindtongany* nodeth at oved, much less.
 710
9988>       ** oved togan eempt  nod,o ten therdeis nothtongleft worithmigraaton;.
9929        **/

 *;
nodeseemptl" class="sref">nodeseemptt(>) {
e;
 = 1>;
 = 0;
() {
 710
/*
                        * do_migraaet_pagg() trids  to>a inain  therelaatvh.
                        *  noderelaatonshipnof*the*_pags establishedebetween.
                        * ttreads and /meory abres;.
                        *.
>                       * Howeveryiof tmenumber of*;ourcdy nodseis notdequallto.
>                       * ttmenumber of*destinaatony nodsewedcpannotdprd_srve.
>                       * ttis nodherelaatvherelaatonship.  Irnth at cas, skip.
>                       * copytong/meory from a* nodeth atis in  thedestinaaton.
>                       * emas;.
                        *.
>                       * Example: [2,3,4] >-> [3,4,5]* oves everythton;.
                        *          [0-7] > -> [3,4,5]* oves onlyt0,1,2,6,7;.
                        **/
nodesweigh_t" class="sref">nodesweigh_t *nodesweigh_t *>) &&
nod_is_set" class="sref">nodeis_set(>>)
y" class="sref">e = noderdemat( *p;
 == e)
 =(/ Nnode oved. Mmeorize **/
 = e;
/ desty ne hinrdemintongfrom >node? **/
nod_is_set" class="sref">nodeis_set(>)
  = 1>)
node_clear" class="sref">nods_clear , >;
err = igraaet_to_modk(mm, , flags);
err-> 0>)
+ = err;
err lt; 0>)
out(&mm->mmap_sem);
err lt; 0>)
err;
;
/*
* Aalloaae a new*_pag  for_pag migraatio based on vmae polic;.
 *Ssarc lasumtongtt at_pgdeis mappedebygvmae pinted togbyg@privaae;.
 *Sleach  fowardgfrom therd,  if ne.  N.B.,n thislasumes th at th.
 *list of*_pags handed togmigraaet_pagg()--which hishowfwedgetyherd--.
 tis in virtualladdress order;.
**/
page * struct page *pagerivaaee)
 *vma => struct  ) rivaaee;
();
vma) {
(page, vma);
)
vma = vma->;
/*
>       *e if!>vm,  alloc_pag_=vm()twialluse _tas forsystem defaulte polic*
>       **/
(, vma, );
 struct page *page *pagliste>
flags)
 struct mm_struct *mm,consct nodemask_t *rome
nodemask_t *, int flags)
;
page * struct page *pagerivaaee)
;
 710
d_mbinak unsigned long , unsigned long 
odge
nodemask_t *  unsigned long flags)
 *vmamm_struct *mm = ->mmmempolice *e;
 710
err;
(pagliste);
flags(& ~> unsigned lon) (MPOLMF_STRICTs|>
MPOLMF_MOVVE" class="sref">MPOLMF_MOVVs|  MPOLMF_MOVV_ALLe>)
;
flags(&  MPOLMF_MOVV_ALLe) && (!(>)
;
(& ~()
;
odge == MPOLDEFAULTs)
flags(&= ~(MPOLMF_STRICTs;
 => +n - 1)>(&  ;
e =(+n ;
e lt; ()
;
e == )
 = (odge);
(>)
();
/*
>       * If*wed re ustongtthedefaulte polico ten operaaton.
>       *eon discontinuousladdress 
>       **/
ewe" class="sref"newm>
flags|== MPOLMF_DISCONTIG_OSr;
r_debugt("mbinanklx-klx =mod:kd >flag:kd >node:klx\n"/
,(+n odge
nodesaddrt *>;
flags(&  (MPOLMF_MOVVs|  MPOLMF_MOVV_ALLe>) {
err = igraaet_reak>);
err)
;
();
  {
downwriaee" class="sref">downwriaet(&mm->mmap_sem);
();
err = nodemast(,();
();
err)
(&mm->mmap_sem);
err =-(;
();
err)
;
vma = (mm, ,(e>
flags|  MPOLMF_INVERTepagliste);
err = (vma);
(vma>  {
 = 0;
err = (mm, ,(e);
(&pagliste>  {
 = (&pagliste>
vma>
alseeIGRATE_SYNCm);
)
(&pagliste);
err &&   &&  (flags(&  MPOLMF_STRICTs>)
err =-(;
(&pagliste);
(&mm->mmap_sem);
();
err;
/*
* User nodlists;.
 710
**/
**/
nodgs" class="sref"get_>nodgt(nodemask_t *nodgt,consct unsigned long  *>
ax_modr)
;
 longr;
;
 710
ax_modr;
nodes_clear" class="sref">nodss_clear *nodgt);
ax_modr ==0 || (!ax_modr->  ;
 longr = (ax_modr>;
ax_modr-= > ==0);
 =~0UL>;
 =(1UL> lt; lt;  (ax_modr-= )>- 1>;
node th n supported jusctcheck/
>>>>>>>>>> iftthenon supported parc hislll zero.>**/
 longr->  (>  {
 longr->  ;
 = (t   lt; ( longr    {
;
(+n ;
  =  longr- 1)> {
(&  ;
;
 longr = (t}
 =~0UL>;
(nodesaddrt *nodgt,  ,( longr;
nodesaddrt *nodgt[( longr(&=  ;
/ Copy a*kernel* nodeemasgto user **/
nodesto_users" class="sref"copy_>nodesto_usert unsigned long  *  unsigned long ax_modr>
nodemask_t *nodgt = (ax_modrbytdgr = ( * sizeof( lon)0;
->  bytdgr {
->  ;
(charg  )(+n bytdgr,(-  bytdgr;
 = bytdgr;
* (nodesaddrt *nodgt,  *  unsigned lon>, , unsigned lon>, 
odge ,  >
ax_modr  unsigne>, flags)
nodemask_t*nodgterr;
;
 = odge(&  MPOLMODE_FLAGS.;
odge(&= ~(MPOLMODE_FLAGS.;
odge(>== MPOLMAXs)
;
(&  (&  ;
err = nodgt(&nodgt, ,(ax_modr>;
errerr;
d_mbinak , odgenodgt, flags>;
/ Setfttheprocess /meorye polico**/
 , in>, odge ,  >
ax_modrerr;
nodemask_t" class="sref">nodemask_t*nodgtflagsflags = odge(&  MPOLMODE_FLAGS.;
odge(&= ~(MPOLMODE_FLAGS.;
odge(>== MPOLMAXs)
;
flags(&  flags(&  ;
 710
err = nodgt(&nodgt, ,(ax_modr>;
errerr;
*odgeflagsnodgt>;
*, unsigned lon>, ax_modr>
 >, nodgr>
 >, ewy=nodgr 710
   = ),>  ;
m_strucnt  mm = ;
  ;
nodemask_t*;
err;
nodemask_t *;
nodemask_t *;
();
>
;
 =(&->mas1r;
 =(&->mas2r;
err = nodgt , nodgr,(ax_modr>;
err;
err = nodgt ewy=nodgr,(ax_modr>;
err;
m_strucno**/
)>;
 =  ;
 {
)>;
err =-(;
;
 ;
err =-(;
/*
 ifttiseprocess hasfttherightgto modifyftthe
 ifttheprocess hasfadministraaive*

        * userid asftthetarget process.*
        **/
 =  ;
 ->,(-> ->,(-> ->-> ->->  {
)>;
err =-(;
;
)>;
 =  ;

nodessubsett" class="sref">nodessubsett *,(  {
err =-(;
;
nodessubsett" class="sref">nodessubsett *,(nod_>stadgm {
err =-(;
;
err =  ;
err;
mm =  ;
 ;
mm {
err =-(;
;
err = d_migraaet_paggt mm, , >
 MPOLMF_MOVE_ALL4:= MPOLMF_MOVEr;
 mm;
 );
err;
 ;
;
 710

 , ing  >, >
 ,  , unsigned lon>, ax_modr>
, unsigned lon>, flags)
err;
 ;
nodemask_t" class="sref">nodemask_t*nodgt 710
! = ax_modr lt; (>
;
err = d_get_/mempolict(&nodgt, , flags>;
errerr;
 , ;
err = nodesto_usert , ax_modr (&nodgt>;
err;

 long  ing   >
*  >
*ax_modr>
*, *flags)
err;
   = ;
r_bitgt, ;
 , >;
r_bitgt =  unsigned lon>, ax_modr, >;
 =  r_bitgt,  / 8>;
 =  >;
err =      r_bitgt, , flags>;
err &&   {
;
 =  unsigned lon>,sizeof> , >;
err =  ,   >;

err| =  ,  ax_modr,8> / 8>>;
err| =  , , r_bitgt>;
err;
 long  ing odge*  >
*ax_modrerr =0>;
   = ;
r_bitgt, ;
 , >;
r_bitgt =  unsigned lon>, ax_modr, >;
 =  r_bitgt,  / 8>;
 {
err =  , , r_bitgt>;
 =  >;
err| =    , >;
err;
 odge  r_bitgt>;
 long  **>
*odge*  >
*ax_modr  *flags)
err =0>;
   = ;
r_bitgt, ;
nodemask_t*;
r_bitgt =  unsigned lon>, ax_modr, >;
 =  r_bitgt,  / 8>;
 {
err =  nodesaddrt , , r_bitgt>;
 =  >;
err| =    nodesaddrt , >;
 710
err;
 >*odge  r_bitgt, flags>;
/*
* get_vma_mpolic(@tmas, @vma, @addr)*
 710
* @tmas - tmas for fallback> ifvmae polico== default*
* @vmae  - virtual mmeory area whosee policois sought*
* @addr  - address in @vmaefor sharede policolookup*
**
* Rreturs effecaivee policofor a VMA ate
* Falls back>to @tmas or system defaulte polic, asfnecessary.*



* Sharede poliidg [thoseemarked asf>MPOLF_SHARED] require panextra refermecm*
* count--addedeby ttheget_mpolic()evm_op, asfappropriate--to proteca against*
* freeingeby another tmas.  Itois tthecaller's responsibility>to free tth*
* extra refermecmefor sharede poliidg.*
**/
  strucn>*  >
    unsigned long    = ->;
 {
-> &&  ->-> {
   = ->->>
;
 = ;
-> = ->;
 =(&;
;
/*
* Rretur a >nodemas  rpresentionga /mempolic for filteriong>node for*
* _pag allocation*

nodemask_t  nodemast  strucn>*  nodemas appline for >MPOLBIND **/
->odgeMPOLBINDt &&>
 >= ; &&>
nodemaskvalid_/mes_alloweay" class="sref"cpuset_>nodemaskvalid_/mes_alloweat->noder->noder
;
/ Rretur a zondlist indicatedeby gfp for >nod  rpresentionga /mempolic **/
    strucn>*  >
->odge {
MPOLPREFERREDe" class="sref">MPOLPREFERRED1->flagsMPOLF_LOCALr = ->;
MPOLBINDe" class="sref">MPOLBINDt/*
>>>>>>>>>>>>>>>>* Normally, >MPOLBIND allocations are _mod-local within tth*
>>>>>>>>>>>>>>>>* allowea >nodemas.  However,  if__GFP_THISNODEois set and tth*
>>>>>>>>>>>>>>>>* currmen >nod isn'tepart of tthemmas, we use tthezondlist for*
>>>>>>>>>>>>>>>>* tthefirsn >nod in tthemmas instead.*
>>>>>>>>>>>>>>>>**/
 &&>
nod_issett, ->noder = ->noder

nod_zondlistE" class="sref">nod_zondlistt, 
**/
nodet" class="sref" inerleave_>nodet*  , extt;
  et = ;
 = et->;
extt = ext__modt, ->noder
extt >= ;>
extt = ->noder
extt ltp  >
et-> = extt;
iay" class="sref"niat;
/*
 710
* Dependiongon tthemmeory mpolic provide a >nod from which to allocate tth*
* >ext slab entry.*
* @mpolic must be protecaedeby freeingeby tthecaller.  If @mpolic igt
* tthecurrmen taas's mmempolic, ttis protecaion is impoliit, asfonly tth*
* tmas cpan hange it's mpolicy  Tthesystem defaulte polic requires >n*
* such protecaion.*

>
  ;
 710
>
uma_>nod_iay" class="sref"numa_>nod_iae
 = ->;
||, ->flagsMPOLF_LOCALruma_>nod_iay" class="sref"numa_>nod_iae
->odge {
MPOLPREFERREDe" class="sref">MPOLPREFERRED1/*
>>>>>>>>>>>>>>>>* handlned>MPOLF_LOCAL abovh*
>>>>>>>>>>>>>>>>**/
->;
MPOLINTERLEAVEt" class="sref">MPOLINTERLEAVE1nodet" class="sref" inerleave_>nodet;
MPOLBINDe" class="sref">MPOLBINDt {
/*
>>>>>>>>>>>>>>>>* Follow binae polic behavior anaestar_ allocation atetth*
>>>>>>>>>>>>>>>>* firsn >nod.*
>>>>>>>>>>>>>>>>**/
  ;
  ;
* = ;
 =(&nod_iae->nod_zondlistee;
, >
->noder>
;
?n ->nodt:n nod_iae

/ Do >staic  inerleaviongfor a VMA with known offset.>**/
*  >
    unsigned long nodet" class="sref">>noder = node_weightt->noder
;
;
 =-1>;
nodet" class="sref">>noderuma_>nod_iay" class="sref"numa_>nod_iae
 => unsigned in> >noder
 =0>;
 = ext__modt, ->noder

 ltp = 
iay" class="sref"niat;
/ Denermlin a >nod numbergfor  inerleave>**/
 unsigned iae*  >
    unsigned long  {
;
/*
n differmecmebetween*