[igt-dev] [PATCH i-g-t v2 1/1] lib: consolidate duplicated define of vfs_file_max(void)

Petri Latvala petri.latvala at intel.com
Thu Apr 25 09:32:30 UTC 2019


On Wed, Apr 24, 2019 at 08:31:29AM -0700, Caz Yokoyama wrote:
> Signed-off-by: Caz Yokoyama <caz.yokoyama at intel.com>
> Cc: Petri Latvala <petri.latvala at intel.com>
> ---
>  lib/igt_aux.c               | 21 +++++++++++++++++++++
>  lib/igt_aux.h               |  2 ++
>  lib/intel_os.c              | 14 --------------
>  tests/i915/gem_exec_reuse.c | 14 +-------------
>  4 files changed, 24 insertions(+), 27 deletions(-)
> 
> diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> index 05528352..6516a6d6 100644
> --- a/lib/igt_aux.c
> +++ b/lib/igt_aux.c
> @@ -1615,3 +1615,24 @@ bool igt_allow_unlimited_files(void)
>  	rlim.rlim_max = nofile_rlim;
>  	return setrlimit(RLIMIT_NOFILE, &rlim) == 0;
>  }
> +
> +/*
> + * vfs_file_max: report maximum number of files
> + *
> + * By reading /proc/sys/fs/file-max, it returns maximum number of files kernel
> + * allows to have at the same time. It may returns 80000 or assert failure
> + * on error.
> + */

The documentation comment block needs to begin with  /**  (two asterisks).

Use the Returns: keyword to describe the return value semantics.

A wording change suggestion:

/**
 * vfs_file_max: get system-wide limit of open files
 *
 * Get the global system-wide maximum of open files the kernel allows,
 * by reading /proc/sys/fs/file-max. Fails the current subtest if
 * reading the file fails, and returns a suitable best guess if it
 * cannot be opened.
 *
 * Returns: System-wide maximum of open files, or a best effort guess.
 */


to better emphasise that it's the system-wide max, not nr_open. A
distinction that has already bitten us.

What do you think?


(When is there ever a case when the file can be opened but reading
fails?)



-- 
Petri Latvala


More information about the igt-dev mailing list