All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Martin <Dave.Martin@arm.com>
To: Mark Brown <broonie@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Shuah Khan <skhan@linuxfoundation.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v3 3/4] kselftest/arm64: Add tests for SVE vector configuration
Date: Mon, 2 Aug 2021 16:36:15 +0100	[thread overview]
Message-ID: <20210802153614.GC25258@arm.com> (raw)
In-Reply-To: <20210802141939.GF4668@sirena.org.uk>

On Mon, Aug 02, 2021 at 03:19:39PM +0100, Mark Brown wrote:
> On Mon, Aug 02, 2021 at 01:37:50PM +0100, Dave Martin wrote:
> > On Mon, Aug 02, 2021 at 12:33:30PM +0100, Mark Brown wrote:
> 
> > > That really doesn't seem like a good idea - it's just asking for
> > > fragility if a signal gets delivered to the parent process or something.
> > > Even if almost all the time there will only be one trip through the loop
> > > we should still have the loop there for those few cases where it
> > > triggers.
> 
> > This concern only applies when the program actually registers signal
> > handlers.
> 
> > wait() can't return for any other reason, and it mustn't, precisely
> > because historically software would have made this assumption.  This is
> > one reason why wait3() etc. are separate functions.
> 
> That's great for the reader with a detailed knowledge of exactly what
> error handling can be skipped and how standards conforming Linux is but
> less good for the reader who is merely aware of best practices.  I am
> not clear what the problem that is solved by removing the loop here is
> TBH - to me it just makes it less obvious that we've handled everything.

Ok, leave it as is then.

(It would be good to collect some best-practice guidance on how to
actually use syscalls, but that's clearly way out of scope here...)

> > That aside though, can't we use popen(3)?
> 
> > I tend to forget about popen because it is "boring" to use it, but it
> > looks like it fits this case quite well.  Then it would be libc's
> > problem how to fork and wait safely.
> 
> popen() appears to be break the _SET_VL_ONEXEC test.  Between a lack of
> strace in my test filesystem and not spotting anything obvious in the
> glibc sources I can't tell exactly where it's doing something different,
> though it does feel like it should be a separate testcase if it's
> anything interesting.  I do think there is value in having exactly
> what's done to start the child process be clear in the test program, and
> that coverage of anything interesting from popen() could be done
> incrementally.

Ah, dang, popen() will run the target program via a shell, so there will
actually be two fork-exec()s, with the VL being reset to default by the
second exec.

Using PR_SET_SET_VL with popen() still makes sense, but if you want the
target program to get the new VL (not just the shell) then you'd need
PR_SVE_VL_INHERIT.  Then we would get confused later when trying to
test the !PR_SVE_VL_INHERIT case.  The way to "fix" this would be to
have the shell invoke something like vlset, but that will blur the test
in a different way, adding even more confusion.

So Ack, we can't test all the variations using the popen() method, so we
probably shouldn't use it here at all.  

This is the kind of reason why I tend not to go for it, I guess --
it looks convenient, but it's just that little bit overcooked as an API.
*sigh*


I'll review your final version of the series, but I guess we're all good.

Cheers
---Dave

WARNING: multiple messages have this Message-ID (diff)
From: Dave Martin <Dave.Martin@arm.com>
To: Mark Brown <broonie@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Shuah Khan <skhan@linuxfoundation.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v3 3/4] kselftest/arm64: Add tests for SVE vector configuration
Date: Mon, 2 Aug 2021 16:36:15 +0100	[thread overview]
Message-ID: <20210802153614.GC25258@arm.com> (raw)
In-Reply-To: <20210802141939.GF4668@sirena.org.uk>

