mempolicy: mpol_shared_policy_init() without pseudo-vma
mpol_shared_policy_init() does not need to use a pseudo-vma: it can use sp_alloc() and sp_insert() directly, since the object's shared policy tree is empty and inaccessible (needing no lock) at get_inode() time. Link: https://lkml.kernel.org/r/3bef62d8-ae78-4c2-533-56a44ae425c@google.com Signed-off-by: Hugh Dickins <hughd@google.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Christoph Lameter <cl@linux.com> Cc: David Hildenbrand <david@redhat.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Huang, Ying" <ying.huang@intel.com> Cc: Kefeng Wang <wangkefeng.wang@huawei.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Nhat Pham <nphamcs@gmail.com> Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Tejun heo <tj@kernel.org> Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com> Cc: Yang Shi <shy828301@gmail.com> Cc: Yosry Ahmed <yosryahmed@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
93397c3b76
commit
35ec8fa020
@ -2736,30 +2736,30 @@ void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol)
|
||||
rwlock_init(&sp->lock);
|
||||
|
||||
if (mpol) {
|
||||
struct vm_area_struct pvma;
|
||||
struct mempolicy *new;
|
||||
struct sp_node *sn;
|
||||
struct mempolicy *npol;
|
||||
NODEMASK_SCRATCH(scratch);
|
||||
|
||||
if (!scratch)
|
||||
goto put_mpol;
|
||||
/* contextualize the tmpfs mount point mempolicy */
|
||||
new = mpol_new(mpol->mode, mpol->flags, &mpol->w.user_nodemask);
|
||||
if (IS_ERR(new))
|
||||
|
||||
/* contextualize the tmpfs mount point mempolicy to this file */
|
||||
npol = mpol_new(mpol->mode, mpol->flags, &mpol->w.user_nodemask);
|
||||
if (IS_ERR(npol))
|
||||
goto free_scratch; /* no valid nodemask intersection */
|
||||
|
||||
task_lock(current);
|
||||
ret = mpol_set_nodemask(new, &mpol->w.user_nodemask, scratch);
|
||||
ret = mpol_set_nodemask(npol, &mpol->w.user_nodemask, scratch);
|
||||
task_unlock(current);
|
||||
if (ret)
|
||||
goto put_new;
|
||||
goto put_npol;
|
||||
|
||||
/* Create pseudo-vma that contains just the policy */
|
||||
vma_init(&pvma, NULL);
|
||||
pvma.vm_end = TASK_SIZE; /* policy covers entire file */
|
||||
mpol_set_shared_policy(sp, &pvma, new); /* adds ref */
|
||||
|
||||
put_new:
|
||||
mpol_put(new); /* drop initial ref */
|
||||
/* alloc node covering entire file; adds ref to file's npol */
|
||||
sn = sp_alloc(0, MAX_LFS_FILESIZE >> PAGE_SHIFT, npol);
|
||||
if (sn)
|
||||
sp_insert(sp, sn);
|
||||
put_npol:
|
||||
mpol_put(npol); /* drop initial ref on file's npol */
|
||||
free_scratch:
|
||||
NODEMASK_SCRATCH_FREE(scratch);
|
||||
put_mpol:
|
||||
|
Loading…
x
Reference in New Issue
Block a user