Skip to contentSkip to conversation

man/man2/{mbind,set_mempolicy}.2: added mode argument MPOL_PREFERRED_MANY

PATCH In review Matthew Cassell 2 participants 4 messages Feb 18, 2025 – Feb 21, 2025 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 man/man2/{mbind,set_mempolicy}.2: added mode argument MPOL_PREFERRED_MANY

Browsing a header file in the kernel source and saw the memory policy enum used for mbind() and set_mempolicy() using an entry that I didn't recognize. I man 2'd both system calls and didn't see an entry for MPOL_PREFERRED_MANY. The commit on the enum entry:

Commit b27abaccf8e8 ("mm/mempolicy: added MPOL_PREFERRED_MANY for multiple preferred nodes")

The commit message gives the rationale as to why the MPOL_PREFERRED_MANY mode would be beneficial. Giving the ability to set the memory policy to target different tiers of memory over different NUMA nodes.

---
 man/man2/mbind.2         | 11 +++++++++++
 man/man2/set_mempolicy.2 | 11 +++++++++++
 2 files changed, 22 insertions(+)
man/man2/mbind.2 +11 -0
index fd1aca4ad..a5a7f4bdc 100644
@@ -107,6 +107,7 @@ argument must specify one of
 .BR MPOL_INTERLEAVE ,
 .BR MPOL_WEIGHTED_INTERLEAVE ,
 .BR MPOL_PREFERRED ,
+.BR MPOL_PREFERRED_MANY ,
 or
 .B MPOL_LOCAL
 (which are described in detail below).
@@ -277,6 +278,16 @@ and
 arguments specify the empty set, then the memory is allocated on
 the node of the CPU that triggered the allocation.
 .TP
+.BR MPOL_PREFERRED_MANY " (since Linux 5.15)"
+.\" commit b27abaccf8e8b012f126da0c2a1ab32723ec8b9f
+This mode specifies a preference for nodes from which the kernel will
+try to allocate from. This differs from
+.BR MPOL_PREFERRED
+in that it accepts a set of nodes versus a single node. This policy
+is intended to benefit page allocations where specific memory types
+(i.e. non-volatile, high-bandwidth, or accelerator memory) are of
+greater importance than node location.
+.TP
 .BR MPOL_LOCAL " (since Linux 3.8)"
 .\" commit 479e2802d09f1e18a97262c4c6f8f17ae5884bd8
 .\" commit f2a07f40dbc603c15f8b06e6ec7f768af67b424f
man/man2/set_mempolicy.2 +11 -0
index 2d0b1da19..f4651ccd3 100644
@@ -65,6 +65,7 @@ argument must specify one of
 .BR MPOL_INTERLEAVE ,
 .BR MPOL_WEIGHTED_INTERLEAVE ,
 .BR MPOL_PREFERRED ,
+.BR MPOL_PREFERRED_MANY ,
 or
 .B MPOL_LOCAL
 (which are described in detail below).
@@ -234,6 +235,16 @@ arguments specify the empty set, then the policy
 specifies "local allocation"
 (like the system default policy discussed above).
 .TP
+.BR MPOL_PREFERRED_MANY " (since Linux 5.15)"
+.\" commit b27abaccf8e8b012f126da0c2a1ab32723ec8b9f
+This mode specifies a preference for nodes from which the kernel will
+try to allocate from. This differs from
+.BR MPOL_PREFERRED
+in that it accepts a set of nodes versus a single node. This policy
+is intended to benefit page allocations where specific memory types
+(i.e. non-volatile, high-bandwidth, or accelerator memory) are of
+greater importance than node location.
+.TP
 .BR MPOL_LOCAL " (since Linux 3.8)"
 .\" commit 479e2802d09f1e18a97262c4c6f8f17ae5884bd8
 .\" commit f2a07f40dbc603c15f8b06e6ec7f768af67b424f
Signature · 1 line
2.39.5 (Apple Git-154)
#1 lore raw

Hi Matthew,

Quoted 1 line

Please add a Cc tag for Dave in the trailer of the commit message.

Quoted 2 lines · Matthew Cassell

Browsing a header file in the kernel source and saw the memory policy enum used for mbind() and set_mempolicy() using an entry that I didn't recognize. I man 2'd

Please use 2 spaces as the inter-sentence separation in commit messages (in man(7) source we always break the line after period).

$ cat CONTRIBUTING.d/patches/description | sed -n '/Style/,+5p'
    Style guide
	URIs should always be enclosed in <>.

The correct inter-sentence space amount is two. See some history about this:
<https://web.archive.org/web/20171217060354/http://www.heracliteanriver.com/?p=324>

Quoted 4 lines

both system calls and didn't see an entry for MPOL_PREFERRED_MANY. The commit on the enum entry:

Commit b27abaccf8e8 ("mm/mempolicy: added MPOL_PREFERRED_MANY for multiple

Let's remove 'Commit'; it's already obvious from what follows. Instead it would be useful to say which repository the commit is in (and the commit date):

linux.git b27abaccf8e8 (2021-09-03; "mm/mempolicy: add MPOL_PREFERRED_MANY for multiple preferred nodes")

Also, while in general I use a 72-column right margin for commit messages, I think I prefer if we don't break this reference.

Quoted 25 lines

preferred nodes")

The commit message gives the rationale as to why the MPOL_PREFERRED_MANY mode would be beneficial. Giving the ability to set the memory policy to target different tiers of memory over different NUMA nodes.

---
 man/man2/mbind.2         | 11 +++++++++++
 man/man2/set_mempolicy.2 | 11 +++++++++++
 2 files changed, 22 insertions(+)
man/man2/mbind.2 +1 -0
index fd1aca4ad..a5a7f4bdc 100644
@@ -107,6 +107,7 @@ argument must specify one of
 .BR MPOL_INTERLEAVE ,
 .BR MPOL_WEIGHTED_INTERLEAVE ,
 .BR MPOL_PREFERRED ,
+.BR MPOL_PREFERRED_MANY ,
 or
 .B MPOL_LOCAL
 (which are described in detail below).

man/man2/mbind.2 and · line 284

Quoted 7 lines
man/man2/mbind.2 +4 -0
@@ -277,6 +278,16 @@ and
 arguments specify the empty set, then the memory is allocated on
 the node of the CPU that triggered the allocation.
 .TP
+.BR MPOL_PREFERRED_MANY " (since Linux 5.15)"
+.\" commit b27abaccf8e8b012f126da0c2a1ab32723ec8b9f
+This mode specifies a preference for nodes from which the kernel will
+try to allocate from. This differs from

Please use semantic newlines. See man-pages(7):

$ MANWIDTH=72 man man-pages | sed -n '/Use semantic newlines/,/^$/p'
   Use semantic newlines
       In  the source of a manual page, new sentences should be started
       on new lines, long sentences  should  be  split  into  lines  at
       clause  breaks (commas, semicolons, colons, and so on), and long
       clauses should be split at phrase boundaries.  This  convention,
       sometimes  known  as "semantic newlines", makes it easier to see
       the effect of patches, which often operate at the level of indi-
       vidual sentences, clauses, or phrases.
Quoted 24 lines
man/man2/mbind.2 +6 -0
+.BR MPOL_PREFERRED
+in that it accepts a set of nodes versus a single node. This policy
+is intended to benefit page allocations where specific memory types
+(i.e. non-volatile, high-bandwidth, or accelerator memory) are of
+greater importance than node location.
+.TP
 .BR MPOL_LOCAL " (since Linux 3.8)"
 .\" commit 479e2802d09f1e18a97262c4c6f8f17ae5884bd8
 .\" commit f2a07f40dbc603c15f8b06e6ec7f768af67b424f
man/man2/set_mempolicy.2 +1 -0
index 2d0b1da19..f4651ccd3 100644
@@ -65,6 +65,7 @@ argument must specify one of
 .BR MPOL_INTERLEAVE ,
 .BR MPOL_WEIGHTED_INTERLEAVE ,
 .BR MPOL_PREFERRED ,
+.BR MPOL_PREFERRED_MANY ,
 or
 .B MPOL_LOCAL
 (which are described in detail below).
@@ -234,6 +235,16 @@ arguments specify the empty set, then the policy
 specifies "local allocation"
 (like the system default policy discussed above).

man/man2/set_mempolicy.2 arguments specify the empty set, then the policy · line 246

Quoted 10 lines
man/man2/set_mempolicy.2 +9 -0
 .TP
+.BR MPOL_PREFERRED_MANY " (since Linux 5.15)"
+.\" commit b27abaccf8e8b012f126da0c2a1ab32723ec8b9f
+This mode specifies a preference for nodes from which the kernel will
+try to allocate from. This differs from
+.BR MPOL_PREFERRED
+in that it accepts a set of nodes versus a single node. This policy
+is intended to benefit page allocations where specific memory types
+(i.e. non-volatile, high-bandwidth, or accelerator memory) are of
+greater importance than node location.

Should we refer from one page to the other? It's hard to keep in sync two manual pages with the same text.

Have a lovely day!
Alex

Quoted 7 lines
man/man2/set_mempolicy.2 +1 -0
+.TP
 .BR MPOL_LOCAL " (since Linux 3.8)"
 .\" commit 479e2802d09f1e18a97262c4c6f8f17ae5884bd8
 .\" commit f2a07f40dbc603c15f8b06e6ec7f768af67b424f
Signature · 1 line
2.39.5 (Apple Git-154)
Signature · 1 line
<https://www.alejandro-colomar.es/>
#2 lore raw

Thank you for the feedback Alejandro. I'm writing a revision now to better stay in format.

Quoted 2 lines

Should we refer from one page to the other? It's hard to keep in sync two manual pages with the same text.

Do you think that keeping the more descriptive paragraph in set_mempolicy(2) and putting a brief referral in mbind(2) would work:

MPOL_PREFERRED_MANY (since Linux 5.15)
Specifies a set of nodes for allocation; see set_mempolicy(2)

-Matt C

Quoted 134 lines · Alejandro Colomar

Hi Matthew,

Quoted 1 line

Please add a Cc tag for Dave in the trailer of the commit message.

Quoted 2 lines · Matthew Cassell

Browsing a header file in the kernel source and saw the memory policy enum used for mbind() and set_mempolicy() using an entry that I didn't recognize. I man 2'd

Please use 2 spaces as the inter-sentence separation in commit messages (in man(7) source we always break the line after period).

$ cat CONTRIBUTING.d/patches/description | sed -n '/Style/,+5p'
    Style guide
        URIs should always be enclosed in <>.

The correct inter-sentence space amount is two. See some history about this:
<https://web.archive.org/web/20171217060354/http://www.heracliteanriver.com/?p=324>

Quoted 4 lines

both system calls and didn't see an entry for MPOL_PREFERRED_MANY. The commit on the enum entry:

Commit b27abaccf8e8 ("mm/mempolicy: added MPOL_PREFERRED_MANY for multiple

Let's remove 'Commit'; it's already obvious from what follows. Instead it would be useful to say which repository the commit is in (and the commit date):

linux.git b27abaccf8e8 (2021-09-03; "mm/mempolicy: add MPOL_PREFERRED_MANY for multiple preferred nodes")

Also, while in general I use a 72-column right margin for commit messages, I think I prefer if we don't break this reference.

Quoted 25 lines

preferred nodes")

The commit message gives the rationale as to why the MPOL_PREFERRED_MANY mode would be beneficial. Giving the ability to set the memory policy to target different tiers of memory over different NUMA nodes.

---
 man/man2/mbind.2         | 11 +++++++++++
 man/man2/set_mempolicy.2 | 11 +++++++++++
 2 files changed, 22 insertions(+)
man/man2/mbind.2 +1 -0
index fd1aca4ad..a5a7f4bdc 100644
@@ -107,6 +107,7 @@ argument must specify one of
 .BR MPOL_INTERLEAVE ,
 .BR MPOL_WEIGHTED_INTERLEAVE ,
 .BR MPOL_PREFERRED ,
+.BR MPOL_PREFERRED_MANY ,
 or
 .B MPOL_LOCAL
 (which are described in detail below).

man/man2/mbind.2 and · line 284

Quoted 7 lines
man/man2/mbind.2 +4 -0
@@ -277,6 +278,16 @@ and
 arguments specify the empty set, then the memory is allocated on
 the node of the CPU that triggered the allocation.
 .TP
+.BR MPOL_PREFERRED_MANY " (since Linux 5.15)"
+.\" commit b27abaccf8e8b012f126da0c2a1ab32723ec8b9f
+This mode specifies a preference for nodes from which the kernel will
+try to allocate from. This differs from

Please use semantic newlines. See man-pages(7):

$ MANWIDTH=72 man man-pages | sed -n '/Use semantic newlines/,/^$/p'
   Use semantic newlines
       In  the source of a manual page, new sentences should be started
       on new lines, long sentences  should  be  split  into  lines  at
       clause  breaks (commas, semicolons, colons, and so on), and long
       clauses should be split at phrase boundaries.  This  convention,
       sometimes  known  as "semantic newlines", makes it easier to see
       the effect of patches, which often operate at the level of indi-
       vidual sentences, clauses, or phrases.
Quoted 24 lines
man/man2/mbind.2 +6 -0
+.BR MPOL_PREFERRED
+in that it accepts a set of nodes versus a single node. This policy
+is intended to benefit page allocations where specific memory types
+(i.e. non-volatile, high-bandwidth, or accelerator memory) are of
+greater importance than node location.
+.TP
 .BR MPOL_LOCAL " (since Linux 3.8)"
 .\" commit 479e2802d09f1e18a97262c4c6f8f17ae5884bd8
 .\" commit f2a07f40dbc603c15f8b06e6ec7f768af67b424f
man/man2/set_mempolicy.2 +1 -0
index 2d0b1da19..f4651ccd3 100644
@@ -65,6 +65,7 @@ argument must specify one of
 .BR MPOL_INTERLEAVE ,
 .BR MPOL_WEIGHTED_INTERLEAVE ,
 .BR MPOL_PREFERRED ,
+.BR MPOL_PREFERRED_MANY ,
 or
 .B MPOL_LOCAL
 (which are described in detail below).
@@ -234,6 +235,16 @@ arguments specify the empty set, then the policy
 specifies "local allocation"
 (like the system default policy discussed above).

man/man2/set_mempolicy.2 arguments specify the empty set, then the policy · line 246

Quoted 10 lines
man/man2/set_mempolicy.2 +9 -0
 .TP
+.BR MPOL_PREFERRED_MANY " (since Linux 5.15)"
+.\" commit b27abaccf8e8b012f126da0c2a1ab32723ec8b9f
+This mode specifies a preference for nodes from which the kernel will
+try to allocate from. This differs from
+.BR MPOL_PREFERRED
+in that it accepts a set of nodes versus a single node. This policy
+is intended to benefit page allocations where specific memory types
+(i.e. non-volatile, high-bandwidth, or accelerator memory) are of
+greater importance than node location.

Should we refer from one page to the other? It's hard to keep in sync two manual pages with the same text.

Have a lovely day!
Alex

Quoted 7 lines
man/man2/set_mempolicy.2 +1 -1
+.TP
 .BR MPOL_LOCAL " (since Linux 3.8)"
 .\" commit 479e2802d09f1e18a97262c4c6f8f17ae5884bd8
 .\" commit f2a07f40dbc603c15f8b06e6ec7f768af67b424f
--

2.39.5 (Apple Git-154)

--
<https://www.alejandro-colomar.es/>

#3 lore raw

Hi Matt,

Quoted 8 lines · Matthew Cassell

Thank you for the feedback Alejandro. I'm writing a revision now to better stay in format.

Quoted 2 lines

Should we refer from one page to the other? It's hard to keep in sync two manual pages with the same text.

Do you think that keeping the more descriptive paragraph in set_mempolicy(2) and putting a brief referral in mbind(2) would work:

Sure!

Quoted 2 lines

MPOL_PREFERRED_MANY (since Linux 5.15)
Specifies a set of nodes for allocation; see set_mempolicy(2)

Yep, this looks good to me. Thanks!

Have a lovely day!
Alex

Quoted 3 lines

-Matt C

Signature · 1 line
<https://www.alejandro-colomar.es/>