pcp updates: libpcp locking and concurrency control changes
"Ken McDonell" <[email protected]> Mon, 16 Jan 2017 07:39:36 +1100
| Newsgroups | gmane.comp.sysutils.pcp |
|---|---|
| Message-ID | <[email protected]> |
Note this is a new branch (threadsafe) in my git tree, not the master branch. These changes need review eyes before being pulled into the master branch.
This is the first stage of (a long) project to refactor the locking and concurrency control in libpcp.
From the commit message ...
With these changes, the use of __pmLock_libpcp has been roughly
halved from 98 locks calls in 23 source files, down to 52 lock calls
in 12 source files. Additionally the lock ordering of the new local
mutexes and __pmLock_extcall ensures these ones are deadlock free.
I can see no QA regressions on Ubuntu 16.04 after running full QA repeatedly for over 24 hours, and I'm part way through a full QA run on RHEL Server 7.2 (vm29) with no issues to date.
Next stage in the plan will be to further reduce the use of the __pmLock_libpcp (the big lock).
Once this is done, I plan to focus on the _real_ concurrency and locking problem(s) around pmns, context and pmcd channel locking.
Changes committed to git://git.pcp.io/kenj/pcp threadsafe
Ken McDonell (11):
src/libpcp/doc: add find-posix-unsafe
src/libpcp/doc: updates
src/libpcp/src: add __pmLock_extcall
libpcp: missing bits for __pmLock_extcall
src/libpcp/doc: find-unsafe changes
src/libpcp: second round of __pmLock_extcall changes
src/libpcp: more __pmLock_extcall and localmutex changes
src/libpcp: more __pmLock_extcall and localmutex changes
src/libpcp/doc: control file, scripts and documentation changes
src/libpcp/doc/libpcp-locking.odt: finally got spelling checking working
src/libpcp: further __pmLock_extcall and local mutex changes
qa/512.out | 54 +++++++++-
src/include/pcp/impl.h | 6 -
src/libpcp/doc/GNUmakefile | 44 +++++++-
src/libpcp/doc/README | 16 ++-
src/libpcp/doc/find-posix-unsafe | 200 +++++++++++++++++++-------------------
src/libpcp/doc/find-unsafe | 190 +++++++++++++++++++++++++++++++++---
src/libpcp/doc/glibc.safe | 37 +++++++
src/libpcp/doc/glibc.unsafe | 14 +-
src/libpcp/doc/libpcp-locking.odt |binary
src/libpcp/doc/mk.cgraph | 31 ++++-
src/libpcp/doc/other.safe | 118 +++++++++++++++++-----
src/libpcp/doc/other.unsafe | 44 ++++++++
src/libpcp/doc/posix.unsafe | 7 -
src/libpcp/src/AF.c | 3
src/libpcp/src/access.c | 14 ++
src/libpcp/src/accounts.c | 168 +++++++++++++++++++++----------
src/libpcp/src/auxconnect.c | 135 +++++++++++++++++--------
src/libpcp/src/auxserver.c | 53 ++++++----
src/libpcp/src/avahi.c | 24 +++-
src/libpcp/src/check-statics | 79 ++++++++-------
src/libpcp/src/config.c | 135 ++++++++++++++++---------
src/libpcp/src/connect.c | 7 +
src/libpcp/src/connectlocal.c | 12 ++
src/libpcp/src/context.c | 70 +++++++++----
src/libpcp/src/derive.c | 82 +++++++++++----
src/libpcp/src/discovery.c | 3
src/libpcp/src/err.c | 13 +-
src/libpcp/src/exports | 4
src/libpcp/src/fault.c | 61 ++++++++---
src/libpcp/src/getopt.c | 13 +-
src/libpcp/src/internal.h | 8 +
src/libpcp/src/interp.c | 7 -
src/libpcp/src/lock.c | 43 ++++++--
src/libpcp/src/logconnect.c | 37 ++++---
src/libpcp/src/logutil.c | 23 +++-
src/libpcp/src/optfetch.c | 2
src/libpcp/src/pdu.c | 57 ++++++++--
src/libpcp/src/pdubuf.c | 95 ++++++++++--------
src/libpcp/src/pmns.c | 5
src/libpcp/src/tz.c | 99 ++++++++----------
src/libpcp/src/util.c | 165 ++++++++++++++++++++-----------
src/libpcp/src/win32.c | 27 +++--
42 files changed, 1559 insertions(+), 646 deletions(-)
Details ...
commit 00506ded32770a74358c6e6aa9827d1d2d5b2264
Author: Ken McDonell <[email protected]>
Date: Mon Jan 16 06:18:57 2017 +1100
src/libpcp: further __pmLock_extcall and local mutex changes
Another checkpoint commit, with no QA regressions.
The __pmLock_extcall and localmutex changes are almost done with this
round of changes.
I still need to work through secureconnect.c and secureserver.c,
and there remain a handful of cleanups needed in win32.c.
With these changes, the use of __pmLock_libpcp has been roughly
halved from 98 locks calls in 23 source files, down to 52 lock calls
in 12 source files. Additionally the lock ordering of the new local
mutexes and __pmLock_extcall ensures these ones are deadlock free.
commit 085770135e455b47169ac8f2ca4aa57a4b778a29
Author: Ken McDonell <[email protected]>
Date: Fri Jan 6 14:22:42 2017 +1100
src/libpcp/doc/libpcp-locking.odt: finally got spelling checking working
commit b42d917afff87cb1be2631dbb145d23799f9bf3b
Author: Ken McDonell <[email protected]>
Date: Fri Jan 6 14:09:46 2017 +1100
src/libpcp/doc: control file, scripts and documentation changes
Control files and scripts now complete - processing all of the libpcp
source.
Documentation is still WIP.
commit 07af1f7246d70125788f0e825a3ce272545c8d3d
Author: Ken McDonell <[email protected]>
Date: Fri Jan 6 13:58:08 2017 +1100
src/libpcp: more __pmLock_extcall and localmutex changes
Fix a couple of missing or misplaced PM_UNLOCK() calls, small
cosmetic changes.
This is a checkpoint commit, as with these changes there are
no QA regressions.
Still more to be done ... auditing for unsafe calls still
required for another 17 source files in libpcp.
commit 6e7873b8f341da7066bb3fc43ce124d0a68da3e3
Author: Ken McDonell <[email protected]>
Date: Wed Jan 4 21:05:37 2017 +1100
src/libpcp: more __pmLock_extcall and localmutex changes
- being consistent about the use of __pmLock_extcall for calls
to external routines that are not thread-safe
- introduce localmutex to be used to protect statics in a source
file where the only lock that can be acquired after localmutex
is __pmLock_extcall ... this is the start of a formal lock
ordering hierarchy
- both of these changes are WIP as we're moving through the source
files of libpcp
commit b89e3fc1a9c5832aea06f5c2a52aa391e524ea04
Author: Ken McDonell <[email protected]>
Date: Thu Dec 29 06:30:46 2016 +1100
src/libpcp: second round of __pmLock_extcall changes
- replace some calls to unsafe routine by calls to their thread safe
counterparts
- re-audit the lock-unlock scopes to ensure that the lock is not
released until we've finished with (or copied) the data from the
unsafe call that may be changed by a subsequent call, e.g. the
value at the end of the pointer returned from getenv()
commit adbbb1266092c5ed5302397ac4ceac8c823fdbd6
Author: Ken McDonell <[email protected]>
Date: Thu Dec 29 06:24:26 2016 +1100
src/libpcp/doc: find-unsafe changes
- renamed from find-posix-unsafe to find-unsafe (so we can check
with the other *.unsafe control files)
- add -u option to specify one or more *.unsafe files
- don't scan comments by default (add -c to revert to previous
behaviour where comments were scanned for "function calls")
- change from sed(1) to awk(1) for final pass filter and reporting,
so output format is easier to read, e.g.
../src/auxserver.c: <-- file name first
--- 106,110 --- <-- line number range
int new_nports = nports;
+ if ((env = getenv("PMCD_PORT")) != NULL) <-- matching line
new_nports = __pmAddPorts(env, ports, nports);
<-- blank line
--- 134,138 --- <-- next line number range
...
commit edb78b9f5ec04f428ee52a4836ffca0d2062d8ee
Author: Ken McDonell <[email protected]>
Date: Wed Dec 21 10:12:03 2016 +1100
libpcp: missing bits for __pmLock_extcall
- impl.h declaration
- libpcp exports
commit 1acd16632b52efe663c2524d8df6b37fd51b2327
Author: Ken McDonell <[email protected]>
Date: Wed Dec 21 10:06:49 2016 +1100
src/libpcp/src: add __pmLock_extcall
First round of changes for this new mutex. It is designed to be the
last on the call hierarchy (no other locks can be acquired while
__pmLock_extcall is held) and is designed for short-duration locking
while external routines that are not thread-safe are called.
This reduces some of the use of __pmLock_libpcp, so we're able to
focus on cleaning up the use of that mutex later.
commit 5570bc56c651fea2529f0fd6e7493a615466d8e4
Author: Ken McDonell <[email protected]>
Date: Wed Dec 21 10:04:19 2016 +1100
src/libpcp/doc: updates
Some more documentation, script refinement and additions to the
safe/unsafe control files.
commit afa0704202cb39849d71cc6e46d2464a4f0a82a0
Author: Ken McDonell <[email protected]>
Date: Wed Dec 21 09:59:48 2016 +1100
src/libpcp/doc: add find-posix-unsafe
Hunt through source looking for calls to routines that POSIX has
declared to be unsafe for threaded use.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links:
You receive all messages sent to this group.
View/Reply Online (#14976): https://groups.io/g/pcp/message/14976
View All Messages In Topic (1): https://groups.io/g/pcp/topic/4185439
Mute This Topic: https://groups.io/mt/4185439?uid=174580
New Topic: https://groups.io/g/pcp/post
-=-=-
pcp mailing list
[email protected]
https://groups.io/g/pcp/messages
-=-=-
Change Your Subscription: https://groups.io/g/pcp/editsub?uid=174580
Group Home: https://groups.io/g/pcp
Contact Group Owner: [email protected]
Terms of Service: https://groups.io/static/tos
Unsubscribe: https://groups.io/g/pcp/leave/354243/563757577/xyzzy
-=-=-=-=-=-=-=-=-=-=-=-