Re: [patch v2] perf_event_open.2 : document PERF_FLAG_FD_CLOEXEC flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/01/2014 11:36 PM, Vince Weaver wrote:
> 
> The Linux 3.14 release adds support for the PERF_FLAG_FD_CLOEXEC flag to
> perf_event_open.2
> 
> This version tries to clarify that the close-on-exec behavior applies to 
> the current file descriptor being created.
> 
> The wording is based on the description in kernel commit
> a21b0b354d4ac39be691f51c53562e2c24443d9e 
> by Yann Droneaud <ydroneaud@xxxxxxxxxx>

Thanks, Vince. 

I applied, and reworked the text to be:

       PERF_FLAG_FD_CLOEXEC (since Linux 3.14).
              This flag enables the close-on-exec flag for the created
              event  file  descriptor,  so that the file descriptor is
              automatically closed on execve(2).  Setting  the  close-
              on-exec  flags at  creation time, rather than later with
              fcntl(2), avoids potential  race  conditions  where  the
              calling  thread  invokes  perf_event_open()  at the same
              time as another thread calls fork(2) then execve(2).

Okay?

Cheers,

Michael

> Signed-off-by: Vince Weaver <vincent.weaver@xxxxxxxxx>
> 
> diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2
> index 30a2168..b4a49c4 100644
> --- a/man2/perf_event_open.2
> +++ b/man2/perf_event_open.2
> @@ -164,6 +164,19 @@ must be passed as the
>  parameter.
>  cgroup monitoring is available only
>  for system-wide events and may therefore require extra permissions.
> +.TP
> +.BR PERF_FLAG_FD_CLOEXEC " (since Linux 3.14)."
> +This flag enables close-on-exec behavior for the created
> +event file descriptor, removing it from the list of
> +file descriptors inherited across exec.
> +Setting this behavior atomically at creation time rather than
> +later with
> +.BR fctl (2)
> +avoids potential race conditions between the current thread and
> +another calling
> +.BR fork (2)
> +then
> +.BR execve(2).
>  .P
>  The
>  .I perf_event_attr
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux