From: Alexander Kanavin <alexander.kanavin@linux.intel.com>
To: Mark Hatle <mark.hatle@windriver.com>,
openembedded-core@lists.openembedded.org
Subject: Re: [PATCHv2 2/2] rpm: run binary package generation via thread pools
Date: Fri, 9 Jun 2017 12:02:22 +0300 [thread overview]
Message-ID: <b34441c5-e2a8-3791-4402-e0edcb745f06@linux.intel.com> (raw)
In-Reply-To: <65c9f0c2-a269-904d-85ff-3a3c8484328c@windriver.com>
On 06/08/2017 11:29 PM, Mark Hatle wrote:
> Assuming that moving the call earlier (like you did) works, and the static
> values are retrievable by the function. You could have fixed this with the
> snipped below (without storing the values). This would simplify the patch.
>
> (If there is something in the way the threads work with openmp that makes the
> static variable not transfer from the main execution thread to the children
> threads -- that is a different issue and should be stated in the commit.)
Ah, now I get you. You are saying that if these functions are executed
once at the start to pre-populate the static data, then they
subsequently become thread-safe. Unfortunately this is not the case: I
have no idea why this happens, as they would only read static data, but
when I did that (in the first iteration of the patch which used nspr
instead of openmp), there was a very rare, but still happening data
corruption issue. There was no explicit first call, but the first
package was built ahead of others (for other reasons, and it still is),
and that's where the first call happened.
Then I commented out the calls, and the data corruption disappeared.
Then I rewrote the function to eliminate the static data, and it's still
working as expected. Weird! I don't want to spend any more time on this
though.
Then there's my other point: use of static data makes it harder to
reason about code. You need to take into account not only the function
inputs, but also the history of function calls up to the current
execution point. Static data is really a 70s C relic from before threads
were invented.
Alex
next prev parent reply other threads:[~2017-06-09 9:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-08 14:42 [PATCHv2 0/2] Multi-threaded RPM support Alexander Kanavin
2017-06-08 14:42 ` [PATCHv2 1/2] package_rpm.bbclass: use multithreaded xz compression Alexander Kanavin
2017-06-08 14:42 ` [PATCHv2 2/2] rpm: run binary package generation via thread pools Alexander Kanavin
2017-06-08 16:55 ` Mark Hatle
2017-06-08 17:23 ` Alexander Kanavin
2017-06-08 20:29 ` Mark Hatle
2017-06-09 9:02 ` Alexander Kanavin [this message]
2017-06-09 11:18 ` Alexander Kanavin
2017-06-08 21:15 ` [PATCHv2 0/2] Multi-threaded RPM support Leonardo Sandoval
2017-06-09 9:13 ` Alexander Kanavin
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=b34441c5-e2a8-3791-4402-e0edcb745f06@linux.intel.com \
--to=alexander.kanavin@linux.intel.com \
--cc=mark.hatle@windriver.com \
--cc=openembedded-core@lists.openembedded.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