[PATCH] um: allow using glibc string functions instead of generics
Anton Ivanov
anton.ivanov at cambridgegreys.com
Tue Nov 10 11:54:55 EST 2020
On 10/11/2020 16:40, Johannes Berg wrote:
> On Tue, 2020-11-10 at 16:30 +0000, anton.ivanov at cambridgegreys.com
> wrote:
>> From: Anton Ivanov <anton.ivanov at cambridgegreys.com>
>>
>> UML kernel runs as a normal userspace process and can use the
>> optimized glibc strings functions like strcpy, memcpy, etc.
>>
>> The support is optional and is turned on/of using a config
>> option.
>>
>> Using glibc functions results in a slightly smaller executable
>> when linked dynamically as well as anything between 1% and 5%
>> performance improvements.
>
> Nice! :-)
>
>> diff --git a/arch/um/Kconfig b/arch/um/Kconfig
>> index 4b799fad8b48..961cf3af3ff0 100644
>> --- a/arch/um/Kconfig
>> +++ b/arch/um/Kconfig
>> @@ -189,6 +189,17 @@ config UML_TIME_TRAVEL_SUPPORT
>>
>> It is safe to say Y, but you probably don't need this.
>>
>> +config UML_USE_HOST_STRINGS
>> + bool
>> + default y
>> + prompt "Use glibc strings and memory functions"
>> + help
>> + UML runs as a normal userspace process. As a result it can use
>> + the optimized strcpy, memcpy, etc from glibc instead of the
>> + kernel generic equivalents. This provides some minimal speedup
>> + in the 1% or so range for most applications. It also results in
>> + a smaller executable.
>
> Looks like some inconsistent tab/spaces indentation there :)
Will fix it in v2.
>
>> +++ b/arch/um/os-Linux/string.c
>> @@ -0,0 +1,78 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
>> + */
>> +
>> +#include <stddef.h>
>> +#include <unistd.h>
>> +#include <string.h>
>> +#include <os_string.h>
>> +
>> +inline char *os_strcpy(char *dest, const char *src)
>
> those 'inline' annotations seem strange - they can't possibly do
> anything useful here?
Indeed. The compiler inlines them anyway. I can remove that. There is no difference (I tried both).
>
> johannes
>
>
--
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/
More information about the linux-um
mailing list