]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
6 weeks agodst_setup(): Add fast path
Liam R. Howlett [Thu, 25 Sep 2025 03:10:09 +0000 (23:10 -0400)]
dst_setup(): Add fast path

If nodes will fit, the just go with it and fix the null terminated nodes in cp_data_write()

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agomulti_src_setup(): Add wr_mas optimisation for appending
Liam R. Howlett [Thu, 25 Sep 2025 02:52:54 +0000 (22:52 -0400)]
multi_src_setup(): Add wr_mas optimisation for appending

Use already available data, when possible

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agomaple_tree: mas_wr_node_store() general cleanup
Liam R. Howlett [Thu, 25 Sep 2025 02:38:21 +0000 (22:38 -0400)]
maple_tree: mas_wr_node_store() general cleanup

Set variables after declaration, order declaration by length of lines.
Remove the height variable as it is seldom used.
Don't memcpy size 0.
change type of slots size to void __rcu *

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agomaple_tree: Remove new_end argument from append and node store
Liam R. Howlett [Thu, 25 Sep 2025 02:10:01 +0000 (22:10 -0400)]
maple_tree: Remove new_end argument from append and node store

Not all writes need the new_end value, so only calculate it when necessary.

mas_wr_node_store() already looks at the necessary informations, so
inline the calculation with the other logic.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agofix type in memcpy
Liam R. Howlett [Thu, 25 Sep 2025 01:57:32 +0000 (21:57 -0400)]
fix type in memcpy

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agoit is unlikely to overwrite the whole tree
Liam R. Howlett [Wed, 24 Sep 2025 20:03:22 +0000 (16:03 -0400)]
it is unlikely to overwrite the whole tree

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agoChange mas_wmb_replace() to do include the setup
Liam R. Howlett [Wed, 24 Sep 2025 16:48:21 +0000 (12:48 -0400)]
Change mas_wmb_replace() to do include the setup

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agoadd spanning_ascend() comment
Liam R. Howlett [Wed, 24 Sep 2025 16:31:59 +0000 (12:31 -0400)]
add spanning_ascend() comment

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agodrop mas_wr_spanning_rebalance and inline it
Liam R. Howlett [Wed, 24 Sep 2025 16:31:25 +0000 (12:31 -0400)]
drop mas_wr_spanning_rebalance and inline it

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agoascend function cleanups
Liam R. Howlett [Wed, 24 Sep 2025 15:36:08 +0000 (11:36 -0400)]
ascend function cleanups

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agorenames and comments for code
Liam R. Howlett [Wed, 24 Sep 2025 15:12:36 +0000 (11:12 -0400)]
renames and comments for code

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agomore cleanup. Rename multi_dst_setup() to dst_setup()
Liam R. Howlett [Wed, 24 Sep 2025 14:26:54 +0000 (10:26 -0400)]
more cleanup.  Rename multi_dst_setup() to dst_setup()

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agoadd comment to data_fits and reduce branching
Liam R. Howlett [Wed, 24 Sep 2025 14:22:43 +0000 (10:22 -0400)]
add comment to data_fits and reduce branching

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agodrop dead code in data_fits()
Liam R. Howlett [Wed, 24 Sep 2025 14:09:19 +0000 (10:09 -0400)]
drop dead code in data_fits()

