Openembedded Core Discussions
 help / color / mirror / Atom feed
* Oddness regarding file locks in package.bbclass
@ 2017-10-03 18:17 Peter Kjellerstedt
  2017-10-04 15:10 ` Burton, Ross
  2018-04-19 22:03 ` Richard Purdie
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Kjellerstedt @ 2017-10-03 18:17 UTC (permalink / raw)
  To: OE Core (openembedded-core@lists.openembedded.org)

I just stumbled upon something odd in package.bbclass. In commit 
ede381d5 from January 2011 (the code hasn't changed since), the 
use of the ${PACKAGELOCK} lock file was changed to shared to 
improve parallelism. However, when looking at the actual change 
it becomes confusing. I have included it below for reference.

> commit ede381d56b180b384fdad98d445e5430819cfade
> Author: Richard Purdie <richard.purdie@linuxfoundation.org>
> Date:   Wed Jan 19 11:04:15 2011 +0000
> 
>     package.bbclass: Take a shared lock when reading to improve do_package parallelism
>     
>     Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
> 
> diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
> index d39c694de5..8e7fa26f72 100644
> --- a/meta/classes/package.bbclass
> +++ b/meta/classes/package.bbclass
> @@ -497,7 +497,8 @@ python emit_pkgdata() {
>  	pkgdest = bb.data.getVar('PKGDEST', d, 1)
>  	pkgdatadir = bb.data.getVar('PKGDESTWORK', d, True)
>  
> -	lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}", d))
> +	# Take shared lock since we're only reading, not writing
> +	lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}", d), True)

Here the lock is changed to shared as per the commit message.

>  
>  	data_file = pkgdatadir + bb.data.expand("/${PN}" , d)
>  	f = open(data_file, 'w')
> @@ -649,6 +650,7 @@ python package_do_shlibs() {
>  	shlibs_dir = bb.data.getVar('SHLIBSDIR', d, True)
>  	shlibswork_dir = bb.data.getVar('SHLIBSWORKDIR', d, True)
>  
> +	# Take shared lock since we're only reading, not writing
>  	lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}", d))

Here, however, it is not changed, even though a comment is added to 
say that it is. Was this intentional, or just an oversight?

>  
>  	def linux_so(root, path, file):
> @@ -878,6 +880,7 @@ python package_do_pkgconfig () {
>  							if hdr == 'Requires':
>  								pkgconfig_needed[pkg] += exp.replace(',', ' ').split()
>  
> +	# Take shared lock since we're only reading, not writing
>  	lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}", d))

Here again a comment is added, but the code is not changed to match.

>  
>  	for pkg in packages.split():

Also, what is the ${PACKAGELOCK} lock file actually protecting? With 
the exception of the two questionable cases above, I cannot see that 
the lock is taken privately anywhere else. And since it looks as the 
code in package_do_shlibs() and package_do_pkgconfig() is not what 
needs protection (based on the added comments above), what is?

//Peter



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Oddness regarding file locks in package.bbclass
  2017-10-03 18:17 Oddness regarding file locks in package.bbclass Peter Kjellerstedt
@ 2017-10-04 15:10 ` Burton, Ross
  2018-03-23 15:05   ` Trevor Woerner
  2018-04-19 22:03 ` Richard Purdie
  1 sibling, 1 reply; 4+ messages in thread
From: Burton, Ross @ 2017-10-04 15:10 UTC (permalink / raw)
  To: Peter Kjellerstedt; +Cc: OE Core (openembedded-core@lists.openembedded.org)

[-- Attachment #1: Type: text/plain, Size: 1186 bytes --]

On 3 October 2017 at 19:17, Peter Kjellerstedt <peter.kjellerstedt@axis.com>
wrote:

> > +     # Take shared lock since we're only reading, not writing
> >       lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}", d))
>
> Here, however, it is not changed, even though a comment is added to
> say that it is. Was this intentional, or just an oversight?
>
> > +     # Take shared lock since we're only reading, not writing
> >       lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}", d))
>
> Here again a comment is added, but the code is not changed to match.


I'm no expert on this piece of code but that definitely looks like an
oversight.


> Also, what is the ${PACKAGELOCK} lock file actually protecting? With
>
the exception of the two questionable cases above, I cannot see that
> the lock is taken privately anywhere else. And since it looks as the
> code in package_do_shlibs() and package_do_pkgconfig() is not what
> needs protection (based on the added comments above), what is?
>

Good point.  The sstate locks are also shared.

Richard was involved in all of these changes so lets wait for him to return
from his holiday...

Ross

[-- Attachment #2: Type: text/html, Size: 2086 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Oddness regarding file locks in package.bbclass
  2017-10-04 15:10 ` Burton, Ross