On Mon, Aug 02, 2021 at 03:19:39PM +0100, Mark Brown wrote:
> On Mon, Aug 02, 2021 at 01:37:50PM +0100, Dave Martin wrote:
> > On Mon, Aug 02, 2021 at 12:33:30PM +0100, Mark Brown wrote:
> 
> > > That really doesn't seem like a good idea - it's just asking for
> > > fragility if a signal gets delivered to the parent process or something.
> > > Even if almost all the time there will only be one trip through the loop
> > > we should still have the loop there for those few cases where it
> > > triggers.
> 
> > This concern only applies when the program actually registers signal
> > handlers.
> 
> > wait() can't return for any other reason, and it mustn't, precisely
> > because historically software would have made this assumption.  This is
> > one reason why wait3() etc. are separate functions.
> 
> That's great for the reader with a detailed knowledge of exactly what
> error handling can be skipped and how standards conforming Linux is but
> less good for the reader who is merely aware of best practices.  I am
> not clear what the problem that is solved by removing the loop here is
> TBH - to me it just makes it less obvious that we've handled everything.

Ok, leave it as is then.

(It would be good to collect some best-practice guidance on how to
actually use syscalls, but that's clearly way out of scope here...)

> > That aside though, can't we use popen(3)?
> 
> > I tend to forget about popen because it is "boring" to use it, but it
> > looks like it fits this case quite well.  Then it would be libc's
> > problem how to fork and wait safely.
> 
> popen() appears to be break the _SET_VL_ONEXEC test.  Between a lack of
> strace in my test filesystem and not spotting anything obvious in the
> glibc sources I can't tell exactly where it's doing something different,
> though it does feel like it should be a separate testcase if it's
> anything interesting.  I do think there is value in having exactly
> what's done to start the child process be clear in the test program, and
> that coverage of anything interesting from popen() could be done
> incrementally.

Ah, dang, popen() will run the target program via a shell, so there will
actually be two fork-exec()s, with the VL being reset to default by the
second exec.

Using PR_SET_SET_VL with popen() still makes sense, but if you want the
target program to get the new VL (not just the shell) then you'd need
PR_SVE_VL_INHERIT.  Then we would get confused later when trying to
test the !PR_SVE_VL_INHERIT case.  The way to "fix" this would be to
have the shell invoke something like vlset, but that will blur the test
in a different way, adding even more confusion.

So Ack, we can't test all the variations using the popen() method, so we
probably shouldn't use it here at all.  

This is the kind of reason why I tend not to go for it, I guess --
it looks convenient, but it's just that little bit overcooked as an API.
*sigh*


I'll review your final version of the series, but I guess we're all good.

Cheers
---Dave

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-08-02 15:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-29 15:15 [PATCH v3 0/4] kselftest/arm64: Vector length configuration tests Mark Brown
2021-07-29 15:15 ` Mark Brown
2021-07-29 15:15 ` [PATCH v3 1/4] kselftest/arm64: Provide a helper binary and "library" for SVE RDVL Mark Brown
2021-07-29 15:15   ` Mark Brown
2021-07-29 15:15 ` [PATCH v3 2/4] kselftest/arm64: Validate vector lengths are set in sve-probe-vls Mark Brown
2021-07-29 15:15   ` Mark Brown
2021-07-29 15:15 ` [PATCH v3 3/4] kselftest/arm64: Add tests for SVE vector configuration Mark Brown
2021-07-29 15:15   ` Mark Brown
2021-07-29 16:06   ` Dave Martin
2021-07-29 16:06     ` Dave Martin
2021-07-29 17:34     ` Mark Brown
2021-07-29 17:34       ` Mark Brown
2021-08-02 10:25       ` Dave Martin
2021-08-02 10:25         ` Dave Martin
2021-08-02 11:33         ` Mark Brown
2021-08-02 11:33           ` Mark Brown
2021-08-02 12:37           ` Dave Martin
2021-08-02 12:37             ` Dave Martin
2021-08-02 14:19             ` Mark Brown
2021-08-02 14:19               ` Mark Brown
2021-08-02 15:36               ` Dave Martin [this message]
2021-08-02 15:36                 ` Dave Martin
2021-08-02 16:23                 ` Mark Brown
2021-08-02 16:23                   ` Mark Brown
2021-07-29 15:15 ` [PATCH v3 4/4] kselftest/arm64: Add a TODO list for floating point tests Mark Brown
2021-07-29 15:15   ` Mark Brown

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=20210802153614.GC25258@arm.com \
    --to=dave.martin@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=will@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.