On Thu, May 18, 2023 at 04:08:34PM -0400, Mike Pattrick wrote:
> Several xlate actions used in recursive translation currently store a
> large amount of information on the stack. This can result in handler
> threads quickly running out of stack space despite before
> xlate_resubmit_resource_check() is able to terminate translation. This
> patch reduces stack usage by over 3kb from several translation actions.
> 
> This patch also moves some trace function from do_xlate_actions into its
> own function to reduce stack usage.
> 
> Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=2104779
> Signed-off-by: Mike Pattrick <m...@redhat.com>
> 
> ---
> 
> Since v1:
>  - Refactored code into specialized functions and renamed variables for
>  improved readability.
> 
> ---
>  ofproto/ofproto-dpif-xlate.c | 223 ++++++++++++++++++++++-------------
>  1 file changed, 141 insertions(+), 82 deletions(-)
> 
> diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> index 29f4daa63..abfa717e2 100644
> --- a/ofproto/ofproto-dpif-xlate.c
> +++ b/ofproto/ofproto-dpif-xlate.c
> @@ -501,6 +501,90 @@ ctx_cancel_freeze(struct xlate_ctx *ctx)
>  
>  static void finish_freezing(struct xlate_ctx *ctx);
>  
> +/* These functions and structure are used to save stack space in actions that
> + * need to retain a large amount of xlate_ctx state. */
> +struct xretained_state {
> +    union mf_subvalue new_stack[1024 / sizeof(union mf_subvalue)];
> +    uint64_t actset_stub[1024 / 8];
> +    struct ofpbuf old_stack;
> +    struct ofpbuf old_action_set;
> +    struct flow old_flow;
> +    struct flow old_base;
> +    struct flow_tnl flow_tnl;
> +};
> +
> +/* The return of this function must be freed by xretain_state_restore(). */
> +static inline struct xretained_state *
> +xretain_state_save(struct xlate_ctx *ctx)

Hi Mike,

nit: I don't think the inline keyword is needed here, or elsewhere in this
     patch. Because the compiler should be able to figure this out.
     So unless there is a strong reason I'd prefer to drop 'inline'.

Otherwise the patch looks good to me.
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to