* [PATCH] maple_tree: Do not inline write slow path
@ 2022-07-21 0:53 Liam Howlett
2022-07-21 8:26 ` David Laight
0 siblings, 1 reply; 3+ messages in thread
From: Liam Howlett @ 2022-07-21 0:53 UTC (permalink / raw)
To: maple-tree, linux-mm, linux-kernel, Andrew Morton, Hugh Dickins; +Cc: Yu Zhao
Having the slow path inlined causes too much stack usage. Create new
function mas_wr_bnode() to write a big node into the tree
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
lib/maple_tree.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 95d8659c5a99..4c383c780162 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -4297,12 +4297,27 @@ static inline bool mas_wr_append(struct ma_wr_state *wr_mas)
return false;
}
+/*
+ * mas_wr_bnode() - Slow path for a modification.
+ * @wr_mas: The write maple state
+ *
+ * This is where split, rebalance end up.
+ */
+static void mas_wr_bnode(struct ma_wr_state *wr_mas)
+{
+ struct maple_big_node b_node;
+
+ trace_ma_write(__func__, wr_mas->mas, 0, wr_mas->entry);
+ memset(&b_node, 0, sizeof(struct maple_big_node));
+ mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end);
+ mas_commit_b_node(wr_mas, &b_node, wr_mas->node_end);
+}
+
static inline void mas_wr_modify(struct ma_wr_state *wr_mas)
{
unsigned char node_slots;
unsigned char node_size;
struct ma_state *mas = wr_mas->mas;
- struct maple_big_node b_node;
/* Direct replacement */
if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last) {
@@ -4338,10 +4353,7 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas)
return;
slow_path:
- memset(&b_node, 0, sizeof(struct maple_big_node));
- mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end);
- trace_ma_write(__func__, mas, 0, wr_mas->entry);
- mas_commit_b_node(wr_mas, &b_node, wr_mas->node_end);
+ mas_wr_bnode(wr_mas);
}
/*
--
2.35.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH] maple_tree: Do not inline write slow path
2022-07-21 0:53 [PATCH] maple_tree: Do not inline write slow path Liam Howlett
@ 2022-07-21 8:26 ` David Laight
2022-07-21 19:30 ` Liam Howlett
0 siblings, 1 reply; 3+ messages in thread
From: David Laight @ 2022-07-21 8:26 UTC (permalink / raw)
To: 'Liam Howlett',
maple-tree, linux-mm, linux-kernel, Andrew Morton, Hugh Dickins
Cc: Yu Zhao
From: Liam Howlett
> Sent: 21 July 2022 01:53
>
> Having the slow path inlined causes too much stack usage. Create new
> function mas_wr_bnode() to write a big node into the tree
Unless you mark the function 'noinline' the compiler is
likely to inline it anyway.
David
>
> Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> ---
> lib/maple_tree.c | 22 +++++++++++++++++-----
> 1 file changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 95d8659c5a99..4c383c780162 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -4297,12 +4297,27 @@ static inline bool mas_wr_append(struct ma_wr_state *wr_mas)
> return false;
> }
>
> +/*
> + * mas_wr_bnode() - Slow path for a modification.
> + * @wr_mas: The write maple state
> + *
> + * This is where split, rebalance end up.
> + */
> +static void mas_wr_bnode(struct ma_wr_state *wr_mas)
> +{
> + struct maple_big_node b_node;
> +
> + trace_ma_write(__func__, wr_mas->mas, 0, wr_mas->entry);
> + memset(&b_node, 0, sizeof(struct maple_big_node));
> + mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end);
> + mas_commit_b_node(wr_mas, &b_node, wr_mas->node_end);
> +}
> +
> static inline void mas_wr_modify(struct ma_wr_state *wr_mas)
> {
> unsigned char node_slots;
> unsigned char node_size;
> struct ma_state *mas = wr_mas->mas;
> - struct maple_big_node b_node;
>
> /* Direct replacement */
> if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last) {
> @@ -4338,10 +4353,7 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas)
> return;
>
> slow_path:
> - memset(&b_node, 0, sizeof(struct maple_big_node));
> - mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end);
> - trace_ma_write(__func__, mas, 0, wr_mas->entry);
> - mas_commit_b_node(wr_mas, &b_node, wr_mas->node_end);
> + mas_wr_bnode(wr_mas);
> }
>
> /*
> --
> 2.35.1
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] maple_tree: Do not inline write slow path
2022-07-21 8:26 ` David Laight
@ 2022-07-21 19:30 ` Liam Howlett
0 siblings, 0 replies; 3+ messages in thread
From: Liam Howlett @ 2022-07-21 19:30 UTC (permalink / raw)
To: David Laight
Cc: maple-tree, linux-mm, linux-kernel, Andrew Morton, Hugh Dickins, Yu Zhao
* David Laight <David.Laight@ACULAB.COM> [220721 04:26]:
> From: Liam Howlett
> > Sent: 21 July 2022 01:53
> >
> > Having the slow path inlined causes too much stack usage. Create new
> > function mas_wr_bnode() to write a big node into the tree
>
> Unless you mark the function 'noinline' the compiler is
> likely to inline it anyway.
>
> David
Thanks for looking at this.
On my testing, removing the inline allowed the compiler to stop
complaining about the stack frame size. I don't mind if it is inlined,
but I don't want to force it to be inlined. I'd like to let the
compiler decide if it does the right thing.
Thanks,
Liam
>
> >
> > Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
> > ---
> > lib/maple_tree.c | 22 +++++++++++++++++-----
> > 1 file changed, 17 insertions(+), 5 deletions(-)
> >
> > diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> > index 95d8659c5a99..4c383c780162 100644
> > --- a/lib/maple_tree.c
> > +++ b/lib/maple_tree.c
> > @@ -4297,12 +4297,27 @@ static inline bool mas_wr_append(struct ma_wr_state *wr_mas)
> > return false;
> > }
> >
> > +/*
> > + * mas_wr_bnode() - Slow path for a modification.
> > + * @wr_mas: The write maple state
> > + *
> > + * This is where split, rebalance end up.
> > + */
> > +static void mas_wr_bnode(struct ma_wr_state *wr_mas)
> > +{
> > + struct maple_big_node b_node;
> > +
> > + trace_ma_write(__func__, wr_mas->mas, 0, wr_mas->entry);
> > + memset(&b_node, 0, sizeof(struct maple_big_node));
> > + mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end);
> > + mas_commit_b_node(wr_mas, &b_node, wr_mas->node_end);
> > +}
> > +
> > static inline void mas_wr_modify(struct ma_wr_state *wr_mas)
> > {
> > unsigned char node_slots;
> > unsigned char node_size;
> > struct ma_state *mas = wr_mas->mas;
> > - struct maple_big_node b_node;
> >
> > /* Direct replacement */
> > if (wr_mas->r_min == mas->index && wr_mas->r_max == mas->last) {
> > @@ -4338,10 +4353,7 @@ static inline void mas_wr_modify(struct ma_wr_state *wr_mas)
> > return;
> >
> > slow_path:
> > - memset(&b_node, 0, sizeof(struct maple_big_node));
> > - mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end);
> > - trace_ma_write(__func__, mas, 0, wr_mas->entry);
> > - mas_commit_b_node(wr_mas, &b_node, wr_mas->node_end);
> > + mas_wr_bnode(wr_mas);
> > }
> >
> > /*
> > --
> > 2.35.1
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-21 19:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 0:53 [PATCH] maple_tree: Do not inline write slow path Liam Howlett
2022-07-21 8:26 ` David Laight
2022-07-21 19:30 ` Liam Howlett
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.