public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: Caz Yokoyama <caz.yokoyama@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t v3 1/1] lib: consolidate duplicated define of vfs_file_max(void)
Date: Fri, 26 Apr 2019 12:41:10 +0300	[thread overview]
Message-ID: <20190426094110.GD22949@platvala-desk.ger.corp.intel.com> (raw)
In-Reply-To: <0df9d3f66d04f5ed7deed54aca5320ad8e202ead.1556212895.git.caz.yokoyama@intel.com>

On Thu, Apr 25, 2019 at 10:23:13AM -0700, Caz Yokoyama wrote:
> Remove it from intel_os.c and gem_exec_reuse.c and globally
> define in igt_aux.c.
> 
> v3: update comment in the code and commit message.
> 
> Signed-off-by: Caz Yokoyama <caz.yokoyama@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>


Reviewed-by: Petri Latvala <petri.latvala@intel.com>

> ---
>  lib/igt_aux.c               | 24 ++++++++++++++++++++++++
>  lib/igt_aux.h               |  2 ++
>  lib/intel_os.c              | 14 --------------
>  tests/i915/gem_exec_reuse.c | 14 +-------------
>  4 files changed, 27 insertions(+), 27 deletions(-)
> 
> diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> index 05528352..c3a9764a 100644
> --- a/lib/igt_aux.c
> +++ b/lib/igt_aux.c
> @@ -1615,3 +1615,27 @@ 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
> + *
> + * 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.
> + */
> +uint64_t vfs_file_max(void)
> +{
> +	static long long unsigned max;
> +	if (max == 0) {
> +		FILE *file = fopen("/proc/sys/fs/file-max", "r");
> +		max = 80000;
> +		if (file) {
> +			igt_assert(fscanf(file, "%llu", &max) == 1);
> +			fclose(file);
> +		}
> +	}
> +	return max;
> +}
> diff --git a/lib/igt_aux.h b/lib/igt_aux.h
> index 55392790..b5416ae0 100644
> --- a/lib/igt_aux.h
> +++ b/lib/igt_aux.h
> @@ -297,4 +297,6 @@ void igt_lsof(const char *dpath);
>  
>  #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
>  
> +uint64_t vfs_file_max(void);
> +
>  #endif /* IGT_AUX_H */
> diff --git a/lib/intel_os.c b/lib/intel_os.c
> index dd93bea1..505831c0 100644
> --- a/lib/intel_os.c
> +++ b/lib/intel_os.c
> @@ -279,20 +279,6 @@ void *intel_get_total_pinnable_mem(size_t *total)
>  	return can_mlock;
>  }
>  
> -static uint64_t vfs_file_max(void)
> -{
> -	static long long unsigned max;
> -	if (max == 0) {
> -		FILE *file = fopen("/proc/sys/fs/file-max", "r");
> -		max = 80000;
> -		if (file) {
> -			igt_assert(fscanf(file, "%llu", &max) == 1);
> -			fclose(file);
> -		}
> -	}
> -	return max;
> -}
> -
>  static unsigned max_open_files(void)
>  {
>  	struct rlimit rlim;
> diff --git a/tests/i915/gem_exec_reuse.c b/tests/i915/gem_exec_reuse.c
> index 9cba1354..935bfa9a 100644
> --- a/tests/i915/gem_exec_reuse.c
> +++ b/tests/i915/gem_exec_reuse.c
> @@ -25,6 +25,7 @@
>  #include <sys/resource.h>
>  
>  #include "igt.h"
> +#include "igt_aux.h"
>  
>  IGT_TEST_DESCRIPTION("Inspect scaling with large number of reused objects");
>  
> @@ -56,19 +57,6 @@ static void noop(struct noop *n,
>  	gem_execbuf(n->fd, &execbuf);
>  }
>  
> -static uint64_t vfs_file_max(void)
> -{
> -	long long unsigned max = 80000;
> -	FILE *file = fopen("/proc/sys/fs/file-max", "r");
> -	if (file) {
> -		igt_assert(fscanf(file, "%llu", &max) == 1);
> -		fclose(file);
> -	}
> -
> -	igt_info("System limit for open files is %llu\n", max);
> -	return max;
> -}
> -
>  static uint64_t max_open_files(void)
>  {
>  	struct rlimit rlim;
> -- 
> 2.17.1
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2019-04-26  9:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25 17:23 [igt-dev] [PATCH i-g-t v3 1/1] lib: consolidate duplicated define of vfs_file_max(void) Caz Yokoyama
2019-04-25 18:18 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v3,1/1] " Patchwork
2019-04-26  7:43 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-04-26  9:41 ` Petri Latvala [this message]
2019-04-26  9:52   ` [igt-dev] [PATCH i-g-t v3 1/1] " Petri Latvala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190426094110.GD22949@platvala-desk.ger.corp.intel.com \
    --to=petri.latvala@intel.com \
    --cc=caz.yokoyama@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox