]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
4 years agomaple_tree: mas_next_node/mas_prev_node restarts added on dead node detection.
Liam R. Howlett [Sat, 27 Jul 2019 00:31:30 +0000 (20:31 -0400)]
maple_tree: mas_next_node/mas_prev_node restarts added on dead node detection.

Also required reordering some functions.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add basic store support.
Liam R. Howlett [Fri, 14 Jun 2019 12:37:34 +0000 (08:37 -0400)]
maple_tree: Add basic store support.

This store operation builds a new tree.  This was done to avoid creating
an invalid b-tree (not the same height from all leaves to head).

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Change erase return to 0 on success.
Liam R. Howlett [Wed, 22 May 2019 16:40:26 +0000 (12:40 -0400)]
maple_tree: Change erase return to 0 on success.

Count isn't used, so return 0 for success.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add reverse walk.
Liam R. Howlett [Wed, 22 May 2019 12:50:15 +0000 (08:50 -0400)]
maple_tree: Add reverse walk.

Search for a hole of a given size at the highest address.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix range checking on skip_node
Liam R. Howlett [Tue, 14 May 2019 17:49:12 +0000 (13:49 -0400)]
maple_tree: Fix range checking on skip_node

When skipping a node, it is only valid to break out of the loop if slot
+ 1 is valid.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix forward searching for gaps.
Liam R. Howlett [Wed, 24 Apr 2019 17:52:00 +0000 (13:52 -0400)]
maple_tree: Fix forward searching for gaps.

There was an off-by-one issue with the gap calculation as it is
exclusive - inclusive.

Fix the ascend search in maple_awalk using the wrong parent slot.

Return -EBUSY correctly when a failure occurs.

Fix node splitting when there is no such thing as dense.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_dump: Pad better
Matthew Wilcox [Wed, 24 Apr 2019 17:03:27 +0000 (13:03 -0400)]
maple_dump: Pad better

I think this works out better visually than the previous effort.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
4 years agomaple_dump: Pad to indicate depth
Matthew Wilcox [Tue, 23 Apr 2019 19:44:48 +0000 (15:44 -0400)]
maple_dump: Pad to indicate depth

Not entirely sure if this is the best way to indicate depth; let's
try it for a bit and see how confused we get.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
4 years agomaple_tree: Disable dense nodes.
Liam R. Howlett [Tue, 23 Apr 2019 19:22:52 +0000 (15:22 -0400)]
maple_tree: Disable dense nodes.

Disable dense nodes to avoid split issues.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: messy test output
Liam R. Howlett [Tue, 2 Apr 2019 14:59:15 +0000 (10:59 -0400)]
maple_tree: messy test output

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Remove early exit on tests
Liam R. Howlett [Thu, 28 Mar 2019 17:59:33 +0000 (13:59 -0400)]
maple_tree: Remove early exit on tests

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add awalk for walking allocation trees for gaps.
Liam R. Howlett [Thu, 28 Mar 2019 16:24:09 +0000 (12:24 -0400)]
maple_tree: Add awalk for walking allocation trees for gaps.

Adds mtree_alloc_range to allocate a range.  Some basic tests.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add maple_tree alloc support for gaps.
Liam R. Howlett [Fri, 15 Mar 2019 20:01:22 +0000 (16:01 -0400)]
maple_tree: Add maple_tree alloc support for gaps.

Start populating gaps with values
Remove the maple_aleaf_64 type and use regular maple_leaf_64.
Rework pivot calculations to be more straight forward.
Don't use dense nodes in the root node to avoid having a dense node as
the right-most node.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: typedef maple_enode for encoded node.
Liam R. Howlett [Mon, 18 Mar 2019 19:57:30 +0000 (15:57 -0400)]
maple_tree: typedef maple_enode for encoded node.

Use the compiler to check if an encoded node or a regular node is used

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: typedef parent node to maple_pnode
Liam R. Howlett [Mon, 18 Mar 2019 17:51:34 +0000 (13:51 -0400)]
maple_tree: typedef parent node to maple_pnode

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Use encoded node for getting rcu slot in ma_encoded_parent
Liam R. Howlett [Fri, 15 Mar 2019 20:26:39 +0000 (16:26 -0400)]
maple_tree: Use encoded node for getting rcu slot in ma_encoded_parent

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add initial maple_arange_64 node support.
Liam R. Howlett [Tue, 12 Mar 2019 18:52:59 +0000 (14:52 -0400)]
maple_tree: Add initial maple_arange_64 node support.

