lkml.org 
[lkml]   [2020]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: [PATCH] perf tools: Add file-handle feature test
Em Thu, Apr 02, 2020 at 12:37:48PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, Apr 02, 2020 at 10:52:49AM +0900, Namhyung Kim escreveu:
> > The file handle (FHANDLE) support is configurable so some systems might
> > not have it. So add a config feature item to check it on build time
> > and reject cgroup tracking based on that.
>
> Ok, I'll break this patch in two, add the feature test first, then fold
> the usage of HAVE_FILE_HANDLE with the patch that uses it, so that we
> keep the codebase bisectable,

> > +++ b/tools/build/feature/test-file-handle.c
> > @@ -0,0 +1,14 @@
> > +#define _GNU_SOURCE
> > +#include <sys/types.h>
> > +#include <sys/stat.h>
> > +#include <fcntl.h>
> > +
> > +int main(void)
> > +{
> > + struct file_handle fh;
> > + int mount_id;
> > +
> > + name_to_handle_at(AT_FDCWD, "/", &fh, &mount_id, 0);
> > + return 0;

Also had to do it just like you use in your patches, see patch below, to
cover this case as well:

CC /tmp/build/perf/util/synthetic-events.o
CC /tmp/build/perf/util/data.o
CC /tmp/build/perf/util/tsc.o
CC /tmp/build/perf/util/cloexec.o
util/synthetic-events.c:428:22: error: field 'fh' with CC /tmp/build/perf/util/call-path.o
variable sized type 'struct file_handle' not at the end of a struct or class is a GNU
extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
struct file_handle fh;
^
1 error generated.
mv: can't rename '/tmp/build/perf/util/.synthetic-events.o.tmp': No such file or directory
make[4]: *** [/git/linux/tools/build/Makefile.build:97: /tmp/build/perf/util/synthetic-events.o] Error 1
make[4]: *** Waiting for unfinished jobs....


This is on Alpine Linux 3.11 onwards, musl libc.

- Arnaldo


diff --git a/tools/build/feature/test-file-handle.c b/tools/build/feature/test-file-handle.c
index e325b2a060ed..bed871e3978d 100644
--- a/tools/build/feature/test-file-handle.c
+++ b/tools/build/feature/test-file-handle.c
@@ -5,9 +5,12 @@

int main(void)
{
- struct file_handle fh;
+ struct {
+ struct file_handle fh;
+ uint64_t cgroup_id;
+ } handle;
int mount_id;

- name_to_handle_at(AT_FDCWD, "/", &fh, &mount_id, 0);
+ name_to_handle_at(AT_FDCWD, "/", &handle.fh, &mount_id, 0);
return 0;
}
\
 
 \ /
  Last update: 2020-04-02 20:39    [W:0.074 / U:31.584 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site