Don't check twice for data fitting for splits

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agodrop big node and maple subtree state
Liam R. Howlett [Wed, 24 Sep 2025 14:08:39 +0000 (10:08 -0400)]
drop big node and maple subtree state

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agoworking and drop debug
Liam R. Howlett [Wed, 24 Sep 2025 14:03:25 +0000 (10:03 -0400)]
working and drop debug

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agotesting conversion and cleanup
Liam R. Howlett [Wed, 24 Sep 2025 14:02:21 +0000 (10:02 -0400)]
testing conversion and cleanup

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agobroken split
Liam R. Howlett [Tue, 23 Sep 2025 19:00:28 +0000 (15:00 -0400)]
broken split

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agodebug
Liam R. Howlett [Mon, 22 Sep 2025 20:06:38 +0000 (16:06 -0400)]
debug

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agoadd split and push to rebalance
Liam R. Howlett [Mon, 22 Sep 2025 19:37:12 +0000 (15:37 -0400)]
add split and push to rebalance

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
6 weeks agopull min and max into cp_dst_to_slots()
Liam R. Howlett [Mon, 22 Sep 2025 19:33:44 +0000 (15:33 -0400)]
pull min and max into cp_dst_to_slots()

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
7 weeks agofix cp_leaf_init and r_wr_mas.end_piv on spanning store
Liam R. Howlett [Wed, 17 Sep 2025 20:11:02 +0000 (16:11 -0400)]
fix cp_leaf_init and r_wr_mas.end_piv on spanning store

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
7 weeks agocp_data_write: Fix dst_size to be split + 1
Liam R. Howlett [Wed, 17 Sep 2025 01:01:06 +0000 (21:01 -0400)]
cp_data_write: Fix dst_size to be split + 1

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
7 weeks agomulti_dst_setup: Fix split size and data off by one
Liam R. Howlett [Wed, 17 Sep 2025 01:00:50 +0000 (21:00 -0400)]
multi_dst_setup: Fix split size and data off by one

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
7 weeks agonode_copy: Fix d_max return value
Liam R. Howlett [Wed, 17 Sep 2025 01:00:18 +0000 (21:00 -0400)]
node_copy: Fix d_max return value

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
7 weeks agocp_data_write: simplify
Liam R. Howlett [Tue, 16 Sep 2025 19:50:21 +0000 (15:50 -0400)]
cp_data_write: simplify

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
7 weeks agoCorrectly set src max on node_cp
Liam R. Howlett [Tue, 16 Sep 2025 19:00:45 +0000 (15:00 -0400)]
Correctly set src max on node_cp

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
7 weeks agorename ma_cp_to to cp_dst_to
Liam R. Howlett [Tue, 16 Sep 2025 18:31:04 +0000 (14:31 -0400)]
rename ma_cp_to to cp_dst_to

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
7 weeks agorename __rebalance_data to cp_data
Liam R. Howlett [Tue, 16 Sep 2025 18:30:31 +0000 (14:30 -0400)]
rename __rebalance_data to cp_data

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
7 weeks agorename rebalance_leaf to cp_leaf
Liam R. Howlett [Tue, 16 Sep 2025 17:59:23 +0000 (13:59 -0400)]
rename rebalance_leaf to cp_leaf

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
7 weeks agorename rebalance_dest to multi_dst
Liam R. Howlett [Tue, 16 Sep 2025 17:56:12 +0000 (13:56 -0400)]
rename rebalance_dest to multi_dst

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
8 weeks agomaple_tree: Use maple_copy for rebalance
Liam R. Howlett [Sat, 13 Sep 2025 20:32:09 +0000 (16:32 -0400)]
maple_tree: Use maple_copy for rebalance

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
8 weeks agospanning_leaf_init: make spanning leaf safe for all rebalances
Liam R. Howlett [Thu, 11 Sep 2025 14:06:16 +0000 (10:06 -0400)]
spanning_leaf_init: make spanning leaf safe for all rebalances

Getting the right side of the operations content from the slot means
that the rebalance can pass the same wr_mas into this function to
correctly set up the new leaf entries.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
8 weeks agomaple_tree: Separate wr_split_store and wr_rebalance store type code
Liam R. Howlett [Wed, 10 Sep 2025 14:56:56 +0000 (10:56 -0400)]
maple_tree: Separate wr_split_store and wr_rebalance store type code
path

The split and rebalance store types both go through the same function
that uses the big node.  Separate the code paths so that each can be
updated independently.

No functional change intended

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
8 weeks agoRemove debug - Working spanning store
Liam R. Howlett [Wed, 3 Sep 2025 16:09:58 +0000 (12:09 -0400)]
Remove debug - Working spanning store

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoFix ascending on l and r on the same node
Liam R. Howlett [Wed, 3 Sep 2025 16:09:47 +0000 (12:09 -0400)]
Fix ascending on l and r on the same node

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agore-enable testing of size
Liam R. Howlett [Wed, 3 Sep 2025 01:41:39 +0000 (21:41 -0400)]
re-enable testing of size

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agotry to honor min height calc
Liam R. Howlett [Wed, 3 Sep 2025 01:16:48 +0000 (21:16 -0400)]
try to honor min height calc

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agodebug removal but broken somehow
Liam R. Howlett [Mon, 1 Sep 2025 06:26:03 +0000 (02:26 -0400)]
debug removal but broken somehow

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoRevert "testing output"
Liam R. Howlett [Mon, 1 Sep 2025 06:08:53 +0000 (02:08 -0400)]
Revert "testing output"

This reverts commit 7312f0d993e1a9939dddbd0c9603bc8b89fd491d.

2 months agotesting output
Liam R. Howlett [Mon, 1 Sep 2025 06:08:49 +0000 (02:08 -0400)]
testing output

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agocheck_range() test update for spanning store calculations
Liam R. Howlett [Mon, 1 Sep 2025 06:08:18 +0000 (02:08 -0400)]
check_range() test update for spanning store calculations

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agospanning_ascend fixes
Liam R. Howlett [Mon, 1 Sep 2025 06:07:05 +0000 (02:07 -0400)]
spanning_ascend fixes

fix gaps by moving sibling check earlier
fix node_finalise by making cp->end +1, was skipping last node
Continue if left and right meet (l_wr_mas->mas->noded == r_wr_mas..

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agosplit destination off by one
Liam R. Howlett [Mon, 1 Sep 2025 06:04:36 +0000 (02:04 -0400)]
split destination off by one

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agogap fix for non leaf
Liam R. Howlett [Sun, 31 Aug 2025 01:10:50 +0000 (21:10 -0400)]
gap fix for non leaf

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agomt_validate() detect root of size 0
Liam R. Howlett [Sun, 31 Aug 2025 00:44:23 +0000 (20:44 -0400)]
mt_validate() detect root of size 0

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agonode_copy(): try to fix max of nodes
Liam R. Howlett [Sun, 31 Aug 2025 00:43:17 +0000 (20:43 -0400)]
node_copy(): try to fix max of nodes

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agonode_copy setting wrong parent slot
Liam R. Howlett [Sun, 31 Aug 2025 00:38:17 +0000 (20:38 -0400)]
node_copy setting wrong parent slot

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agomt_pivots incorrect for maple_copy
Liam R. Howlett [Sun, 31 Aug 2025 00:37:55 +0000 (20:37 -0400)]
mt_pivots incorrect for maple_copy

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agospanning_data_calc() one off error
Liam R. Howlett [Sun, 31 Aug 2025 00:37:34 +0000 (20:37 -0400)]
spanning_data_calc() one off error

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoreadability of d increment and gap fix
Liam R. Howlett [Fri, 29 Aug 2025 19:09:21 +0000 (15:09 -0400)]
readability of d increment and gap fix

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agofix max when rewinding
Liam R. Howlett [Fri, 29 Aug 2025 19:09:05 +0000 (15:09 -0400)]
fix max when rewinding

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agomaple_tree: Create ma_leaf_max_gap() to not depend on maple state
Liam R. Howlett [Fri, 29 Aug 2025 19:08:19 +0000 (15:08 -0400)]
maple_tree: Create ma_leaf_max_gap() to not depend on maple state

Pass through the min, max, pivots, and slots so that a maple state is not needed.

This is neede dlater to avoid the min and max extraction from the struct which isn't always available.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agotests are failing
Liam R. Howlett [Wed, 27 Aug 2025 14:41:38 +0000 (10:41 -0400)]
tests are failing

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agomaple_tree: Increase spanning store testing and rcu cleanup
Liam R. Howlett [Tue, 26 Aug 2025 18:30:51 +0000 (14:30 -0400)]
maple_tree: Increase spanning store testing and rcu cleanup

Add more spanning store tests and validate the tree after the tests.

When rcu tests fail, many fail and dump the tree.  Add a lock to only
allow the first to dump the tree while the rest exit.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agodebug and warn on
Liam R. Howlett [Tue, 26 Aug 2025 17:02:53 +0000 (13:02 -0400)]
debug and warn on

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agonode_finalise was a mess
Liam R. Howlett [Tue, 26 Aug 2025 17:02:34 +0000 (13:02 -0400)]
node_finalise was a mess

meta needs to be set regardless for arange

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoheight fix
Liam R. Howlett [Tue, 26 Aug 2025 17:01:43 +0000 (13:01 -0400)]
height fix

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoascend cleanup
Liam R. Howlett [Tue, 26 Aug 2025 16:12:06 +0000 (12:12 -0400)]
ascend cleanup

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agonode finalise new root\n
Liam R. Howlett [Tue, 26 Aug 2025 16:10:00 +0000 (12:10 -0400)]
node finalise new root\n

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoheight fix
Liam R. Howlett [Tue, 26 Aug 2025 15:36:33 +0000 (11:36 -0400)]
height fix

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agofix new node location
Liam R. Howlett [Tue, 26 Aug 2025 15:31:50 +0000 (11:31 -0400)]
fix new node location

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agonew root broken
Liam R. Howlett [Tue, 26 Aug 2025 01:41:00 +0000 (21:41 -0400)]
new root broken

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agonew root broken
Liam R. Howlett [Tue, 26 Aug 2025 01:39:05 +0000 (21:39 -0400)]
new root broken

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agofix whitespace
Liam R. Howlett [Mon, 25 Aug 2025 20:41:16 +0000 (16:41 -0400)]
fix whitespace

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agodrop wr_l_mas and l_mas from mas_wr_spanning_store
Liam R. Howlett [Mon, 25 Aug 2025 20:40:54 +0000 (16:40 -0400)]
drop wr_l_mas and l_mas from mas_wr_spanning_store

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agodrop mast from spanning rebalance
Liam R. Howlett [Mon, 25 Aug 2025 20:38:33 +0000 (16:38 -0400)]
drop mast from spanning rebalance

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agobig hunk of code, drop big node from spanning store
Liam R. Howlett [Mon, 25 Aug 2025 20:37:39 +0000 (16:37 -0400)]
big hunk of code, drop big node from spanning store

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoadd cp.pivot to ma_pivots
Liam R. Howlett [Mon, 25 Aug 2025 19:57:07 +0000 (15:57 -0400)]
add cp.pivot to ma_pivots

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agocp.min and cp.max fixes
Liam R. Howlett [Fri, 22 Aug 2025 17:05:27 +0000 (13:05 -0400)]
cp.min and cp.max fixes

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agomaple_copy: Increase slots to 3
Liam R. Howlett [Fri, 22 Aug 2025 17:04:35 +0000 (13:04 -0400)]
maple_copy: Increase slots to 3

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agofix destination max setting
Liam R. Howlett [Fri, 22 Aug 2025 15:51:24 +0000 (11:51 -0400)]
fix destination max setting

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoadd dummy loop
Liam R. Howlett [Thu, 21 Aug 2025 21:02:43 +0000 (17:02 -0400)]
add dummy loop

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agostop using maple_subtree_state
Liam R. Howlett [Thu, 21 Aug 2025 21:02:02 +0000 (17:02 -0400)]
stop using maple_subtree_state

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoabstract split dest and src
Liam R. Howlett [Thu, 21 Aug 2025 20:30:24 +0000 (16:30 -0400)]
abstract split dest and src

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoabstract data calc from mas_wr_spanning_rebalance()
Liam R. Howlett [Thu, 21 Aug 2025 20:21:57 +0000 (16:21 -0400)]
abstract data calc from mas_wr_spanning_rebalance()

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agoruns through
Liam R. Howlett [Thu, 21 Aug 2025 19:28:39 +0000 (15:28 -0400)]
runs through

probably an issue with the end slot checking in mas_wr_spanning_rebalance()
Probably an issue ith the split calculation for 3 nodes

But I'll kick myself later when I didn't take the time to fix them now.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agobroken progress
Liam R. Howlett [Thu, 21 Aug 2025 19:04:08 +0000 (15:04 -0400)]
broken progress

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agomaple_tree: Make ma_wr_states reliable for reuse in spanning store
Liam R. Howlett [Wed, 20 Aug 2025 16:34:50 +0000 (12:34 -0400)]
maple_tree: Make ma_wr_states reliable for reuse in spanning store

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agobroken count
Liam R. Howlett [Tue, 19 Aug 2025 15:06:04 +0000 (11:06 -0400)]
broken count

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agomaple_tree: inline mas_spanning_rebalance() into mas_wr_spanning_rebalance()
Liam R. Howlett [Tue, 19 Aug 2025 14:11:39 +0000 (10:11 -0400)]
maple_tree: inline mas_spanning_rebalance() into mas_wr_spanning_rebalance()

Copy the contents of mas_spanning_rebalance() into
mas_wr_spanning_rebalance(), in preparation of removing initial big node
use.

No functional changes intended.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agomaple_tree: Remove unnecessary assignment of orig_l index
Liam R. Howlett [Tue, 19 Aug 2025 14:09:28 +0000 (10:09 -0400)]
maple_tree: Remove unnecessary assignment of orig_l index

The index value is already a copy of the maple state so there is no need
to set it again.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agomaple_tree: Extract use of big node from mas_wr_spanning_store()
Liam R. Howlett [Tue, 19 Aug 2025 14:08:08 +0000 (10:08 -0400)]
maple_tree: Extract use of big node from mas_wr_spanning_store()

Isolate big node to use in its own function.

No functional changes intended.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agomaple_tree: Move mas_spanning_rebalance loop to function
Liam R. Howlett [Tue, 19 Aug 2025 13:55:58 +0000 (09:55 -0400)]
maple_tree: Move mas_spanning_rebalance loop to function

Move the loop over the tree levels to its own function.

No intended functional changes.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
2 months agodrivers/base: move memory_block_add_nid() into the caller
Hannes Reinecke [Tue, 29 Jul 2025 06:46:36 +0000 (08:46 +0200)]
drivers/base: move memory_block_add_nid() into the caller

Now the node id only needs to be set for early memory, so move
memory_block_add_nid() into the caller and rename it into
memory_block_add_nid_early().  This allows us to further simplify the code
by dropping the 'context' argument to
do_register_memory_block_under_node().

Link: https://lkml.kernel.org/r/20250729064637.51662-4-hare@kernel.org
Suggested-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Hannes Reinecke <hare@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Donet Tom <donettom@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm/memory_hotplug: activate node before adding new memory blocks
Hannes Reinecke [Tue, 29 Jul 2025 06:46:35 +0000 (08:46 +0200)]
mm/memory_hotplug: activate node before adding new memory blocks

The sysfs attributes for memory blocks require the node ID to be set and
initialized, so move the node activation before adding new memory blocks.
This also has the nice side effect that the BUG_ON() can be converted into
a WARN_ON() as we now can handle registration errors.

Link: https://lkml.kernel.org/r/20250729064637.51662-3-hare@kernel.org
Fixes: b9ff036082cd ("mm/memory_hotplug.c: make add_memory_resource use __try_online_node")
Signed-off-by: Hannes Reinecke <hare@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Donet Tom <donettom@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agodrivers/base/memory: add node id parameter to add_memory_block()
Hannes Reinecke [Tue, 29 Jul 2025 06:46:34 +0000 (08:46 +0200)]
drivers/base/memory: add node id parameter to add_memory_block()

We have some udev rules trying to read the sysfs attribute 'valid_zones'
during an memory 'add' event, causing a crash in zone_for_pfn_range().
Debugging found that mem->nid was set to NUMA_NO_NODE, which crashed in
NODE_DATA(nid).  Further analysis revealed that we're running into a race
with udev event processing: add_memory_resource() has this function calls:

1) __try_online_node()
2) arch_add_memory()
3) create_memory_block_devices()
  -> calls device_register() -> memory 'add' event
4) node_set_online()/__register_one_node()
  -> calls device_register() -> node 'add' event
5) register_memory_blocks_under_node()
  -> sets mem->nid

Which, to the uninitated, is ... weird ...

Why do we try to online the node in 1), but only register the node in 4)
_after_ we have created the memory blocks in 3) ?  And why do we set the
'nid' value in 5), when the uevent (which might need to see the correct
'nid' value) is sent out in 3) ?  There must be a reason, I'm sure ...

So here's a small patchset to fixup uevent ordering.  The first patch adds
a 'nid' parameter to add_memory_blocks() (to avoid mem->nid being
initialized with NUMA_NO_NODE), and the second patch reshuffles the code
in add_memory_resource() to fully initialize the node prior to calling
create_memory_block_devices() so that the node is valid at that time and
uevent processing will see correct values in sysfs.

This patch (of 3):

Add a 'nid' parameter to add_memory_block() to initialize the memory block
with the correct node id.

Link: https://lkml.kernel.org/r/20250729064637.51662-1-hare@kernel.org
Link: https://lkml.kernel.org/r/20250729064637.51662-2-hare@kernel.org
Signed-off-by: Hannes Reinecke <hare@kernel.org>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Donet Tom <donettom@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agompage: convert do_mpage_readpage() to return int type
Chi Zhiling [Tue, 12 Aug 2025 07:22:25 +0000 (15:22 +0800)]
mpage: convert do_mpage_readpage() to return int type

The return value of do_mpage_readpage() is arg->bio, which is already set
in the arg structure.  Returning it again is redundant.

This patch changes the return type to int and always returns 0 since the
caller does not care about the return value.

Link: https://lkml.kernel.org/r/20250812072225.181798-3-chizhiling@163.com
Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Sungjong Seo <sj1557.seo@samsung.com>
Cc: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agompage: terminate read-ahead on read error
Chi Zhiling [Tue, 12 Aug 2025 07:22:23 +0000 (15:22 +0800)]
mpage: terminate read-ahead on read error

For exFAT filesystems with 4MB read_ahead_size, removing the storage
device during read operations can delay EIO error reporting by several
minutes.  This occurs because the read-ahead implementation in mpage
doesn't handle errors.

Another reason for the delay is that the filesystem requires metadata to
issue file read request.  When the storage device is removed, the metadata
buffers are invalidated, causing mpage to repeatedly attempt to fetch
metadata during each get_block call.

The original purpose of this patch is terminate read ahead when we fail to
get metadata, to make the patch more generic, implement it by checking
folio status, instead of checking the return of get_block().

Link: https://lkml.kernel.org/r/20250812072225.181798-1-chizhiling@163.com
Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: Sungjong Seo <sj1557.seo@samsung.com>
Cc: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm/filemap: Skip non-uptodate folio if there are available folios
Chi Zhiling [Mon, 28 Jul 2025 08:39:52 +0000 (16:39 +0800)]
mm/filemap: Skip non-uptodate folio if there are available folios

When reading data exceeding the maximum IO size, the operation is split
into multiple IO requests, but the data isn't immediately copied to
userspace after each IO completion.

For example, when reading 2560k data from a device with 1280k maximum IO
size, the following sequence occurs:

1. read 1280k
2. copy 41 pages and issue read ahead for next 1280k
3. copy 31 pages to user buffer
4. wait the next 1280k
5. copy 8 pages to user buffer
6. copy 20 folios(64k) to user buffer

The 8 pages in step 5 are copied after the second 1280k completes(step 4)
due to waiting for a non-uptodate folio in filemap_update_page.  We can
copy the 8 pages before the second 1280k completes(step 4) to reduce the
latency of this read operation.

After applying the patch, these 8 pages will be copied before the next IO
completes:

1. read 1280k
2. copy 41 pages and issue read ahead for next 1280k
3. copy 31 pages to user buffer
4. copy 8 pages to user buffer
5. wait the next 1280k
6. copy 20 folios(64k) to user buffer

This patch drops a setting of IOCB_NOWAIT for AIO, which is fine because
filemap_read will set it again for AIO.

The final solution provided by Matthew Wilcox:
Link: https://lore.kernel.org/linux-fsdevel/aIDy076Sxt544qja@casper.infradead.org/
Link: https://lkml.kernel.org/r/20250728083952.75518-3-chizhiling@163.com
Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm/filemap: do not use is_partially_uptodate for entire folio
Chi Zhiling [Mon, 28 Jul 2025 08:39:51 +0000 (16:39 +0800)]
mm/filemap: do not use is_partially_uptodate for entire folio

Patch series "Tiny optimization for large read operations".

This series contains two patches,

1. Skip calling is_partially_uptodate for entire folio to save time, I
   have reviewed the mpage and iomap implementations and didn't spot any
   issues, but this change likely needs more thorough review.

2. Skip calling filemap_uptodate if there are ready folios in the
   batch, This might save a few milliseconds in practice, but I didn't
   observe measurable improvements in my tests.

This patch (of 2):

When a folio is marked as non-uptodate, it means the folio contains some
non-uptodate data.  Therefore, calling is_partially_uptodate() to recheck
the entire folio is redundant.

If all data in a folio is actually up-to-date but the folio lacks the
uptodate flag, it will still be treated as non-uptodate in many other
places.  Thus, there should be no special case handling for filemap.

Link: https://lkml.kernel.org/r/20250728083952.75518-1-chizhiling@163.com
Link: https://lkml.kernel.org/r/20250728083952.75518-2-chizhiling@163.com
Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm/rmap: use folio_large_nr_pages() when we are sure it is a large folio
Wei Yang [Sun, 17 Aug 2025 03:26:47 +0000 (03:26 +0000)]
mm/rmap: use folio_large_nr_pages() when we are sure it is a large folio

Non-large folio is handled at the beginning, so it is a large folio for
sure.

Use folio_large_nr_pages() here like elsewhere.

Link: https://lkml.kernel.org/r/20250817032647.29147-3-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Harry Yoo <harry.yoo@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm/rmap: not necessary to mask off FOLIO_PAGES_MAPPED
Wei Yang [Sun, 17 Aug 2025 03:26:46 +0000 (03:26 +0000)]
mm/rmap: not necessary to mask off FOLIO_PAGES_MAPPED

At this point, we are in an if branch conditional on (nr <
ENTIRELY_MAPPED), and FOLIO_PAGES_MAPPED is equal to (ENTIRELY_MAPPED -
1).  This means the upper bits are already cleared.

It is not necessary to mask it off.

Link: https://lkml.kernel.org/r/20250817032647.29147-2-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Harry Yoo <harry.yoo@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agoselftests/mm/uffd: refactor non-composite global vars into struct
Ujwal Kundur [Sun, 17 Aug 2025 06:52:11 +0000 (12:22 +0530)]
selftests/mm/uffd: refactor non-composite global vars into struct

Refactor macros and non-composite global variable definitions into a
struct that is defined at the start of a test and is passed around
instead of relying on global vars.

Link: https://lkml.kernel.org/r/20250817065211.855-1-ujwal.kundur@gmail.com
Signed-off-by: Ujwal Kundur <ujwal.kundur@gmail.com>
Acked-by: Peter Xu <peterx@redhat.com>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm/damon/tests/core-kunit: add damos_commit_filter test
Sang-Heon Jeon [Sun, 17 Aug 2025 02:13:48 +0000 (11:13 +0900)]
mm/damon/tests/core-kunit: add damos_commit_filter test

Add unit test to verify that damos_commmit_filter() change dest value
well.

Link: https://lkml.kernel.org/r/20250817021348.570692-1-ekffu200098@gmail.com
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Cc: Honggyu Kim <honggyu.kim@sk.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm: fix duplicate accounting of free pages in should_reclaim_retry()
liuqiqi [Tue, 12 Aug 2025 07:02:10 +0000 (15:02 +0800)]
mm: fix duplicate accounting of free pages in should_reclaim_retry()

In the zone_reclaimable_pages() function, if the page counts for
NR_ZONE_INACTIVE_FILE, NR_ZONE_ACTIVE_FILE, NR_ZONE_INACTIVE_ANON, and
NR_ZONE_ACTIVE_ANON are all zero, the function returns the number of free
pages as the result.

In this case, when should_reclaim_retry() calculates reclaimable pages, it
will inadvertently double-count the free pages in its accounting.

static inline bool
should_reclaim_retry(gfp_t gfp_mask, unsigned order,
                     struct alloc_context *ac, int alloc_flags,
                     bool did_some_progress, int *no_progress_loops)
{
        ...
                available = reclaimable = zone_reclaimable_pages(zone);
                available += zone_page_state_snapshot(zone, NR_FREE_PAGES);

Link: https://lkml.kernel.org/r/20250812070210.1624218-1-liuqiqi@kylinos.cn
Fixes: 6aaced5abd32 ("mm: vmscan: account for free pages to prevent infinite Loop in throttle_direct_reclaim()")
Signed-off-by: liuqiqi <liuqiqi@kylinos.cn>
Reviewed-by: Ye Liu <liuye@kylinos.cn>
Cc: David Hildenbrand <david@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm: add folio_is_pci_p2pdma()
Matthew Wilcox (Oracle) [Tue, 5 Aug 2025 17:23:01 +0000 (18:23 +0100)]
mm: add folio_is_pci_p2pdma()

Reimplement is_pci_p2pdma_page() in terms of folio_is_pci_p2pdma().  Moves
the page_folio() call from inside page_pgmap() to is_pci_p2pdma_page().
This removes a page_folio() call from try_grab_folio() which already has a
folio and can pass it in.

Link: https://lkml.kernel.org/r/20250805172307.1302730-12-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm: reimplement folio_is_fsdax()
Matthew Wilcox (Oracle) [Tue, 5 Aug 2025 17:23:00 +0000 (18:23 +0100)]
mm: reimplement folio_is_fsdax()

For callers of folio_is_fsdax(), we save a folio->page->folio conversion.
Callers of is_fsdax_page() simply move the conversion of page->folio from
the implementation of page_pgmap() to is_fsdax_page().

Link: https://lkml.kernel.org/r/20250805172307.1302730-11-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm: reimplement folio_is_device_coherent()
Matthew Wilcox (Oracle) [Tue, 5 Aug 2025 17:22:59 +0000 (18:22 +0100)]
mm: reimplement folio_is_device_coherent()

For callers of folio_is_device_coherent(), we save a folio->page->folio
conversion.  Callers of is_device_coherent_page() simply move the
conversion of page->folio from the implementation of page_pgmap() to
is_device_coherent_page().

Link: https://lkml.kernel.org/r/20250805172307.1302730-10-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2 months agomm: reimplement folio_is_device_private()
Matthew Wilcox (Oracle) [Tue, 5 Aug 2025 17:22:58 +0000 (18:22 +0100)]
mm: reimplement folio_is_device_private()

For callers of folio_is_device_private(), we save a folio->page->folio
conversion.  Callers of is_device_private_page() simply move the
conversion of page->folio from the implementation of page_pgmap() to
is_device_private_page().

Link: https://lkml.kernel.org/r/20250805172307.1302730-9-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>