maple_arange_64 is for allocation ranges which need to track gaps in
subtrees.  This commit does not address tracking the gaps.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Fix range checking.
Liam R. Howlett [Thu, 14 Mar 2019 16:53:16 +0000 (12:53 -0400)]
test_maple_tree: Fix range checking.

Checking a range was not using the correct number range.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix range add to empty tree.
Liam R. Howlett [Wed, 13 Mar 2019 15:56:15 +0000 (11:56 -0400)]
maple_tree: Fix range add to empty tree.

When adding to an empty tree, use the encoded node to set the pivot.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Rework internal walk.
Liam R. Howlett [Tue, 12 Mar 2019 18:52:18 +0000 (14:52 -0400)]
maple_tree: Rework internal walk.

Reduce possible calls to get an rcu entry.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoma_xa_benchmark: Update time calculations
Liam R. Howlett [Fri, 8 Mar 2019 18:54:13 +0000 (13:54 -0500)]
ma_xa_benchmark: Update time calculations

Time calculations were prone to overflow because seconds were not
included.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix double free error.
Liam R. Howlett [Fri, 8 Mar 2019 18:53:10 +0000 (13:53 -0500)]
maple_tree: Fix double free error.

There was a double free which raced with the rcu free so it was not
detected all the time.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple: Fix _mas_walk return & clean up ma_insert root expand logic
Liam R. Howlett [Thu, 7 Mar 2019 15:18:29 +0000 (10:18 -0500)]
maple: Fix _mas_walk return & clean up ma_insert root expand logic

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple: Fix off by one error when walking.
Liam R. Howlett [Thu, 7 Mar 2019 14:47:48 +0000 (09:47 -0500)]
maple: Fix off by one error when walking.

When going to the next slot, the minimum value is actually pivot + 1 and
not just the pivot value.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Optimize _mas_walk
Liam R. Howlett [Sun, 17 Feb 2019 22:01:21 +0000 (17:01 -0500)]
maple_tree: Optimize _mas_walk

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Rework walk.
Liam R. Howlett [Fri, 15 Feb 2019 21:27:03 +0000 (16:27 -0500)]
maple_tree: Rework walk.

Make walk more efficient by avoiding duplicate fetches of slot and pivots.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Make walk faster.
Liam R. Howlett [Fri, 15 Feb 2019 20:58:50 +0000 (15:58 -0500)]
maple_tree: Make walk faster.

Avoid looking up duplicate information.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoma_xa_benchmark: Fix percentage calculation for time.
Liam R. Howlett [Fri, 15 Feb 2019 20:45:42 +0000 (15:45 -0500)]
ma_xa_benchmark: Fix percentage calculation for time.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Efficiencies
Liam R. Howlett [Fri, 15 Feb 2019 20:43:48 +0000 (15:43 -0500)]
maple_tree: Efficiencies

Remove unneeded code.
Fix splitting from the back of a node.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Dense node support & nulls in tree.
Liam R. Howlett [Wed, 13 Feb 2019 16:12:02 +0000 (11:12 -0500)]
maple_tree: Dense node support & nulls in tree.

Support dense node types.  The reduces the space required for sequential
indexes a lot.
Splitting now decides between usign the parent type and the dense node
type for left/right independently.
Fixes had to be made to pivot lookups.
A few static inline additions to speed things up.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Performance enhancements.
Liam R. Howlett [Tue, 12 Feb 2019 21:01:13 +0000 (16:01 -0500)]
maple_tree:  Performance enhancements.

Start using slot 0 on splits.
Fix missing breaks on set of slots.
Calc node type only once during certain loops

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Make functions node-type generic.
Liam R. Howlett [Thu, 7 Feb 2019 19:34:49 +0000 (14:34 -0500)]
maple_tree: Make functions node-type generic.

Move mt_max outside of debug and add mt_slots
Create mt_slots for enum to slot size mapping.
Rename ma_cp_data_64 to ma_split_data
Drop extra calls in split.
Create calls to get/set pivots & slots.
Rework all functions to use generic calls.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoma_xa_benchmark: Use user time. add rcu barrier before size calc.
Liam R. Howlett [Wed, 6 Feb 2019 20:23:25 +0000 (15:23 -0500)]
ma_xa_benchmark: Use user time. add rcu barrier before size calc.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoma_xa_benchmark: Initial push
Liam R. Howlett [Tue, 5 Feb 2019 17:30:13 +0000 (12:30 -0500)]
ma_xa_benchmark: Initial push

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: remove duplicate function.
Liam R. Howlett [Tue, 5 Feb 2019 15:23:16 +0000 (10:23 -0500)]
maple_tree: remove duplicate function.

When adding a check for reserved entries, I hadn't noticed it already
existed.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Fix comments & add more tests.
Liam R. Howlett [Fri, 1 Feb 2019 19:22:25 +0000 (14:22 -0500)]
test_maple_tree: Fix comments & add more tests.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix split & insert to use last slot.
Liam R. Howlett [Fri, 1 Feb 2019 19:21:33 +0000 (14:21 -0500)]
maple_tree: Fix split & insert to use last slot.

The last slot was revealed to be NULL always.  Fix this by changing the
the end calculations and to ensure it is okay to use the final slot.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Drop depth from split operation.
Liam R. Howlett [Fri, 1 Feb 2019 18:09:56 +0000 (13:09 -0500)]
maple_tree: Drop depth from split operation.

It is not used.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix root bit & parent type.
Liam R. Howlett [Fri, 1 Feb 2019 18:00:47 +0000 (13:00 -0500)]
maple_tree: Fix root bit & parent type.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: fix goto lables in ma_insert
Liam R. Howlett [Fri, 1 Feb 2019 00:30:44 +0000 (19:30 -0500)]
maple_tree: fix goto lables in ma_insert

Fix the order of goto labels and set the error correct if using exists.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add root expand to node if the single entry ends in 10.
Liam R. Howlett [Fri, 1 Feb 2019 00:28:50 +0000 (19:28 -0500)]
maple_tree: Add root expand to node if the single entry ends in 10.

As requested by page cache.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Change mask calc for mt_parent_type
Liam R. Howlett [Fri, 1 Feb 2019 00:28:10 +0000 (19:28 -0500)]
maple_tree: Change mask calc for mt_parent_type

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Remove depth from ma_split.
Liam R. Howlett [Thu, 31 Jan 2019 16:18:46 +0000 (11:18 -0500)]
maple_tree: Remove depth from ma_split.

the depth is no longer use, so drop it.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoThoughts: Add table of bits in the parent.
Liam R. Howlett [Thu, 31 Jan 2019 16:15:05 +0000 (11:15 -0500)]
Thoughts: Add table of bits in the parent.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix parent definitions & fallout from ULONG_MAX ending.
Liam R. Howlett [Thu, 31 Jan 2019 16:11:13 +0000 (11:11 -0500)]
maple_tree: Fix parent definitions & fallout from ULONG_MAX ending.

coalesce needed to be updated for ULONG_MAX endings.
ma_copy needed to check for ULONG_MAX ending.
ma_encoded_parent no longer updates the ma_state limits.
adopt_children needed the encoded node passed in for the node type to
encode in the parent of the children.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Add seqential test for adding 1000 entries
Liam R. Howlett [Thu, 31 Jan 2019 15:53:33 +0000 (10:53 -0500)]
test_maple_tree: Add seqential test for adding 1000 entries

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add comment about encode parent.
Liam R. Howlett [Wed, 30 Jan 2019 14:38:56 +0000 (09:38 -0500)]
maple_tree: Add comment about encode parent.

function name seems to lack description

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Move mas_update_limits
Liam R. Howlett [Tue, 29 Jan 2019 20:53:03 +0000 (15:53 -0500)]
maple_tree: Move mas_update_limits

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Small cleanup of code and comments
Liam R. Howlett [Tue, 29 Jan 2019 20:28:36 +0000 (15:28 -0500)]
maple_tree: Small cleanup of code and comments

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix error in splitting on the right side
Liam R. Howlett [Tue, 29 Jan 2019 20:06:00 +0000 (15:06 -0500)]
maple_tree: Fix error in splitting on the right side

When splitting on the right side, there were a number of logical
errors:
1. Finding the parents type needed the parent to be encoded, so move the
logic to a location better suited to use the encoded node.
2. ma_copy had an incorrect range (off by one).
3. mt_replace was not using the encoded node to find the parent's slot.
This would always return zero.
4. ma_link had a potential overflow in the pivot.
5. The ma_state's min/max was not being updated and so the pivots were
not always correct when using the min/max.
6. The data end detection needed to be updated to also check for
ULONG_MAX.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: port nomem thread race test.
Liam R. Howlett [Mon, 28 Jan 2019 19:08:29 +0000 (14:08 -0500)]
test_maple_tree: port nomem thread race test.

Test to see that allocations work when two threads are racing.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Change return type of ma_insert.
Liam R. Howlett [Mon, 28 Jan 2019 19:07:04 +0000 (14:07 -0500)]
maple_tree: Change return type of ma_insert.

ma_insert was returning a pointer in the old API.  This is no longer
needed.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Re-implement old allocation tests for new API.
Liam R. Howlett [Mon, 28 Jan 2019 18:30:15 +0000 (13:30 -0500)]
test_maple_tree: Re-implement old allocation tests for new API.

Rewrite the allocation tests for maple2 rewrite.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotesting: Fix bug in allocation tests for radix-tree linux.
Liam R. Howlett [Mon, 28 Jan 2019 18:29:01 +0000 (13:29 -0500)]
testing: Fix bug in allocation tests for radix-tree linux.

When initializing kmem_cache for testing, ensure non_kernel is
initialized to zero.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Fix compile warning
Liam R. Howlett [Mon, 28 Jan 2019 15:21:11 +0000 (10:21 -0500)]
test_maple_tree: Fix compile warning

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Clean up erase function.
Liam R. Howlett [Fri, 25 Jan 2019 21:03:21 +0000 (16:03 -0500)]
maple_tree: Clean up erase function.

The node type is set during the partial copy of data operation now.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Remove enc_full and just use mas->node.
Liam R. Howlett [Fri, 25 Jan 2019 20:49:28 +0000 (15:49 -0500)]
maple_tree: Remove enc_full and just use mas->node.

No need for this variable in mas_split.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Load safe root to mas->node in encoded_parent
Liam R. Howlett [Fri, 25 Jan 2019 20:43:38 +0000 (15:43 -0500)]
maple_tree: Load safe root to mas->node in encoded_parent

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Code clean up.
Liam R. Howlett [Fri, 25 Jan 2019 20:34:15 +0000 (15:34 -0500)]
maple_tree: Code clean up.

Drop unused variables & a fuction left from development of split

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix dump debug code when the last slot is null.
Liam R. Howlett [Tue, 22 Jan 2019 15:14:38 +0000 (10:14 -0500)]
maple_tree: Fix dump debug code when the last slot is null.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_node: Fix comments
Liam R. Howlett [Fri, 18 Jan 2019 19:46:54 +0000 (14:46 -0500)]
maple_node: Fix comments

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Split support
Liam R. Howlett [Fri, 18 Jan 2019 15:55:38 +0000 (10:55 -0500)]
maple_tree: Split support

Initial split support.  Walks up the tree splitting as necessary to
support the addition of a node.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Rearrange _ma_insert for appends.
Liam R. Howlett [Tue, 15 Jan 2019 16:17:00 +0000 (11:17 -0500)]
maple_tree: Rearrange _ma_insert for appends.

Reorder and make _ma_insert append safe and prepare for split.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Refactor coalesce into a separate function.
Liam R. Howlett [Fri, 11 Jan 2019 15:46:29 +0000 (10:46 -0500)]
maple_tree: Refactor coalesce into a separate function.

Reworked logic to have a bit of a cleaner looking function.  Supports
full nodes now as well.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Avoid allocating a node in coalescing until necessary
Liam R. Howlett [Fri, 11 Jan 2019 02:01:25 +0000 (21:01 -0500)]
maple_tree: Avoid allocating a node in coalescing until necessary

When looping through a node, don't create a new node if there is no need
to do so.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Avoid coalescing on insert if it is not needed.
Liam R. Howlett [Thu, 10 Jan 2019 20:18:01 +0000 (15:18 -0500)]
maple_tree: Avoid coalescing on insert if it is not needed.

On insert, iterate over the pivots looking for matching ones to
determine if slots need to be coalesced.
Erase always needs to coalesce, so don't check there.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: whitespace fix
Liam R. Howlett [Thu, 10 Jan 2019 19:57:47 +0000 (14:57 -0500)]
maple_tree: whitespace fix

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agotest_maple_tree: Add new function to allow __GFP_DIRECT_RECLAIM gfp for
Liam R. Howlett [Thu, 10 Jan 2019 19:06:51 +0000 (14:06 -0500)]
test_maple_tree: Add new function to allow __GFP_DIRECT_RECLAIM gfp for
a given number of times.

Set a variable that allows reclaims to occur for a specific count for
testing.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Change ma_coalesce to return the number of slots removed.
Liam R. Howlett [Thu, 10 Jan 2019 19:05:43 +0000 (14:05 -0500)]
maple_tree: Change ma_coalesce to return the number of slots removed.

