[PATCH] perf trace beauty fcntl: Fix build with older kernel headers

Florian Fainelli posted 1 patch 4 weeks, 1 day ago
tools/perf/trace/beauty/fcntl.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
[PATCH] perf trace beauty fcntl: Fix build with older kernel headers
Posted by Florian Fainelli 4 weeks, 1 day ago
Toolchains with older kernel headers that do not include upstream commit
c75b1d9421f80f4143e389d2d50ddfc8a28c8c35 ("fs: add fcntl() interface for
setting/getting write life time hints") will now fail to build perf due
to missing definitions for
F_GET_RW_HINT/F_SET_RW_HINT/F_GET_FILE_RW_HINT/F_SET_FILE_RW_HINT.

Provide a fallback definition for these when they are not already
defined.

Fixes: 9c47f6674838 ("perf trace beauty fcntl: Basic 'arg' beautifier")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 tools/perf/trace/beauty/fcntl.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/perf/trace/beauty/fcntl.c b/tools/perf/trace/beauty/fcntl.c
index d075904dccce..e1b99b8f55eb 100644
--- a/tools/perf/trace/beauty/fcntl.c
+++ b/tools/perf/trace/beauty/fcntl.c
@@ -9,6 +9,22 @@
 #include <linux/kernel.h>
 #include <linux/fcntl.h>
 
+#ifndef F_GET_RW_HINT
+#define F_GET_RW_HINT		(F_LINUX_SPECIFIC_BASE + 11)
+#endif
+
+#ifndef F_SET_RW_HINT
+#define F_SET_RW_HINT		(F_LINUX_SPECIFIC_BASE + 12)
+#endif
+
+#ifndef F_GET_FILE_RW_HINT
+#define F_GET_FILE_RW_HINT	(F_LINUX_SPECIFIC_BASE + 13)
+#endif
+
+#ifndef F_SET_FILE_RW_HINT
+#define F_SET_FILE_RW_HINT	(F_LINUX_SPECIFIC_BASE + 14)
+#endif
+
 static size_t fcntl__scnprintf_getfd(unsigned long val, char *bf, size_t size, bool show_prefix)
 {
 	return val ? scnprintf(bf, size, "%s", "0") :
-- 
2.34.1
Re: [PATCH] perf trace beauty fcntl: Fix build with older kernel headers
Posted by Namhyung Kim 4 weeks ago
Hello,

On Wed, May 13, 2026 at 12:23:46PM -0700, Florian Fainelli wrote:
> Toolchains with older kernel headers that do not include upstream commit
> c75b1d9421f80f4143e389d2d50ddfc8a28c8c35 ("fs: add fcntl() interface for
> setting/getting write life time hints") will now fail to build perf due
> to missing definitions for
> F_GET_RW_HINT/F_SET_RW_HINT/F_GET_FILE_RW_HINT/F_SET_FILE_RW_HINT.

Can you share the error messages?

I think this code should use a copy of the header in
trace/beauty/include/uapi/linux/fcntl.h which has the definitions.

Thanks,
Namhyung

> 
> Provide a fallback definition for these when they are not already
> defined.
> 
> Fixes: 9c47f6674838 ("perf trace beauty fcntl: Basic 'arg' beautifier")
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
>  tools/perf/trace/beauty/fcntl.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/tools/perf/trace/beauty/fcntl.c b/tools/perf/trace/beauty/fcntl.c
> index d075904dccce..e1b99b8f55eb 100644
> --- a/tools/perf/trace/beauty/fcntl.c
> +++ b/tools/perf/trace/beauty/fcntl.c
> @@ -9,6 +9,22 @@
>  #include <linux/kernel.h>
>  #include <linux/fcntl.h>
>  
> +#ifndef F_GET_RW_HINT
> +#define F_GET_RW_HINT		(F_LINUX_SPECIFIC_BASE + 11)
> +#endif
> +
> +#ifndef F_SET_RW_HINT
> +#define F_SET_RW_HINT		(F_LINUX_SPECIFIC_BASE + 12)
> +#endif
> +
> +#ifndef F_GET_FILE_RW_HINT
> +#define F_GET_FILE_RW_HINT	(F_LINUX_SPECIFIC_BASE + 13)
> +#endif
> +
> +#ifndef F_SET_FILE_RW_HINT
> +#define F_SET_FILE_RW_HINT	(F_LINUX_SPECIFIC_BASE + 14)
> +#endif
> +
>  static size_t fcntl__scnprintf_getfd(unsigned long val, char *bf, size_t size, bool show_prefix)
>  {
>  	return val ? scnprintf(bf, size, "%s", "0") :
> -- 
> 2.34.1
>
Re: [PATCH] perf trace beauty fcntl: Fix build with older kernel headers
Posted by Ian Rogers 4 weeks ago
On Thu, May 14, 2026 at 8:56 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hello,
>
> On Wed, May 13, 2026 at 12:23:46PM -0700, Florian Fainelli wrote:
> > Toolchains with older kernel headers that do not include upstream commit
> > c75b1d9421f80f4143e389d2d50ddfc8a28c8c35 ("fs: add fcntl() interface for
> > setting/getting write life time hints") will now fail to build perf due
> > to missing definitions for
> > F_GET_RW_HINT/F_SET_RW_HINT/F_GET_FILE_RW_HINT/F_SET_FILE_RW_HINT.
>
> Can you share the error messages?
>
> I think this code should use a copy of the header in
> trace/beauty/include/uapi/linux/fcntl.h which has the definitions.

I don't think the beauty headers are in the include path.

Thanks,
Ian

> Thanks,
> Namhyung
>
> >
> > Provide a fallback definition for these when they are not already
> > defined.
> >
> > Fixes: 9c47f6674838 ("perf trace beauty fcntl: Basic 'arg' beautifier")
> > Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> > ---
> >  tools/perf/trace/beauty/fcntl.c | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> >
> > diff --git a/tools/perf/trace/beauty/fcntl.c b/tools/perf/trace/beauty/fcntl.c
> > index d075904dccce..e1b99b8f55eb 100644
> > --- a/tools/perf/trace/beauty/fcntl.c
> > +++ b/tools/perf/trace/beauty/fcntl.c
> > @@ -9,6 +9,22 @@
> >  #include <linux/kernel.h>
> >  #include <linux/fcntl.h>
> >
> > +#ifndef F_GET_RW_HINT
> > +#define F_GET_RW_HINT                (F_LINUX_SPECIFIC_BASE + 11)
> > +#endif
> > +
> > +#ifndef F_SET_RW_HINT
> > +#define F_SET_RW_HINT                (F_LINUX_SPECIFIC_BASE + 12)
> > +#endif
> > +
> > +#ifndef F_GET_FILE_RW_HINT
> > +#define F_GET_FILE_RW_HINT   (F_LINUX_SPECIFIC_BASE + 13)
> > +#endif
> > +
> > +#ifndef F_SET_FILE_RW_HINT
> > +#define F_SET_FILE_RW_HINT   (F_LINUX_SPECIFIC_BASE + 14)
> > +#endif
> > +
> >  static size_t fcntl__scnprintf_getfd(unsigned long val, char *bf, size_t size, bool show_prefix)
> >  {
> >       return val ? scnprintf(bf, size, "%s", "0") :
> > --
> > 2.34.1
> >
Re: [PATCH] perf trace beauty fcntl: Fix build with older kernel headers
Posted by Florian Fainelli 4 weeks ago

On 5/14/2026 9:37 AM, Ian Rogers wrote:
> On Thu, May 14, 2026 at 8:56 AM Namhyung Kim <namhyung@kernel.org> wrote:
>>
>> Hello,
>>
>> On Wed, May 13, 2026 at 12:23:46PM -0700, Florian Fainelli wrote:
>>> Toolchains with older kernel headers that do not include upstream commit
>>> c75b1d9421f80f4143e389d2d50ddfc8a28c8c35 ("fs: add fcntl() interface for
>>> setting/getting write life time hints") will now fail to build perf due
>>> to missing definitions for
>>> F_GET_RW_HINT/F_SET_RW_HINT/F_GET_FILE_RW_HINT/F_SET_FILE_RW_HINT.
>>
>> Can you share the error messages?

The compile errors look like this:

trace/beauty/fcntl.c: In function 'syscall_arg__scnprintf_fcntl_arg':
trace/beauty/fcntl.c:96:13: error: 'F_GET_RW_HINT' undeclared (first use 
in this function); did you mean 'F_GETOWN'?
       cmd == F_GET_RW_HINT || cmd == F_SET_RW_HINT ||
              ^~~~~~~~~~~~~
              F_GETOWN
trace/beauty/fcntl.c:96:13: note: each undeclared identifier is reported 
only once for each function it appears in
trace/beauty/fcntl.c:96:37: error: 'F_SET_RW_HINT' undeclared (first use 
in this function); did you mean 'F_SETOWN'?
       cmd == F_GET_RW_HINT || cmd == F_SET_RW_HINT ||
                                      ^~~~~~~~~~~~~
                                      F_SETOWN
trace/beauty/fcntl.c:97:13: error: 'F_GET_FILE_RW_HINT' undeclared 
(first use in this function); did you mean 'F_GETOWNER_UIDS'?
       cmd == F_GET_FILE_RW_HINT || cmd == F_SET_FILE_RW_HINT)
              ^~~~~~~~~~~~~~~~~~
              F_GETOWNER_UIDS
trace/beauty/fcntl.c:97:42: error: 'F_SET_FILE_RW_HINT' undeclared 
(first use in this function)
       cmd == F_GET_FILE_RW_HINT || cmd == F_SET_FILE_RW_HINT)
                                           ^~~~~~~~~~~~~~~~~~

>>
>> I think this code should use a copy of the header in
>> trace/beauty/include/uapi/linux/fcntl.h which has the definitions.
> 
> I don't think the beauty headers are in the include path.

I suppose if it were however that would provide the missing definition, 
maybe that's a better path forward to front load the inclusion of 
trace/beauty/include/uapi/linux/fcntl.h?
-- 
Florian

Re: [PATCH] perf trace beauty fcntl: Fix build with older kernel headers
Posted by Ian Rogers 4 weeks ago
On Thu, May 14, 2026 at 9:57 AM Florian Fainelli
<florian.fainelli@broadcom.com> wrote:
>
> On 5/14/2026 9:37 AM, Ian Rogers wrote:
> > On Thu, May 14, 2026 at 8:56 AM Namhyung Kim <namhyung@kernel.org> wrote:
> >>
> >> Hello,
> >>
> >> On Wed, May 13, 2026 at 12:23:46PM -0700, Florian Fainelli wrote:
> >>> Toolchains with older kernel headers that do not include upstream commit
> >>> c75b1d9421f80f4143e389d2d50ddfc8a28c8c35 ("fs: add fcntl() interface for
> >>> setting/getting write life time hints") will now fail to build perf due
> >>> to missing definitions for
> >>> F_GET_RW_HINT/F_SET_RW_HINT/F_GET_FILE_RW_HINT/F_SET_FILE_RW_HINT.
> >>
> >> Can you share the error messages?
>
> The compile errors look like this:
>
> trace/beauty/fcntl.c: In function 'syscall_arg__scnprintf_fcntl_arg':
> trace/beauty/fcntl.c:96:13: error: 'F_GET_RW_HINT' undeclared (first use
> in this function); did you mean 'F_GETOWN'?
>        cmd == F_GET_RW_HINT || cmd == F_SET_RW_HINT ||
>               ^~~~~~~~~~~~~
>               F_GETOWN
> trace/beauty/fcntl.c:96:13: note: each undeclared identifier is reported
> only once for each function it appears in
> trace/beauty/fcntl.c:96:37: error: 'F_SET_RW_HINT' undeclared (first use
> in this function); did you mean 'F_SETOWN'?
>        cmd == F_GET_RW_HINT || cmd == F_SET_RW_HINT ||
>                                       ^~~~~~~~~~~~~
>                                       F_SETOWN
> trace/beauty/fcntl.c:97:13: error: 'F_GET_FILE_RW_HINT' undeclared
> (first use in this function); did you mean 'F_GETOWNER_UIDS'?
>        cmd == F_GET_FILE_RW_HINT || cmd == F_SET_FILE_RW_HINT)
>               ^~~~~~~~~~~~~~~~~~
>               F_GETOWNER_UIDS
> trace/beauty/fcntl.c:97:42: error: 'F_SET_FILE_RW_HINT' undeclared
> (first use in this function)
>        cmd == F_GET_FILE_RW_HINT || cmd == F_SET_FILE_RW_HINT)
>                                            ^~~~~~~~~~~~~~~~~~
>
> >>
> >> I think this code should use a copy of the header in
> >> trace/beauty/include/uapi/linux/fcntl.h which has the definitions.
> >
> > I don't think the beauty headers are in the include path.
>
> I suppose if it were however that would provide the missing definition,
> maybe that's a better path forward to front load the inclusion of
> trace/beauty/include/uapi/linux/fcntl.h?

That's a reasonable thought, in that case we should move the header to
the more regular tools/include/uapi/linux for that purpose.

I'd very much like to get rid of tools/include entirely and have its
headers provided by explicit build targets similar to how we have say
libbpf headers:
https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/Makefile.perf?h=perf-tools-next#n957
Currently our include paths are a mess and we prioritize
tools/include/linux over tools/include/uapi/linux, which seems the
opposite of the expectation in user space. If we could install
separate headers, we could be clearer about licensing.
An issue with all of this is that the tools/include headers should
really be hermetic. This isn't true today and may be an issue for
moving linux/fcntl.h. The usual failure with non-hermetic headers is
pulling in linux/types.h or similar, from the system, linux or
uapi/linux and then get some mismatch in expectations with say u64 vs
__u64. For how silly the code base is today see bitsperlong.h that has
23 header files for essentially "sizeof(long) * 8".

Anyway, Arnaldo has been moving to reduce the number of files in
tools/include to avoid touching files there that then trigger a full
kernel rebuild, which frustrates Linus.

Thanks,
Ian

> --
> Florian
>
Re: [PATCH] perf trace beauty fcntl: Fix build with older kernel headers
Posted by Ian Rogers 4 weeks, 1 day ago
On Wed, May 13, 2026 at 12:23 PM Florian Fainelli
<florian.fainelli@broadcom.com> wrote:
>
> Toolchains with older kernel headers that do not include upstream commit
> c75b1d9421f80f4143e389d2d50ddfc8a28c8c35 ("fs: add fcntl() interface for
> setting/getting write life time hints") will now fail to build perf due
> to missing definitions for
> F_GET_RW_HINT/F_SET_RW_HINT/F_GET_FILE_RW_HINT/F_SET_FILE_RW_HINT.
>
> Provide a fallback definition for these when they are not already
> defined.

This seems fine but the commit you mention was added to Linux 4.13. Is
there a reason you've run into this problem? The oldest active LTS
kernel is 4.19.

Thanks,
Ian

> Fixes: 9c47f6674838 ("perf trace beauty fcntl: Basic 'arg' beautifier")
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
> ---
>  tools/perf/trace/beauty/fcntl.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/tools/perf/trace/beauty/fcntl.c b/tools/perf/trace/beauty/fcntl.c
> index d075904dccce..e1b99b8f55eb 100644
> --- a/tools/perf/trace/beauty/fcntl.c
> +++ b/tools/perf/trace/beauty/fcntl.c
> @@ -9,6 +9,22 @@
>  #include <linux/kernel.h>
>  #include <linux/fcntl.h>
>
> +#ifndef F_GET_RW_HINT
> +#define F_GET_RW_HINT          (F_LINUX_SPECIFIC_BASE + 11)
> +#endif
> +
> +#ifndef F_SET_RW_HINT
> +#define F_SET_RW_HINT          (F_LINUX_SPECIFIC_BASE + 12)
> +#endif
> +
> +#ifndef F_GET_FILE_RW_HINT
> +#define F_GET_FILE_RW_HINT     (F_LINUX_SPECIFIC_BASE + 13)
> +#endif
> +
> +#ifndef F_SET_FILE_RW_HINT
> +#define F_SET_FILE_RW_HINT     (F_LINUX_SPECIFIC_BASE + 14)
> +#endif
> +
>  static size_t fcntl__scnprintf_getfd(unsigned long val, char *bf, size_t size, bool show_prefix)
>  {
>         return val ? scnprintf(bf, size, "%s", "0") :
> --
> 2.34.1
>
Re: [PATCH] perf trace beauty fcntl: Fix build with older kernel headers
Posted by Florian Fainelli 4 weeks, 1 day ago
On 5/13/26 13:58, Ian Rogers wrote:
> On Wed, May 13, 2026 at 12:23 PM Florian Fainelli
> <florian.fainelli@broadcom.com> wrote:
>>
>> Toolchains with older kernel headers that do not include upstream commit
>> c75b1d9421f80f4143e389d2d50ddfc8a28c8c35 ("fs: add fcntl() interface for
>> setting/getting write life time hints") will now fail to build perf due
>> to missing definitions for
>> F_GET_RW_HINT/F_SET_RW_HINT/F_GET_FILE_RW_HINT/F_SET_FILE_RW_HINT.
>>
>> Provide a fallback definition for these when they are not already
>> defined.
> 
> This seems fine but the commit you mention was added to Linux 4.13. Is
> there a reason you've run into this problem? The oldest active LTS
> kernel is 4.19.

The toolchain I am using is still on kernel headers 4.9.x, I am 
cognizant this is a very old set of kernel headers, this is specific and 
unique to building for MIPS, our ARM/ARM64 targets are using more modern 
components.
-- 
Florian
Re: [PATCH] perf trace beauty fcntl: Fix build with older kernel headers
Posted by Ian Rogers 4 weeks, 1 day ago
On Wed, May 13, 2026 at 2:56 PM Florian Fainelli
<florian.fainelli@broadcom.com> wrote:
>
> On 5/13/26 13:58, Ian Rogers wrote:
> > On Wed, May 13, 2026 at 12:23 PM Florian Fainelli
> > <florian.fainelli@broadcom.com> wrote:
> >>
> >> Toolchains with older kernel headers that do not include upstream commit
> >> c75b1d9421f80f4143e389d2d50ddfc8a28c8c35 ("fs: add fcntl() interface for
> >> setting/getting write life time hints") will now fail to build perf due
> >> to missing definitions for
> >> F_GET_RW_HINT/F_SET_RW_HINT/F_GET_FILE_RW_HINT/F_SET_FILE_RW_HINT.
> >>
> >> Provide a fallback definition for these when they are not already
> >> defined.
> >
> > This seems fine but the commit you mention was added to Linux 4.13. Is
> > there a reason you've run into this problem? The oldest active LTS
> > kernel is 4.19.
>
> The toolchain I am using is still on kernel headers 4.9.x, I am
> cognizant this is a very old set of kernel headers, this is specific and
> unique to building for MIPS, our ARM/ARM64 targets are using more modern
> components.

Sgtm. I have some libunwind clean up for MIPS that I'll add you to, in
case it is of interest since I can't test it myself :-)

For this patch:
Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> --
> Florian
Re: [PATCH] perf trace beauty fcntl: Fix build with older kernel headers
Posted by Arnaldo Carvalho de Melo 4 weeks ago
On Wed, May 13, 2026 at 04:13:58PM -0700, Ian Rogers wrote:
> On Wed, May 13, 2026 at 2:56 PM Florian Fainelli <florian.fainelli@broadcom.com> wrote:

> > On 5/13/26 13:58, Ian Rogers wrote:
> > > On Wed, May 13, 2026 at 12:23 PM Florian Fainelli <florian.fainelli@broadcom.com> wrote:
> > >> Toolchains with older kernel headers that do not include upstream commit
> > >> c75b1d9421f80f4143e389d2d50ddfc8a28c8c35 ("fs: add fcntl() interface for
> > >> setting/getting write life time hints") will now fail to build perf due
> > >> to missing definitions for
> > >> F_GET_RW_HINT/F_SET_RW_HINT/F_GET_FILE_RW_HINT/F_SET_FILE_RW_HINT.

> > >> Provide a fallback definition for these when they are not already
> > >> defined.

> > > This seems fine but the commit you mention was added to Linux 4.13. Is
> > > there a reason you've run into this problem? The oldest active LTS
> > > kernel is 4.19.

> > The toolchain I am using is still on kernel headers 4.9.x, I am
> > cognizant this is a very old set of kernel headers, this is specific and
> > unique to building for MIPS, our ARM/ARM64 targets are using more modern
> > components.

> Sgtm. I have some libunwind clean up for MIPS that I'll add you to, in
> case it is of interest since I can't test it myself :-)
 
> For this patch:
> Reviewed-by: Ian Rogers <irogers@google.com>

Thanks, applied to perf-tools-next, for v7.2.

- ARnaldo