You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by Jie Yu <yu...@gmail.com> on 2013/11/08 02:31:01 UTC
Review Request 15333: Added Owned::share().
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/15333/
-----------------------------------------------------------
Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
Repository: mesos-git
Description
-------
See summary.
Renamed to Shared<T>::upgrade to Shared<T>::own().
Also, moved owned.hpp to libprocess.
Diffs
-----
3rdparty/libprocess/3rdparty/stout/Makefile.am 47e8dbb
3rdparty/libprocess/3rdparty/stout/include/stout/owned.hpp 3433f50
3rdparty/libprocess/Makefile.am d348780
3rdparty/libprocess/include/process/owned.hpp PRE-CREATION
3rdparty/libprocess/include/process/shared.hpp e0c7991
3rdparty/libprocess/include/process/statistics.hpp fbae641
3rdparty/libprocess/src/tests/owned_tests.cpp PRE-CREATION
3rdparty/libprocess/src/tests/shared_tests.cpp 860a9aa
3rdparty/libprocess/src/tests/statistics_tests.cpp 8695f45
src/master/master.hpp e377af8
src/master/master.cpp 8e14a07
src/sched/sched.cpp 3abe72f
src/slave/gc.hpp 083aa79
src/slave/monitor.cpp 9cb6256
src/slave/reaper.hpp 4498139
src/slave/slave.hpp 68526f3
src/tests/cluster.hpp bea395a
Diff: https://reviews.apache.org/r/15333/diff/
Testing
-------
make check
Thanks,
Jie Yu
Re: Review Request 15333: Added Owned::share().
Posted by Jie Yu <yu...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/15333/#review29197
-----------------------------------------------------------
Separated this patch into 3 smaller patches:
1) https://reviews.apache.org/r/15731/ (Refactored Owned and added a function Owned::share())
2) https://reviews.apache.org/r/15732/ (Moved Owned from stout to libprocess)
3) https://reviews.apache.org/r/15739/ (Renamed Shared::upgrade() to Shared::own())
- Jie Yu
On Nov. 8, 2013, 1:30 a.m., Jie Yu wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/15333/
> -----------------------------------------------------------
>
> (Updated Nov. 8, 2013, 1:30 a.m.)
>
>
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
>
>
> Repository: mesos-git
>
>
> Description
> -------
>
> See summary.
>
> Renamed to Shared<T>::upgrade to Shared<T>::own().
>
> Also, moved owned.hpp to libprocess.
>
>
> Diffs
> -----
>
> 3rdparty/libprocess/3rdparty/stout/Makefile.am 47e8dbb
> 3rdparty/libprocess/3rdparty/stout/include/stout/owned.hpp 3433f50
> 3rdparty/libprocess/Makefile.am d348780
> 3rdparty/libprocess/include/process/owned.hpp PRE-CREATION
> 3rdparty/libprocess/include/process/shared.hpp e0c7991
> 3rdparty/libprocess/include/process/statistics.hpp fbae641
> 3rdparty/libprocess/src/tests/owned_tests.cpp PRE-CREATION
> 3rdparty/libprocess/src/tests/shared_tests.cpp 860a9aa
> 3rdparty/libprocess/src/tests/statistics_tests.cpp 8695f45
> src/master/master.hpp e377af8
> src/master/master.cpp 8e14a07
> src/sched/sched.cpp 3abe72f
> src/slave/gc.hpp 083aa79
> src/slave/monitor.cpp 9cb6256
> src/slave/reaper.hpp 4498139
> src/slave/slave.hpp 68526f3
> src/tests/cluster.hpp bea395a
>
> Diff: https://reviews.apache.org/r/15333/diff/
>
>
> Testing
> -------
>
> make check
>
>
> Thanks,
>
> Jie Yu
>
>
Re: Review Request 15333: Added Owned::share().
Posted by Vinod Kone <vi...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/15333/#review28713
-----------------------------------------------------------
Mind splitting this into 2, one for the move and one for the "share()"? That will make it easy to review.
- Vinod Kone
On Nov. 8, 2013, 1:30 a.m., Jie Yu wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/15333/
> -----------------------------------------------------------
>
> (Updated Nov. 8, 2013, 1:30 a.m.)
>
>
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
>
>
> Repository: mesos-git
>
>
> Description
> -------
>
> See summary.
>
> Renamed to Shared<T>::upgrade to Shared<T>::own().
>
> Also, moved owned.hpp to libprocess.
>
>
> Diffs
> -----
>
> 3rdparty/libprocess/3rdparty/stout/Makefile.am 47e8dbb
> 3rdparty/libprocess/3rdparty/stout/include/stout/owned.hpp 3433f50
> 3rdparty/libprocess/Makefile.am d348780
> 3rdparty/libprocess/include/process/owned.hpp PRE-CREATION
> 3rdparty/libprocess/include/process/shared.hpp e0c7991
> 3rdparty/libprocess/include/process/statistics.hpp fbae641
> 3rdparty/libprocess/src/tests/owned_tests.cpp PRE-CREATION
> 3rdparty/libprocess/src/tests/shared_tests.cpp 860a9aa
> 3rdparty/libprocess/src/tests/statistics_tests.cpp 8695f45
> src/master/master.hpp e377af8
> src/master/master.cpp 8e14a07
> src/sched/sched.cpp 3abe72f
> src/slave/gc.hpp 083aa79
> src/slave/monitor.cpp 9cb6256
> src/slave/reaper.hpp 4498139
> src/slave/slave.hpp 68526f3
> src/tests/cluster.hpp bea395a
>
> Diff: https://reviews.apache.org/r/15333/diff/
>
>
> Testing
> -------
>
> make check
>
>
> Thanks,
>
> Jie Yu
>
>
Re: Review Request 15333: Added Owned::share().
Posted by Jie Yu <yu...@gmail.com>.
> On Nov. 17, 2013, 8:53 p.m., Benjamin Hindman wrote:
> > 3rdparty/libprocess/include/process/owned.hpp, line 143
> > <https://reviews.apache.org/r/15333/diff/1/?file=380731#file380731line143>
> >
> > IIUC, you're using 'shared' to protect against two threads/processes from simultaneously calling Owned::share? Why would two threads/processes be doing this in the first place (considering this is supposed to be "owned")? Even if this was the case, I'm not convinced you've got sufficient coverage. Consider: thread 1 context switches before the CAS in Owned::share (line 143) and thread 2 executes Owned::get and context switches before 'return data->t;' (line 106) then thread 1 resumes and does 'data.reset()' which means thread 2 is going to deference a NULL pointer when it resumes. Unless I'm missing something?
To answer your first question, we saw many places in the code that copy Owned pointers (i.e., two Owned pointers holding the same object).
Therefore, I decided to provide the following semantics:
1) if there is only one Owned pointer holding the object, we should have no problem doing Owned::share()
2) if there are more than one Owned pointers holding the object, only one of them may successfully do Owned:shared(), other Owned's operations (e.g. ->, get(), etc.) should fail after the ownership has been transferred. In that case, we try to provide as many diagnosis information as possible such as a CHECK.
In your case, the program won't crash because thread 2 is still holding the reference to Data object, therefore, it will not be deleted even if thread 1 calls 'data.reset()'.
However, it's likely that data->t will be deleted by the Shared object (because it is out of scope later), and we are trying to dereference data->t through the Owned pointer in thread 2, which is bad.
Probably what we can do is: instead of using a separate boolean flag, we use the data->t itself to distinguish if it is shared or not. In other words, if data->t is NULL, then it is shared, otherwise, it is not.
Thoughts?
- Jie
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/15333/#review29028
-----------------------------------------------------------
On Nov. 8, 2013, 1:30 a.m., Jie Yu wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/15333/
> -----------------------------------------------------------
>
> (Updated Nov. 8, 2013, 1:30 a.m.)
>
>
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
>
>
> Repository: mesos-git
>
>
> Description
> -------
>
> See summary.
>
> Renamed to Shared<T>::upgrade to Shared<T>::own().
>
> Also, moved owned.hpp to libprocess.
>
>
> Diffs
> -----
>
> 3rdparty/libprocess/3rdparty/stout/Makefile.am 47e8dbb
> 3rdparty/libprocess/3rdparty/stout/include/stout/owned.hpp 3433f50
> 3rdparty/libprocess/Makefile.am d348780
> 3rdparty/libprocess/include/process/owned.hpp PRE-CREATION
> 3rdparty/libprocess/include/process/shared.hpp e0c7991
> 3rdparty/libprocess/include/process/statistics.hpp fbae641
> 3rdparty/libprocess/src/tests/owned_tests.cpp PRE-CREATION
> 3rdparty/libprocess/src/tests/shared_tests.cpp 860a9aa
> 3rdparty/libprocess/src/tests/statistics_tests.cpp 8695f45
> src/master/master.hpp e377af8
> src/master/master.cpp 8e14a07
> src/sched/sched.cpp 3abe72f
> src/slave/gc.hpp 083aa79
> src/slave/monitor.cpp 9cb6256
> src/slave/reaper.hpp 4498139
> src/slave/slave.hpp 68526f3
> src/tests/cluster.hpp bea395a
>
> Diff: https://reviews.apache.org/r/15333/diff/
>
>
> Testing
> -------
>
> make check
>
>
> Thanks,
>
> Jie Yu
>
>
Re: Review Request 15333: Added Owned::share().
Posted by Benjamin Hindman <be...@berkeley.edu>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/15333/#review29028
-----------------------------------------------------------
3rdparty/libprocess/include/process/owned.hpp
<https://reviews.apache.org/r/15333/#comment56113>
IIUC, you're using 'shared' to protect against two threads/processes from simultaneously calling Owned::share? Why would two threads/processes be doing this in the first place (considering this is supposed to be "owned")? Even if this was the case, I'm not convinced you've got sufficient coverage. Consider: thread 1 context switches before the CAS in Owned::share (line 143) and thread 2 executes Owned::get and context switches before 'return data->t;' (line 106) then thread 1 resumes and does 'data.reset()' which means thread 2 is going to deference a NULL pointer when it resumes. Unless I'm missing something?
3rdparty/libprocess/include/process/shared.hpp
<https://reviews.apache.org/r/15333/#comment56112>
How about: "Transfers ownership of the pointer by waiting for exclusive access (i.e., no other Shared instances). ..."
3rdparty/libprocess/include/process/shared.hpp
<https://reviews.apache.org/r/15333/#comment56111>
How about: "Ownership is already being transferred".
- Benjamin Hindman
On Nov. 8, 2013, 1:30 a.m., Jie Yu wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/15333/
> -----------------------------------------------------------
>
> (Updated Nov. 8, 2013, 1:30 a.m.)
>
>
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
>
>
> Repository: mesos-git
>
>
> Description
> -------
>
> See summary.
>
> Renamed to Shared<T>::upgrade to Shared<T>::own().
>
> Also, moved owned.hpp to libprocess.
>
>
> Diffs
> -----
>
> 3rdparty/libprocess/3rdparty/stout/Makefile.am 47e8dbb
> 3rdparty/libprocess/3rdparty/stout/include/stout/owned.hpp 3433f50
> 3rdparty/libprocess/Makefile.am d348780
> 3rdparty/libprocess/include/process/owned.hpp PRE-CREATION
> 3rdparty/libprocess/include/process/shared.hpp e0c7991
> 3rdparty/libprocess/include/process/statistics.hpp fbae641
> 3rdparty/libprocess/src/tests/owned_tests.cpp PRE-CREATION
> 3rdparty/libprocess/src/tests/shared_tests.cpp 860a9aa
> 3rdparty/libprocess/src/tests/statistics_tests.cpp 8695f45
> src/master/master.hpp e377af8
> src/master/master.cpp 8e14a07
> src/sched/sched.cpp 3abe72f
> src/slave/gc.hpp 083aa79
> src/slave/monitor.cpp 9cb6256
> src/slave/reaper.hpp 4498139
> src/slave/slave.hpp 68526f3
> src/tests/cluster.hpp bea395a
>
> Diff: https://reviews.apache.org/r/15333/diff/
>
>
> Testing
> -------
>
> make check
>
>
> Thanks,
>
> Jie Yu
>
>
Re: Review Request 15333: Added Owned::share().
Posted by Jie Yu <yu...@gmail.com>.
> On Nov. 8, 2013, 9:42 p.m., Ben Mahler wrote:
> > Why did you move this into libprocess?
> >
> > Can you split this change into separate reviews for libprocess / stout / mesos?
Shared<T> has to be in libprocess since it involves Future.
Since Owned<T>::share() returns a Shared<T>, Owned<T> has to be in libprocess also.
Also, Shared<T> and Owned<T> are related to concurrency, thus I think libprocess is a better fit? Thoughts?
- Jie
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/15333/#review28578
-----------------------------------------------------------
On Nov. 8, 2013, 1:30 a.m., Jie Yu wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/15333/
> -----------------------------------------------------------
>
> (Updated Nov. 8, 2013, 1:30 a.m.)
>
>
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
>
>
> Repository: mesos-git
>
>
> Description
> -------
>
> See summary.
>
> Renamed to Shared<T>::upgrade to Shared<T>::own().
>
> Also, moved owned.hpp to libprocess.
>
>
> Diffs
> -----
>
> 3rdparty/libprocess/3rdparty/stout/Makefile.am 47e8dbb
> 3rdparty/libprocess/3rdparty/stout/include/stout/owned.hpp 3433f50
> 3rdparty/libprocess/Makefile.am d348780
> 3rdparty/libprocess/include/process/owned.hpp PRE-CREATION
> 3rdparty/libprocess/include/process/shared.hpp e0c7991
> 3rdparty/libprocess/include/process/statistics.hpp fbae641
> 3rdparty/libprocess/src/tests/owned_tests.cpp PRE-CREATION
> 3rdparty/libprocess/src/tests/shared_tests.cpp 860a9aa
> 3rdparty/libprocess/src/tests/statistics_tests.cpp 8695f45
> src/master/master.hpp e377af8
> src/master/master.cpp 8e14a07
> src/sched/sched.cpp 3abe72f
> src/slave/gc.hpp 083aa79
> src/slave/monitor.cpp 9cb6256
> src/slave/reaper.hpp 4498139
> src/slave/slave.hpp 68526f3
> src/tests/cluster.hpp bea395a
>
> Diff: https://reviews.apache.org/r/15333/diff/
>
>
> Testing
> -------
>
> make check
>
>
> Thanks,
>
> Jie Yu
>
>
Re: Review Request 15333: Added Owned::share().
Posted by Ben Mahler <be...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/15333/#review28578
-----------------------------------------------------------
Why did you move this into libprocess?
Can you split this change into separate reviews for libprocess / stout / mesos?
- Ben Mahler
On Nov. 8, 2013, 1:30 a.m., Jie Yu wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/15333/
> -----------------------------------------------------------
>
> (Updated Nov. 8, 2013, 1:30 a.m.)
>
>
> Review request for mesos, Benjamin Hindman, Ben Mahler, and Vinod Kone.
>
>
> Repository: mesos-git
>
>
> Description
> -------
>
> See summary.
>
> Renamed to Shared<T>::upgrade to Shared<T>::own().
>
> Also, moved owned.hpp to libprocess.
>
>
> Diffs
> -----
>
> 3rdparty/libprocess/3rdparty/stout/Makefile.am 47e8dbb
> 3rdparty/libprocess/3rdparty/stout/include/stout/owned.hpp 3433f50
> 3rdparty/libprocess/Makefile.am d348780
> 3rdparty/libprocess/include/process/owned.hpp PRE-CREATION
> 3rdparty/libprocess/include/process/shared.hpp e0c7991
> 3rdparty/libprocess/include/process/statistics.hpp fbae641
> 3rdparty/libprocess/src/tests/owned_tests.cpp PRE-CREATION
> 3rdparty/libprocess/src/tests/shared_tests.cpp 860a9aa
> 3rdparty/libprocess/src/tests/statistics_tests.cpp 8695f45
> src/master/master.hpp e377af8
> src/master/master.cpp 8e14a07
> src/sched/sched.cpp 3abe72f
> src/slave/gc.hpp 083aa79
> src/slave/monitor.cpp 9cb6256
> src/slave/reaper.hpp 4498139
> src/slave/slave.hpp 68526f3
> src/tests/cluster.hpp bea395a
>
> Diff: https://reviews.apache.org/r/15333/diff/
>
>
> Testing
> -------
>
> make check
>
>
> Thanks,
>
> Jie Yu
>
>