Set ma->node to the new node, so save the previous node before calling
the function.  Also fix an off-by-one error in ma_coalesce.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoCorrected typo
Liam R. Howlett [Thu, 10 Jan 2019 18:49:06 +0000 (13:49 -0500)]
Corrected typo

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add erase support.
Liam R. Howlett [Thu, 10 Jan 2019 16:08:14 +0000 (11:08 -0500)]
maple_tree: Add erase support.

Refactor replacing a node in a tree to its own function and use that
with the erase and insert functions.

Erase NULLs the range in which the index resides and coalesces adjacent
NULLs if allocation succeeds.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix several off-by-one errors.
Liam R. Howlett [Thu, 10 Jan 2019 16:06:23 +0000 (11:06 -0500)]
maple_tree: Fix several off-by-one errors.

When counting through the slots/pivots, the pivots overflow before the
slots which is an area of confusion sometimes.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Rework walking the tree to combine insert/walk/erase
Liam R. Howlett [Wed, 9 Jan 2019 20:11:15 +0000 (15:11 -0500)]
maple_tree: Rework walking the tree to combine insert/walk/erase
functions.

This turned out to be a huge deal with many issues resolved for the
following of Thoughts:

1. Nodes can use the last 0x7F bits of the address, so clear them and
such.
2. Root needs to have bit 1 (0x2) set, so be safe around that.
3. mas->node should be encoded (except root needs to remove bit 1 to
avoid being seen as an error).
4. xa_is_node no longer works, so remove BUG_ONs.  Take care that we
know we have a value when we have a slot & an leaf node in mas->node.
5. Store slots in the same place as the alloc requests as their uses do
not overlap.
6. mas_start needs to return a safe root instead of making its own node.
7. Insert was basically rewritten
8. Verify that we are no inserting reserved values
9. Change testcases to not try to insert reserved values.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix potential race condition in _ma_insert
Liam R. Howlett [Mon, 7 Jan 2019 19:45:10 +0000 (14:45 -0500)]
maple_tree: Fix potential race condition in _ma_insert

The pivots protect readers from reading invalid data.  Without a wmb
between overwriting the end pivot (of zero), there is a potential that
the writes could be reordered and a race condition would exist between
updating both values and a reader interleaving those writes.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add insert/append operation.
Liam R. Howlett [Mon, 7 Jan 2019 17:46:05 +0000 (12:46 -0500)]
maple_tree: Add insert/append operation.

Check for NULL runs by looking for duplicate pivots and coalesce them
into a single entry.  Append and insert into a new node, then replace
the old node and adopt the children.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Fix data_end calculation and root expansion.
Liam R. Howlett [Thu, 3 Jan 2019 18:30:57 +0000 (13:30 -0500)]
maple_tree: Fix data_end calculation and root expansion.

Root expansion needs to set the pivot to the empty value if there is no
zero for the append to function correctly.

In append, we know the data end will always be at least 1, so take two
off the idx when checking the previous pivot value (since we also add 1
to the end for the new termination).

Append will need to be altered to cover off the overflow possibility in
the future.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: clean up swithc statement and remove null parent assignment
Liam R. Howlett [Thu, 3 Jan 2019 16:42:27 +0000 (11:42 -0500)]
maple_tree: clean up swithc statement and remove null parent assignment

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agoMore Thoughts
Matthew Wilcox [Wed, 2 Jan 2019 21:18:41 +0000 (16:18 -0500)]
More Thoughts

Mostly relating to auxiliary data

Signed-off-by: Matthew Wilcox <willy@infradead.org>
4 years agomaple_tree: Implement destroy.
Liam R. Howlett [Thu, 3 Jan 2019 15:34:32 +0000 (10:34 -0500)]
maple_tree: Implement destroy.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Implement expanding root.
Liam R. Howlett [Wed, 2 Jan 2019 18:31:54 +0000 (13:31 -0500)]
maple_tree: Implement expanding root.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add kmem_cache
Matthew Wilcox [Mon, 24 Dec 2018 17:31:00 +0000 (12:31 -0500)]
maple_tree: Add kmem_cache

Allocate nodes from a kmem cache, making the necessary changes to the
slab emulation to support alignment.  Free nodes through RCU.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
4 years agomaple_tree: Change my thoughts
Matthew Wilcox [Mon, 24 Dec 2018 15:27:45 +0000 (10:27 -0500)]
maple_tree: Change my thoughts

Reorganise the Thoughts file to bring it to some kind of order, and
change the tree dumping code accordingly.  It only supports three kinds
of node so far: leaf_64, range_64 and dense.  But it does now support
user pointers that are only 2-byte aligned.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
4 years agoAdd some notes
Matthew Wilcox [Fri, 21 Dec 2018 20:30:54 +0000 (15:30 -0500)]
Add some notes

Not for upstream, obviously

4 years agomaple_tree: Fix mt_dump
Matthew Wilcox [Thu, 20 Dec 2018 19:41:03 +0000 (14:41 -0500)]
maple_tree: Fix mt_dump

Conform to new definition of maple tree

Signed-off-by: Matthew Wilcox <willy@infradead.org>
4 years agomaple_tree: Fix compilation differently
Matthew Wilcox [Thu, 20 Dec 2018 02:28:39 +0000 (21:28 -0500)]
maple_tree: Fix compilation differently

Signed-off-by: Matthew Wilcox <willy@infradead.org>
4 years agomaple_tree: Testing framework and stubbed out maple_tree.c
Liam R. Howlett [Wed, 19 Dec 2018 20:43:14 +0000 (15:43 -0500)]
maple_tree: Testing framework and stubbed out maple_tree.c

Also fix some compile issues with header.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
4 years agomaple_tree: Add header file
Matthew Wilcox [Wed, 19 Dec 2018 19:40:16 +0000 (14:40 -0500)]
maple_tree: Add header file

Signed-off-by: Matthew Wilcox <willy@infradead.org>
4 years agoLinux 5.10
Linus Torvalds [Sun, 13 Dec 2020 22:41:30 +0000 (14:41 -0800)]
Linux 5.10

4 years agoMerge tag 'x86-urgent-2020-12-13' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 13 Dec 2020 19:31:19 +0000 (11:31 -0800)]
Merge tag 'x86-urgent-2020-12-13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fixes from Thomas Gleixner:
 "A set of x86 and membarrier fixes:

   - Correct a few problems in the x86 and the generic membarrier
     implementation. Small corrections for assumptions about visibility
     which have turned out not to be true.

   - Make the PAT bits for memory encryption correct vs 4K and 2M/1G
     page table entries as they are at a different location.

   - Fix a concurrency issue in the the local bandwidth readout of
     resource control leading to incorrect values

   - Fix the ordering of allocating a vector for an interrupt. The order
     missed to respect the provided cpumask when the first attempt of
     allocating node local in the mask fails. It then tries the node
     instead of trying the full provided mask first. This leads to
     erroneous error messages and breaking the (user) supplied affinity
     request. Reorder it.

   - Make the INT3 padding detection in optprobe work correctly"

* tag 'x86-urgent-2020-12-13' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/kprobes: Fix optprobe to detect INT3 padding correctly
  x86/apic/vector: Fix ordering in vector assignment
  x86/resctrl: Fix incorrect local bandwidth when mba_sc is enabled
  x86/mm/mem_encrypt: Fix definition of PMD_FLAGS_DEC_WP
  membarrier: Execute SYNC_CORE on the calling thread
  membarrier: Explicitly sync remote cores when SYNC_CORE is requested
  membarrier: Add an actual barrier before rseq_preempt()
  x86/membarrier: Get rid of a dubious optimization

4 years agoMerge tag 'block-5.10-2020-12-12' of git://git.kernel.dk/linux-block
Linus Torvalds [Sun, 13 Dec 2020 18:36:23 +0000 (10:36 -0800)]
Merge tag 'block-5.10-2020-12-12' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
 "This should be it for 5.10.

  Mike and Song looked into the warning case, and thankfully it appears
  the fix was pretty trivial - we can just change the md device chunk
  type to unsigned int to get rid of it. They cannot currently be < 0,
  and nobody is checking for that either.

  We're reverting the discard changes as the corruption reports came in
  very late, and there's just no time to attempt to deal with it at this
  point. Reverting the changes in question is the right call for 5.10"

* tag 'block-5.10-2020-12-12' of git://git.kernel.dk/linux-block:
  md: change mddev 'chunk_sectors' from int to unsigned
  Revert "md: add md_submit_discard_bio() for submitting discard bio"
  Revert "md/raid10: extend r10bio devs to raid disks"
  Revert "md/raid10: pull codes that wait for blocked dev into one function"
  Revert "md/raid10: improve raid10 discard request"
  Revert "md/raid10: improve discard request for far layout"
  Revert "dm raid: remove unnecessary discard limits for raid10"

4 years agoMerge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Linus Torvalds [Sat, 12 Dec 2020 20:57:12 +0000 (12:57 -0800)]
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "Five small fixes.  Four in drivers:

   - hisi_sas: fix internal queue timeout

   - be2iscsi: revert a prior fix causing problems

   - bnx2i: add missing dependency

   - storvsc: late arriving revert of a problem fix

  and one in the core.

  The core one is a minor change to stop paying attention to the busy
  count when returning out of resources because there's a race window
  where the queue might not restart due to missing returning I/O"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  Revert "scsi: storvsc: Validate length of incoming packet in storvsc_on_channel_callback()"
  scsi: hisi_sas: Select a suitable queue for internal I/Os
  scsi: core: Fix race between handling STS_RESOURCE and completion
  scsi: be2iscsi: Revert "Fix a theoretical leak in beiscsi_create_eqs()"
  scsi: bnx2i: Requires MMU

4 years agoMerge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
Linus Torvalds [Sat, 12 Dec 2020 20:47:46 +0000 (12:47 -0800)]
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c fix from Wolfram Sang:
 "Bugfix for the AT24 EEPROM driver"

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  misc: eeprom: at24: fix NVMEM name with custom AT24 device name

4 years agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Linus Torvalds [Sat, 12 Dec 2020 18:08:16 +0000 (10:08 -0800)]
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm fixes from Paolo Bonzini:
 "Bugfixes for ARM, x86 and tools"

* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
  tools/kvm_stat: Exempt time-based counters
  KVM: mmu: Fix SPTE encoding of MMIO generation upper half
  kvm: x86/mmu: Use cpuid to determine max gfn
  kvm: svm: de-allocate svm_cpu_data for all cpus in svm_cpu_uninit()
  selftests: kvm/set_memory_region_test: Fix race in move region test
  KVM: arm64: Add usage of stage 2 fault lookup level in user_mem_abort()
  KVM: arm64: Fix handling of merging tables into a block entry
  KVM: arm64: Fix memory leak on stage2 update of a valid PTE

4 years agoMerge tag 'for-linus-5.10c-rc8-tag' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 12 Dec 2020 18:02:03 +0000 (10:02 -0800)]
Merge tag 'for-linus-5.10c-rc8-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen fixes from Juergen Gross:
 "A short series fixing a regression introduced in 5.9 for running as
  Xen dom0 on a system with NVMe backed storage"

* tag 'for-linus-5.10c-rc8-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  xen: don't use page->lru for ZONE_DEVICE memory
  xen: add helpers for caching grant mapping pages

4 years agoMerge tag 'riscv-for-linus-5.10-rc8' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 12 Dec 2020 17:50:26 +0000 (09:50 -0800)]
Merge tag 'riscv-for-linus-5.10-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fix from Palmer Dabbelt:
 "Just one fix. It's nothing critical, just a randconfig that wasn't
  building. That said, it does seem pretty safe and is technically a
  regression so I'm sending it along for 5.10:

   - define get_cycles64() all the time, as it's used by most
     configurations"

* tag 'riscv-for-linus-5.10-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  RISC-V: Define get_cycles64() regardless of M-mode

4 years agoMerge tag 'io_uring-5.10-2020-12-11' of git://git.kernel.dk/linux-block
Linus Torvalds [Sat, 12 Dec 2020 17:45:01 +0000 (09:45 -0800)]
Merge tag 'io_uring-5.10-2020-12-11' of git://git.kernel.dk/linux-block

Pull io_uring fixes from Jens Axboe:
 "Two fixes in here, fixing issues introduced in this merge window"

* tag 'io_uring-5.10-2020-12-11' of git://git.kernel.dk/linux-block:
  io_uring: fix file leak on error path of io ctx creation
  io_uring: fix mis-seting personality's creds

4 years agoMerge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Linus Torvalds [Sat, 12 Dec 2020 17:41:33 +0000 (09:41 -0800)]
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input fixes from Dmitry Torokhov:

 - a fix for cm109 stomping on its own control URB if it tries to toggle
   buzzer immediately after userspace opens input device (found by
   syzcaller)

 - another fix for Raydium touchscreens that do not like splitting
   command transfers

 - quirks for i8042, soc_button_array, and goodix drivers to make them
   work better with certain hardware.

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: goodix - add upside-down quirk for Teclast X98 Pro tablet
  Input: cm109 - do not stomp on control URB
  Input: i8042 - add Acer laptops to the i8042 reset list
  Input: cros_ec_keyb - send 'scancodes' in addition to key events
  Input: soc_button_array - add Lenovo Yoga Tablet2 1051L to the dmi_use_low_level_irq list
  Input: raydium_ts_i2c - do not split tx transactions

4 years agomd: change mddev 'chunk_sectors' from int to unsigned
Mike Snitzer [Sat, 12 Dec 2020 16:55:37 +0000 (11:55 -0500)]
md: change mddev 'chunk_sectors' from int to unsigned

Commit e2782f560c29 ("Revert "dm raid: remove unnecessary discard
limits for raid10"") exposed compiler warnings introduced by commit
e0910c8e4f87 ("dm raid: fix discard limits for raid1 and raid10"):

In file included from ./include/linux/kernel.h:14,
                 from ./include/asm-generic/bug.h:20,
                 from ./arch/x86/include/asm/bug.h:93,
                 from ./include/linux/bug.h:5,
                 from ./include/linux/mmdebug.h:5,
                 from ./include/linux/gfp.h:5,
                 from ./include/linux/slab.h:15,
                 from drivers/md/dm-raid.c:8:
drivers/md/dm-raid.c: In function ‘raid_io_hints’:
./include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                            ^~
./include/linux/minmax.h:32:4: note: in expansion of macro ‘__typecheck’
   (__typecheck(x, y) && __no_side_effects(x, y))
    ^~~~~~~~~~~
./include/linux/minmax.h:42:24: note: in expansion of macro ‘__safe_cmp’
  __builtin_choose_expr(__safe_cmp(x, y), \
                        ^~~~~~~~~~
./include/linux/minmax.h:51:19: note: in expansion of macro ‘__careful_cmp’
 #define min(x, y) __careful_cmp(x, y, <)
                   ^~~~~~~~~~~~~
./include/linux/minmax.h:84:39: note: in expansion of macro ‘min’
  __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
                                       ^~~
drivers/md/dm-raid.c:3739:33: note: in expansion of macro ‘min_not_zero’
   limits->max_discard_sectors = min_not_zero(rs->md.chunk_sectors,
                                 ^~~~~~~~~~~~

Fix this by changing the chunk_sectors member of 'struct mddev' from
int to 'unsigned int' to match the type used for the 'chunk_sectors'
member of 'struct queue_limits'.  Various MD code still uses 'int' but
none of it appears to ever make use of signed int; and storing
positive signed int in unsigned is perfectly safe.

Reported-by: Song Liu <songliubraving@fb.com>
Fixes: e2782f560c29 ("Revert "dm raid: remove unnecessary discard limits for raid10"")
Fixes: e0910c8e4f87 ("dm raid: fix discard limits for raid1 and raid10")
Cc: stable@vger,kernel.org # e0910c8e4f87 was marked for stable@
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Reviewed-by: Song Liu <song@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
4 years agox86/kprobes: Fix optprobe to detect INT3 padding correctly
Masami Hiramatsu [Fri, 11 Dec 2020 07:04:17 +0000 (16:04 +0900)]
x86/kprobes: Fix optprobe to detect INT3 padding correctly

Commit

  7705dc855797 ("x86/vmlinux: Use INT3 instead of NOP for linker fill bytes")

changed the padding bytes between functions from NOP to INT3. However,
when optprobe decodes a target function it finds INT3 and gives up the
jump optimization.

Instead of giving up any INT3 detection, check whether the rest of the
bytes to the end of the function are INT3. If all of them are INT3,
those come from the linker. In that case, continue the optprobe jump
optimization.

 [ bp: Massage commit message. ]

Fixes: 7705dc855797 ("x86/vmlinux: Use INT3 instead of NOP for linker fill bytes")
Reported-by: Adam Zabrocki <pi3@pi3.com.pl>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/160767025681.3880685.16021570341428835411.stgit@devnote2
4 years agoInput: goodix - add upside-down quirk for Teclast X98 Pro tablet
Simon Beginn [Sat, 12 Dec 2020 00:17:32 +0000 (16:17 -0800)]
Input: goodix - add upside-down quirk for Teclast X98 Pro tablet

The touchscreen on the Teclast x98 Pro is also mounted upside-down in
relation to the display orientation.

Signed-off-by: Simon Beginn <linux@simonmicro.de>
Signed-off-by: Bastien Nocera <hadess@hadess.net>
Link: https://lore.kernel.org/r/20201117004253.27A5A27EFD@localhost
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>