From: Richard Weinberger <richard@nod.at>
To: anton.ivanov@cambridgegreys.com
Cc: linux-um@lists.infradead.org
Subject: Re: [PATCH] um: Try to avoid kmalloc in signal handling
Date: Fri, 04 Jan 2019 11:13:06 +0100 [thread overview]
Message-ID: <2157515.SUgOQPs8Ts@blindfold> (raw)
In-Reply-To: <20190104100517.9809-1-anton.ivanov@cambridgegreys.com>
Am Freitag, 4. Januar 2019, 11:05:17 CET schrieb anton.ivanov@cambridgegreys.com:
> From: Anton Ivanov <anton.ivanov@cambridgegreys.com>
>
> Signal handling (which maps to interrupt handling in UML) needs
> to pass current registers to the relevant handlers and was
> allocating a structure for that using kmalloc. It is possible
> to avoid this kmalloc by using a small "signal register stack".
> A depth of 4 suffices for normal use. If it is exceeded
> further sets of registers are allocated as before via kmalloc.
>
> The end result is >10% performance increase in networking
> as measured by iperf and >5% across the board.
>
> Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
> ---
> arch/um/include/shared/os.h | 4 ++++
> arch/um/kernel/signal.c | 31 +++++++++++++++++++++++++++++++
> arch/um/os-Linux/signal.c | 16 ++++------------
> 3 files changed, 39 insertions(+), 12 deletions(-)
>
> diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
> index ebf23012a59b..4ec1bc63213b 100644
> --- a/arch/um/include/shared/os.h
> +++ b/arch/um/include/shared/os.h
> @@ -319,4 +319,8 @@ extern unsigned long os_get_top_address(void);
>
> long syscall(long number, ...);
>
> +/* signal.c */
> +extern struct uml_pt_regs *get_save_register_state(void);
> +extern void release_save_register_state(struct uml_pt_regs *r);
> +
> #endif
> diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c
> index 57acbd67d85d..558ac7e4df97 100644
> --- a/arch/um/kernel/signal.c
> +++ b/arch/um/kernel/signal.c
> @@ -6,11 +6,18 @@
> #include <linux/module.h>
> #include <linux/ptrace.h>
> #include <linux/sched.h>
> +#include <linux/slab.h>
> #include <asm/siginfo.h>
> #include <asm/signal.h>
> #include <asm/unistd.h>
> #include <frame_kern.h>
> #include <kern_util.h>
> +#include <os.h>
> +
> +static atomic_t reg_depth;
> +
> +static struct uml_pt_regs reg_file[4];
> +#define REG_SWITCH_TO_KMALLOC_DEPTH 3
I fear this is not correct.
Think of task switching, if you push something to reg_file[],
it is not guaranteed that the same task will run next and pop the item.
The order can change.
Thanks,
//richard
_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um
next prev parent reply other threads:[~2019-01-04 10:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-04 10:05 [PATCH] um: Try to avoid kmalloc in signal handling anton.ivanov
2019-01-04 10:13 ` Richard Weinberger [this message]
2019-01-04 10:19 ` Anton Ivanov
2019-01-04 10:33 ` Richard Weinberger
2019-01-04 10:49 ` Anton Ivanov
2019-01-04 11:31 ` Anton Ivanov
-- strict thread matches above, loose matches on Subject: below --
2019-01-03 16:09 anton.ivanov
2019-01-03 17:13 ` Anton Ivanov
2019-01-03 21:29 ` Anton Ivanov
2019-01-03 21:42 ` Richard Weinberger
2019-01-04 7:07 ` Anton Ivanov
2019-01-04 7:48 ` Anton Ivanov
2019-01-04 15:50 ` Anton Ivanov
2019-01-07 10:07 ` Anton Ivanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2157515.SUgOQPs8Ts@blindfold \
--to=richard@nod.at \
--cc=anton.ivanov@cambridgegreys.com \
--cc=linux-um@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox