From: Jonathan Corbet <corbet@lwn.net>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>, linux-mm@kvack.org
Cc: akpm@linux-foundation.org,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
Ben Widawsky <ben.widawsky@intel.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Feng Tang <feng.tang@intel.com>, Michal Hocko <mhocko@kernel.org>,
Andrea Arcangeli <aarcange@redhat.com>,
Mel Gorman <mgorman@techsingularity.net>,
Mike Kravetz <mike.kravetz@oracle.com>,
Randy Dunlap <rdunlap@infradead.org>,
Vlastimil Babka <vbabka@suse.cz>, Andi Kleen <ak@linux.intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Huang Ying <ying.huang@intel.com>,
linux-api@vger.kernel.org
Subject: Re: [PATCH v4 2/3] mm/mempolicy: add set_mempolicy_home_node syscall
Date: Wed, 10 Nov 2021 08:18:10 -0700 [thread overview]
Message-ID: <871r3okpjh.fsf@meer.lwn.net> (raw)
In-Reply-To: <20211101050206.549050-3-aneesh.kumar@linux.ibm.com>
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
> This syscall can be used to set a home node for the MPOL_BIND
> and MPOL_PREFERRED_MANY memory policy. Users should use this
> syscall after setting up a memory policy for the specified range
> as shown below.
So I noticed one little thing as I was looking at this...
[...]
> +SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, len,
> + unsigned long, home_node, unsigned long, flags)
> +{
> + struct mm_struct *mm = current->mm;
> + struct vm_area_struct *vma;
> + struct mempolicy *new;
> + unsigned long vmstart;
> + unsigned long vmend;
> + unsigned long end;
> + int err = -ENOENT;
> +
> + if (start & ~PAGE_MASK)
> + return -EINVAL;
> +
> + len = (len + PAGE_SIZE - 1) & PAGE_MASK;
> + end = start + len;
> +
> + if (end < start)
> + return -EINVAL;
> + if (end == start)
> + return 0;
> + mmap_write_lock(mm);
> + vma = find_vma(mm, start);
> + for (; vma && vma->vm_start < end; vma = vma->vm_next) {
> +
> + vmstart = max(start, vma->vm_start);
> + vmend = min(end, vma->vm_end);
> + new = mpol_dup(vma_policy(vma));
> + if (IS_ERR(new)) {
> + err = PTR_ERR(new);
> + break;
> + }
> + /*
> + * Only update home node if there is an existing vma policy
> + */
> + if (!new)
> + continue;
> + new->home_node = home_node;
> + err = mbind_range(mm, vmstart, vmend, new);
> + if (err)
> + break;
> + }
> + mmap_write_unlock(mm);
> + return err;
> +}
You never do anything with flags; I believe you want to check and ensure
that it's zero if there are no defined flags at this point?
Thanks,
jon
next prev parent reply other threads:[~2021-11-10 15:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-01 5:02 [PATCH v4 0/3] mm: add new syscall set_mempolicy_home_node Aneesh Kumar K.V
2021-11-01 5:02 ` [PATCH v4 1/3] mm/mempolicy: use policy_node helper with MPOL_PREFERRED_MANY Aneesh Kumar K.V
2021-11-01 5:02 ` [PATCH v4 2/3] mm/mempolicy: add set_mempolicy_home_node syscall Aneesh Kumar K.V
2021-11-10 15:18 ` Jonathan Corbet [this message]
2021-11-10 15:55 ` Aneesh Kumar K.V
2021-11-01 5:02 ` [PATCH v4 3/3] mm/mempolicy: wire up syscall set_mempolicy_home_node Aneesh Kumar K.V
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871r3okpjh.fsf@meer.lwn.net \
--to=corbet@lwn.net \
--cc=aarcange@redhat.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=ben.widawsky@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=feng.tang@intel.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=rdunlap@infradead.org \
--cc=vbabka@suse.cz \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox