* [PATCH v2 0/3] cleanup maple_alloc related functions
@ 2024-10-15 12:07 Wei Yang
2024-10-15 12:07 ` [PATCH v2 1/3] maple_tree: clear request_count for new allocated one Wei Yang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Wei Yang @ 2024-10-15 12:07 UTC (permalink / raw)
To: akpm, Liam.Howlett; +Cc: maple-tree, linux-mm, Wei Yang
Patch 1/2: some fields of the maple_alloc is not necessary to change, so we
can skip some operations
Patch 3: a valid alloc check could be hide in current code, so we don't need
to do a separate check
v2: refine the change log of patch 3.
Wei Yang (3):
maple_tree: clear request_count for new allocated one
maple_tree: total is not changed for nomem_one case
maple_tree: simplify mas_push_node()
lib/maple_tree.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/3] maple_tree: clear request_count for new allocated one
2024-10-15 12:07 [PATCH v2 0/3] cleanup maple_alloc related functions Wei Yang
@ 2024-10-15 12:07 ` Wei Yang
2024-10-15 12:07 ` [PATCH v2 2/3] maple_tree: total is not changed for nomem_one case Wei Yang
2024-10-15 12:07 ` [PATCH v2 3/3] maple_tree: simplify mas_push_node() Wei Yang
2 siblings, 0 replies; 4+ messages in thread
From: Wei Yang @ 2024-10-15 12:07 UTC (permalink / raw)
To: akpm, Liam.Howlett
Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett, Sidhartha Kumar,
Lorenzo Stoakes
If this is not a new allocated one, the request_count has already been
cleared in mas_set_alloc_req().
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
lib/maple_tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 6047c74c5a31..31899e853c1e 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -1250,11 +1250,11 @@ static inline void mas_alloc_nodes(struct ma_state *mas, gfp_t gfp)
mas->alloc = node;
node->total = ++allocated;
+ node->request_count = 0;
requested--;
}
node = mas->alloc;
- node->request_count = 0;
while (requested) {
max_req = MAPLE_ALLOC_SLOTS - node->node_count;
slots = (void **)&node->slot[node->node_count];
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] maple_tree: total is not changed for nomem_one case
2024-10-15 12:07 [PATCH v2 0/3] cleanup maple_alloc related functions Wei Yang
2024-10-15 12:07 ` [PATCH v2 1/3] maple_tree: clear request_count for new allocated one Wei Yang
@ 2024-10-15 12:07 ` Wei Yang
2024-10-15 12:07 ` [PATCH v2 3/3] maple_tree: simplify mas_push_node() Wei Yang
2 siblings, 0 replies; 4+ messages in thread
From: Wei Yang @ 2024-10-15 12:07 UTC (permalink / raw)
To: akpm, Liam.Howlett
Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett, Sidhartha Kumar,
Lorenzo Stoakes
If it jumps to nomem_one, the total allocated number is not changed. So
we don't need to adjust it.
For the nomem_bulk case, we know there is a valid mas->alloc. So we
don't need to do the check.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
lib/maple_tree.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 31899e853c1e..ab398461754b 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -1279,10 +1279,9 @@ static inline void mas_alloc_nodes(struct ma_state *mas, gfp_t gfp)
nomem_bulk:
/* Clean up potential freed allocations on bulk failure */
memset(slots, 0, max_req * sizeof(unsigned long));
+ mas->alloc->total = allocated;
nomem_one:
mas_set_alloc_req(mas, requested);
- if (mas->alloc && !(((unsigned long)mas->alloc & 0x1)))
- mas->alloc->total = allocated;
mas_set_err(mas, -ENOMEM);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] maple_tree: simplify mas_push_node()
2024-10-15 12:07 [PATCH v2 0/3] cleanup maple_alloc related functions Wei Yang
2024-10-15 12:07 ` [PATCH v2 1/3] maple_tree: clear request_count for new allocated one Wei Yang
2024-10-15 12:07 ` [PATCH v2 2/3] maple_tree: total is not changed for nomem_one case Wei Yang
@ 2024-10-15 12:07 ` Wei Yang
2 siblings, 0 replies; 4+ messages in thread
From: Wei Yang @ 2024-10-15 12:07 UTC (permalink / raw)
To: akpm, Liam.Howlett
Cc: maple-tree, linux-mm, Wei Yang, Liam R . Howlett, Sidhartha Kumar,
Lorenzo Stoakes
When count is not 0, we know head is valid. So we can put the assignment
in if (count) instead of checking the head pointer again.
Also count represents current total, we can assign the new total by
increasing the count by one.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
---
v2: refine the change log
---
lib/maple_tree.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index ab398461754b..afb59bb6a641 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -1192,19 +1192,17 @@ static inline void mas_push_node(struct ma_state *mas, struct maple_node *used)
reuse->request_count = 0;
reuse->node_count = 0;
- if (count && (head->node_count < MAPLE_ALLOC_SLOTS)) {
- head->slot[head->node_count++] = reuse;
- head->total++;
- goto done;
- }
-
- reuse->total = 1;
- if ((head) && !((unsigned long)head & 0x1)) {
+ if (count) {
+ if (head->node_count < MAPLE_ALLOC_SLOTS) {
+ head->slot[head->node_count++] = reuse;
+ head->total++;
+ goto done;
+ }
reuse->slot[0] = head;
reuse->node_count = 1;
- reuse->total += head->total;
}
+ reuse->total = count + 1;
mas->alloc = reuse;
done:
if (requested > 1)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-15 12:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 12:07 [PATCH v2 0/3] cleanup maple_alloc related functions Wei Yang
2024-10-15 12:07 ` [PATCH v2 1/3] maple_tree: clear request_count for new allocated one Wei Yang
2024-10-15 12:07 ` [PATCH v2 2/3] maple_tree: total is not changed for nomem_one case Wei Yang
2024-10-15 12:07 ` [PATCH v2 3/3] maple_tree: simplify mas_push_node() Wei Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).