@ 2018-03-23 15:05   ` Trevor Woerner
  0 siblings, 0 replies; 4+ messages in thread
From: Trevor Woerner @ 2018-03-23 15:05 UTC (permalink / raw)
  To: Richard Purdie
  Cc: Peter Kjellerstedt,
	OE Core (openembedded-core@lists.openembedded.org)

[-- Attachment #1: Type: text/plain, Size: 1573 bytes --]

This item doesn't appear to have a follow-up.

On Wed, Oct 4, 2017 at 11:10 AM, Burton, Ross <ross.burton@intel.com> wrote:

> On 3 October 2017 at 19:17, Peter Kjellerstedt <
> peter.kjellerstedt@axis.com> wrote:
>
>> > +     # Take shared lock since we're only reading, not writing
>> >       lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}", d))
>>
>> Here, however, it is not changed, even though a comment is added to
>> say that it is. Was this intentional, or just an oversight?
>>
>> > +     # Take shared lock since we're only reading, not writing
>> >       lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}", d))
>>
>> Here again a comment is added, but the code is not changed to match.
>
>
> I'm no expert on this piece of code but that definitely looks like an
> oversight.
>
>
>> Also, what is the ${PACKAGELOCK} lock file actually protecting? With
>>
> the exception of the two questionable cases above, I cannot see that
>> the lock is taken privately anywhere else. And since it looks as the
>> code in package_do_shlibs() and package_do_pkgconfig() is not what
>> needs protection (based on the added comments above), what is?
>>
>
> Good point.  The sstate locks are also shared.
>
> Richard was involved in all of these changes so lets wait for him to
> return from his holiday...
>
> Ross
>
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>
>

[-- Attachment #2: Type: text/html, Size: 3075 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Oddness regarding file locks in package.bbclass
  2017-10-03 18:17 Oddness regarding file locks in package.bbclass Peter Kjellerstedt
  2017-10-04 15:10 ` Burton, Ross
@ 2018-04-19 22:03 ` Richard Purdie
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Purdie @ 2018-04-19 22:03 UTC (permalink / raw)
  To: Peter Kjellerstedt,
	OE Core (openembedded-core@lists.openembedded.org)

On Tue, 2017-10-03 at 18:17 +0000, Peter Kjellerstedt wrote:
> I just stumbled upon something odd in package.bbclass. In commit 
> ede381d5 from January 2011 (the code hasn't changed since), the 
> use of the ${PACKAGELOCK} lock file was changed to shared to 
> improve parallelism. However, when looking at the actual change 
> it becomes confusing. I have included it below for reference.
> 
> > 
> > commit ede381d56b180b384fdad98d445e5430819cfade
> > Author: Richard Purdie <richard.purdie@linuxfoundation.org>
> > Date:   Wed Jan 19 11:04:15 2011 +0000
> > 
> >     package.bbclass: Take a shared lock when reading to improve
> > do_package parallelism
> >     
> >     Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.o
> > rg>
> > 
> > diff --git a/meta/classes/package.bbclass
> > b/meta/classes/package.bbclass
> > index d39c694de5..8e7fa26f72 100644
> > --- a/meta/classes/package.bbclass
> > +++ b/meta/classes/package.bbclass
> > @@ -497,7 +497,8 @@ python emit_pkgdata() {
> >  	pkgdest = bb.data.getVar('PKGDEST', d, 1)
> >  	pkgdatadir = bb.data.getVar('PKGDESTWORK', d, True)
> >  
> > -	lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}",
> > d))
> > +	# Take shared lock since we're only reading, not writing
> > +	lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}",
> > d), True)
> Here the lock is changed to shared as per the commit message.
> 
> > 
> >  
> >  	data_file = pkgdatadir + bb.data.expand("/${PN}" , d)
> >  	f = open(data_file, 'w')
> > @@ -649,6 +650,7 @@ python package_do_shlibs() {
> >  	shlibs_dir = bb.data.getVar('SHLIBSDIR', d, True)
> >  	shlibswork_dir = bb.data.getVar('SHLIBSWORKDIR', d, True)
> >  
> > +	# Take shared lock since we're only reading, not writing
> >  	lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}",
> > d))
> Here, however, it is not changed, even though a comment is added to 
> say that it is. Was this intentional, or just an oversight?
> 
> > 
> >  
> >  	def linux_so(root, path, file):
> > @@ -878,6 +880,7 @@ python package_do_pkgconfig () {
> >  							if hdr ==
> > 'Requires':
> >  								pk
> > gconfig_needed[pkg] += exp.replace(',', ' ').split()
> >  
> > +	# Take shared lock since we're only reading, not writing
> >  	lf = bb.utils.lockfile(bb.data.expand("${PACKAGELOCK}",
> > d))
> Here again a comment is added, but the code is not changed to match.
> 
> > 
> >  
> >  	for pkg in packages.split():
> Also, what is the ${PACKAGELOCK} lock file actually protecting? With 
> the exception of the two questionable cases above, I cannot see that 
> the lock is taken privately anywhere else. And since it looks as the 
> code in package_do_shlibs() and package_do_pkgconfig() is not what 
> needs protection (based on the added comments above), what is?

Sorry for not replying sooner, this was brought to my attention again.

PACKAGELOCK is there for PKGDATA_DIR which is defined as
${TMPDIR}/pkgdata/${MACHINE}, i.e. not recipe specific.

If something is reading files from pkgdata and something else
writes/changes them, we used to see build failures. The lock therefore
does have a purpose in guarding against this.

Looking at the code, something has gotten lost with the addition of
recipe specific sysroots and the separation of do_packagedata from
do_package.

I suspect it needs:

-do_packagedata[sstate-lockfile-shared] = "${PACKAGELOCK}"
+do_packagedata[sstate-lockfile] = "${PACKAGELOCK}"

and the other sites you mention should be shared locks, then this would
all make a lot more sense.

Cheers,

Richard









^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-19 22:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-03 18:17 Oddness regarding file locks in package.bbclass Peter Kjellerstedt
2017-10-04 15:10 ` Burton, Ross
2018-03-23 15:05   ` Trevor Woerner
2018-04-19 22:03 ` Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox