lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211211095006.446a7e85@oasis.local.home>
Date:   Sat, 11 Dec 2021 09:50:06 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Yinan Liu <yinan@...ux.alibaba.com>
Cc:     peterz@...radead.org, mark-pk.tsai@...iatek.com, mingo@...hat.com,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7 1/2] scripts: ftrace - move the sort-processing in
 ftrace_init

On Tue,  7 Dec 2021 23:13:46 +0800
Yinan Liu <yinan@...ux.alibaba.com> wrote:

> When the kernel starts, the initialization of ftrace takes
> up a portion of the time (approximately 6~8ms) to sort mcount
> addresses. We can save this time by moving mcount-sorting to
> compile time.
> 
> Signed-off-by: Yinan Liu <yinan@...ux.alibaba.com>
> Reported-by: kernel test robot <lkp@...el.com>
> Reported-by: kernel test robot <oliver.sang@...el.com>
> ---
>  kernel/trace/ftrace.c   |  11 +++-
>  scripts/Makefile        |   6 +-
>  scripts/link-vmlinux.sh |   6 +-
>  scripts/sorttable.c     |   2 +
>  scripts/sorttable.h     | 120 +++++++++++++++++++++++++++++++++++++++-
>  5 files changed, 137 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 30bc880c3849..9ca63df6553a 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -6406,8 +6406,15 @@ static int ftrace_process_locs(struct module *mod,
>  	if (!count)
>  		return 0;
>  
> -	sort(start, count, sizeof(*start),
> -	     ftrace_cmp_ips, NULL);
> +	/*
> +	 * Sorting mcount in vmlinux at build time depend on
> +	 * CONFIG_BUILDTIME_TABLE_SORT, while mcount loc in
> +	 * modules can not be sorted at build time.
> +	 */
> +	if (!IS_ENABLED(CONFIG_BUILDTIME_TABLE_SORT) || mod) {
> +		sort(start, count, sizeof(*start),
> +		     ftrace_cmp_ips, NULL);
> +	}
>  
>  	start_pg = ftrace_allocate_pages(count);
>  	if (!start_pg)
> diff --git a/scripts/Makefile b/scripts/Makefile
> index 9adb6d247818..d27503469f4b 100644
> --- a/scripts/Makefile
> +++ b/scripts/Makefile
> @@ -17,6 +17,7 @@ hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE)	+= insert-sys-cert
>  hostprogs-always-$(CONFIG_SYSTEM_REVOCATION_LIST)	+= extract-cert
>  
>  HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include
> +HOSTLDLIBS_sorttable = -lpthread
>  HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
>  HOSTCFLAGS_sign-file.o = $(CRYPTO_CFLAGS)
>  HOSTLDLIBS_sign-file = $(CRYPTO_LIBS)
> @@ -29,7 +30,10 @@ ARCH := x86
>  endif
>  HOSTCFLAGS_sorttable.o += -I$(srctree)/tools/arch/x86/include
>  HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED
> -HOSTLDLIBS_sorttable = -lpthread
> +endif
> +
> +ifdef CONFIG_FUNCTION_TRACER
> +HOSTCFLAGS_sorttable.o += -DMCOUNT_SORT_ENABLED
>  endif
>

I dropped this patch again (note I pulled in patch 2, so you do not
need to resend it). The attached config fails to build. The reason is
that you need to test for CONFIG_DYNAMIC_FTRACE and not
CONFIG_FUNCTION_TRACER.  The function tracer can be statically enabled,
which means all the functions just call "mcount" (or whatever), and
they are never patched. This means that the mcount location is not
created.

Just resend a v8 of this patch. Thanks!

-- Steve

Download attachment "config-fail.gz" of type "application/gzip" (30299 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