Web lists-archives.com

Re: [PATCH 4/6] tools/gup_benchmark: Allow user specified file




On Wed, 10 Oct 2018 13:56:03 -0600 Keith Busch <keith.busch@xxxxxxxxx> wrote:

> This patch allows a user to specify a file to map by adding a new option,
> '-f', providing a means to test various file backings.
> 
> If not specified, the benchmark will use a private mapping of /dev/zero,
> which produces an anonymous mapping as before.
> 
> ...
>
> --- a/tools/testing/selftests/vm/gup_benchmark.c
> +++ b/tools/testing/selftests/vm/gup_benchmark.c
>
> ...
>
> @@ -61,11 +62,18 @@ int main(int argc, char **argv)
>  		case 'w':
>  			write = 1;
>  			break;
> +		case 'f':
> +			file = optarg;
> +			break;
>  		default:
>  			return -1;
>  		}
>  	}
>  
> +	filed = open(file, O_RDWR|O_CREAT);
> +	if (filed < 0)
> +		perror("open"), exit(filed);

Ick.  Like this, please:

--- a/tools/testing/selftests/vm/gup_benchmark.c~tools-gup_benchmark-allow-user-specified-file-fix
+++ a/tools/testing/selftests/vm/gup_benchmark.c
@@ -71,8 +71,10 @@ int main(int argc, char **argv)
 	}
 
 	filed = open(file, O_RDWR|O_CREAT);
-	if (filed < 0)
-		perror("open"), exit(filed);
+	if (filed < 0) {
+		perror("open");
+		exit(filed);
+	}
 
 	gup.nr_pages_per_call = nr_pages;
 	gup.flags = write;