Bug 199861

Summary: ureadahead - events/fs/do_sys_open/enable (No such file or directory)
Product: Tracing/Profiling Reporter: Demon (fyredemonyte)
Component: FtraceAssignee: Steven Rostedt (rostedt)
Status: REOPENED ---    
Severity: high CC: fyredemonyte
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: 4.16.0-041600-generic, 5.6.19-rt Subsystem:
Regression: No Bisected commit-id:

Description Demon 2018-05-28 07:22:22 UTC
Operating System: Ubuntu 16.04.4 
Kernel: 4.16.0-041600-generic

Running ureadahead from terminal as root with

# strace ureadahead --verbose --force-trace /

produces the output:

[..]
openat(3, "events/fs/do_sys_open/enable", O_RDWR) = -1 ENOENT (No such file or directory)
close(3)                                = 0
write(2, "ureadahead: Error while tracing:"..., 59ureadahead: Error while tracing: No such file or directory
[..]

Looking into this the directory/file in fact does not exist:

"/sys/kernel/debug/tracing/events/fs/do_sys_open/enable" 


The reason I became aware of this is because systemd is reporting that ureadahead.service is failing:

* ureadahead.service - Read required files in advance
   Loaded: loaded (/lib/systemd/system/ureadahead.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2018-05-27 23:41:51 EDT; 3h 38min ago
  Process: 282 ExecStart=/sbin/ureadahead (code=exited, status=5)
 Main PID: 282 (code=exited, status=5)

May 27 23:41:51 UbuntuHP ureadahead[282]: ureadahead: Error while tracing: No such file or directory
May 27 23:41:51 UbuntuHP ureadahead[282]: Counted 4 CPUs
May 27 23:41:51 UbuntuHP systemd[1]: ureadahead.service: Main process exited, code=exited, status=5/NOTINSTALLED
May 27 23:41:51 UbuntuHP systemd[1]: ureadahead.service: Unit entered failed state.
May 27 23:41:51 UbuntuHP systemd[1]: ureadahead.service: Failed with result 'exit-code'.
May 27 23:42:59 UbuntuHP systemd[1]: Stopped Read required files in advance.
Comment 1 Demon 2018-05-28 07:49:47 UTC
One reported solution on stackexchange was to apply a patch to the kernel :

https://unix.stackexchange.com/questions/308801/ureadahead-error-while-tracing-possible-kernel-patch-problem

Others are reporting this bug as well on launchpad with different kernel..

https://bugs.launchpad.net/ubuntu/+source/ureadahead/+bug/1763584
Comment 2 Steven Rostedt 2018-06-01 21:32:53 UTC
I don't know the Ubuntu kernel, but does your kernel have this commit?

1c758a2202a6 ("tracing/x86: Update syscall trace events to handle new prefixed syscall func names")

??

-- Steve
Comment 3 Demon 2020-08-16 10:31:57 UTC
(In reply to Steven Rostedt from comment #2)
> I don't know the Ubuntu kernel, but does your kernel have this commit?
> 
> 1c758a2202a6 ("tracing/x86: Update syscall trace events to handle new
> prefixed syscall func names")
> 
> ??
> 
> -- Steve

I completely forgot about this issue, but also my email address changed since I commented. 

However, I just recently did a custom compiled PREEMPT-RT kernel for version 5.6.19-rt. 

Using this patch: http://update.rootmaster.info/linux-kernel/projects/rt/5.6/ )

This is the content of ~/dev/kernel/linux5.6.19/arch/x86/include/asm/ftrace.h in regards to this bug report and your question about the commit, which seems its not implemented here:

==========================================================

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_X86_FTRACE_H
#define _ASM_X86_FTRACE_H

#ifdef CONFIG_FUNCTION_TRACER
#ifndef CC_USING_FENTRY
# error Compiler does not support fentry?
#endif
# define MCOUNT_ADDR		((unsigned long)(__fentry__))
#define MCOUNT_INSN_SIZE	5 /* sizeof mcount call */

#ifdef CONFIG_DYNAMIC_FTRACE
#define ARCH_SUPPORTS_FTRACE_OPS 1
#endif

#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR

#ifndef __ASSEMBLY__
extern atomic_t modifying_ftrace_code;
extern void __fentry__(void);

static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
	/*
	 * addr is the address of the mcount call instruction.
	 * recordmcount does the necessary offset calculation.
	 */
	return addr;
}

/*
 * When a ftrace registered caller is tracing a function that is
 * also set by a register_ftrace_direct() call, it needs to be
 * differentiated in the ftrace_caller trampoline. To do this, we
 * place the direct caller in the ORIG_AX part of pt_regs. This
 * tells the ftrace_caller that there's a direct caller.
 */
static inline void arch_ftrace_set_direct_caller(struct pt_regs *regs, unsigned long addr)
{
	/* Emulate a call */
	regs->orig_ax = addr;
}

#ifdef CONFIG_DYNAMIC_FTRACE

struct dyn_arch_ftrace {
	/* No extra data needed for x86 */
};

#define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR

#endif /*  CONFIG_DYNAMIC_FTRACE */
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_FUNCTION_TRACER */


#ifndef __ASSEMBLY__

#if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
extern void set_ftrace_ops_ro(void);
#else
static inline void set_ftrace_ops_ro(void) { }
#endif

#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
{
	/*
	 * Compare the symbol name with the system call name. Skip the
	 * "__x64_sys", "__ia32_sys" or simple "sys" prefix.
	 */
	return !strcmp(sym + 3, name + 3) ||
		(!strncmp(sym, "__x64_", 6) && !strcmp(sym + 9, name + 3)) ||
		(!strncmp(sym, "__ia32_", 7) && !strcmp(sym + 10, name + 3));
}

#ifndef COMPILE_OFFSETS

#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION)
#include <linux/compat.h>

/*
 * Because ia32 syscalls do not map to x86_64 syscall numbers
 * this screws up the trace output when tracing a ia32 task.
 * Instead of reporting bogus syscalls, just do not trace them.
 *
 * If the user really wants these, then they should use the
 * raw syscall tracepoints with filtering.
 */
#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1
static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
{
	return in_32bit_syscall();
}
#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_IA32_EMULATION */
#endif /* !COMPILE_OFFSETS */
#endif /* !__ASSEMBLY__ */

#endif /* _ASM_X86_FTRACE_H */

==========================================================

Please note I'm not working with the kernel from the linux repository (git), it's the zipped source code found here: https://cdn.kernel.org/pub/linux/kernel/v5.x/

***
However from the kernel repository which I checked I did see:

demon@Bionic18:~/dev/kernel/linux$ git log 1c758a2202a6
commit 1c758a2202a6b4624d0703013a2c6cfa6e7455aa
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Tue Apr 17 17:41:28 2018 -0400
***

Thank you for your assistance. Please advice on what should be done to properly get ureadahead to function.