mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Thomas Meyer <thomas@m3y3r.de>
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	shuah@kernel.org, Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH] selftests/bpf: Make bpf_util work on uniprocessor systems
Date: Fri, 8 Sep 2017 16:01:57 -0700	[thread overview]
Message-ID: <20170908230155.esge2mctk5d5g7gb@ast-mbp> (raw)
In-Reply-To: <20170908111923.27434-1-thomas@m3y3r.de>

On Fri, Sep 08, 2017 at 01:19:23PM +0200, Thomas Meyer wrote:
> The current implementation fails to work on uniprocessor systems.
> Fix the parser to also handle the uniprocessor case.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

Thanks for the fix. lgtm
Acked-by: Alexei Starovoitov <ast@kernel.org>

This time it's ok to go via selftest tree, but next time please use net-next/net
to avoid conflicts.
Thanks

> ---
>  tools/testing/selftests/bpf/bpf_util.h | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selftests/bpf/bpf_util.h
> index 20ecbaa0d85d..6c53a8906eff 100644
> --- a/tools/testing/selftests/bpf/bpf_util.h
> +++ b/tools/testing/selftests/bpf/bpf_util.h
> @@ -12,6 +12,7 @@ static inline unsigned int bpf_num_possible_cpus(void)
>  	unsigned int start, end, possible_cpus = 0;
>  	char buff[128];
>  	FILE *fp;
> +	int n;
>  
>  	fp = fopen(fcpu, "r");
>  	if (!fp) {
> @@ -20,17 +21,17 @@ static inline unsigned int bpf_num_possible_cpus(void)
>  	}
>  
>  	while (fgets(buff, sizeof(buff), fp)) {
> -		if (sscanf(buff, "%u-%u", &start, &end) == 2) {
> -			possible_cpus = start == 0 ? end + 1 : 0;
> -			break;
> +		n = sscanf(buff, "%u-%u", &start, &end);
> +		if (n == 0) {
> +			printf("Failed to retrieve # possible CPUs!\n");
> +			exit(1);
> +		} else if (n == 1) {
> +			end = start;
>  		}
> +		possible_cpus = start == 0 ? end + 1 : 0;
> +		break;
>  	}
> -
>  	fclose(fp);
> -	if (!possible_cpus) {
> -		printf("Failed to retrieve # possible CPUs!\n");
> -		exit(1);
> -	}
>  
>  	return possible_cpus;
>  }
> -- 
> 2.11.0
> 

  reply	other threads:[~2017-09-08 23:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-08 11:19 Thomas Meyer
2017-09-08 23:01 ` Alexei Starovoitov [this message]
2017-09-08 23:05   ` Daniel Borkmann
2017-09-14 15:01     ` Shuah Khan
2017-09-14 15:33       ` selftests/bpf doesn't compile Shuah Khan
2017-09-15 16:02         ` Alexei Starovoitov
2017-09-15 16:58           ` Edward Cree
2017-09-15 18:07             ` Alexei Starovoitov
2017-09-15 18:23               ` Daniel Borkmann
2017-09-15 18:48                 ` Daniel Borkmann
2017-09-15 22:41                   ` Shuah Khan
2017-09-18 13:31                     ` Daniel Borkmann
2017-09-15 17:00           ` Shuah Khan
2017-09-15 17:44             ` Shuah Khan
2017-09-15 18:14             ` Alexei Starovoitov
2017-09-15 22:32               ` Shuah Khan
2019-01-04 17:16         ` Geert Uytterhoeven
2019-01-04 19:07           ` shuah
2017-09-19 14:45       ` [PATCH] selftests/bpf: Make bpf_util work on uniprocessor systems Shuah Khan

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=20170908230155.esge2mctk5d5g7gb@ast-mbp \
    --to=alexei.starovoitov@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=thomas@m3y3r.de \
    /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

all inboxes | Powered by JetHome®