This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, Libatomic, Darwin] Initial libatomic port for *darwin*.
- From: Iain Sandoe <iain at codesourcery dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Joseph Myers <joseph at codesourcery dot com>, gcc-patches Patches <gcc-patches at gcc dot gnu dot org>, Mike Stump <mikestump at comcast dot net>
- Date: Fri, 14 Nov 2014 08:44:58 +0000
- Subject: Re: [PATCH, Libatomic, Darwin] Initial libatomic port for *darwin*.
- Authentication-results: sourceware.org; auth=none
- References: <BF9E148F-40E0-4B10-AAE2-C1FDE7F757E7 at codesourcery dot com> <5464606E dot 4080907 at redhat dot com> <6228E2F0-3E10-4F77-92DE-9412E5325284 at codesourcery dot com> <5465B6F1 dot 6080705 at redhat dot com> <229043AC-78C9-49D4-B9D1-D5BA3B66D5CB at codesourcery dot com> <5465BC74 dot 5000709 at redhat dot com>
On 14 Nov 2014, at 08:25, Richard Henderson wrote:
> On 11/14/2014 09:12 AM, Iain Sandoe wrote:
>> my locks are only 4 bytes [whereas they are rounded-up-to-n-cachlines(sizeof(pthreads mutext)) for the posix implementation].
>> The items that they are locking are of arbitrary size (at least up to one page).
>>
>> hmmm .. there's something I'm not following about what you are seeing as a problem here.
>>
>> In the posix implementation the granularity calculation is also used to
>> round up the space allocated in the locks table for each pthreads mutex
>> (i.e. it has two uses, AFAICT).
>
> No, there's only one use: How large an area is *protected* by the lock.
>
> Since we need to protect one page of these areas, we need NLOCKS = PAGE_SIZE /
> WATCH_SIZE locks, which are then allocated in an array. We do not care how
> large that array is.
>
> So if you'd like to differ from the posix implementation in protecting
> 4 bytes at a time, rather than one cacheline at a time, then just change
> WATCH_SIZE to 4. The fact that WATCH_SIZE happens to equal to the lock size is
> simply a coincidence.
Indeed (the use to round up the space allocated for the mutex also happens to be another co-incidence)
However, my intention is to have a variable-sized area protected by each locks.
The nummber of locks allocated exceeds (page-size/watch-size) [unless watch-sizes was reduced to 4bytes, of course]
Only when the size of the area to be protected exceeds one cache-line do I split it up into cache-line-sized chunks.
I happened to allocate one-page-worth of locks (as a somewhat arbitrary choice in the absence of metrics to guide otherwise) - which is another source of co-incidence.
Perhaps some re-naming of things would help, or do you think that a scheme to lock variable-sized chunks cannot work?
Iain
- References:
- [PATCH, Libatomic, Darwin] Initial libatomic port for *darwin*.
- Re: [PATCH, Libatomic, Darwin] Initial libatomic port for *darwin*.
- Re: [PATCH, Libatomic, Darwin] Initial libatomic port for *darwin*.
- Re: [PATCH, Libatomic, Darwin] Initial libatomic port for *darwin*.
- Re: [PATCH, Libatomic, Darwin] Initial libatomic port for *darwin*.
- Re: [PATCH, Libatomic, Darwin] Initial libatomic port for *darwin*.