Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugins for negotiation

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Micha? Miros?aw <mirqus@...>
Cc: <davem@...>, <dccp@...>, <netdev@...>
Date: Tuesday, December 16, 2008 - 1:55 am

| > | > +static int ccid_request_module(u8 id)
| > | > +{
| > | > +       if (!in_atomic()) {
| > | > +               ccids_read_lock();
| > | > +               if (ccids[id] == NULL) {
| > | > +                       ccids_read_unlock();
| > | > +                       return request_module("net-dccp-ccid-%d", id);
| > | > +               }
| > | > +               ccids_read_unlock();
| > | > +       }
| > | > +       return 0;
| > | > +}
| > |
| > | Just a random thought: does this lock really do anything useful here?
| > |
| > Reading the (shared) 'ccids' array is the solution chosen to check whether
| > the module for CCID with number 'id' is already loaded.
| >
| > It would be bad to call request_module() each time a new DCCP socket is
| > opened. Using the 'ccids' array may not be the only way to check whether
| > a given module (whose name depends on the value of 'id') is loaded.
| >
| > But if this solution is chosen, then it requires to protect the read
| > access to 'ccids', which is shared among all DCCP sockets.
| 
| Since the lock is dropped after checking ccids[id] then there's
| a window where multiple request_module()s can be called if multiple
| applications create a DCCP socket at a same time. The code below
| should do the same without a lock (ccids is a static array,
| so ccids[N] is always at the same place).
| 
| static int ccid_request_module(u8 id)
| {
|        if (!in_atomic()) {
|                rmb();
|                if (ccids[id] == NULL)
|                        return request_module("net-dccp-ccid-%d", id);
|        }
|        return 0;
| }
| 
Sorry Michael, but this is really just a "random thought". What you are
in effect saying is that reader/writer locks can be replaced with just a
read memory barrier.

Please have a more detailed look at net/dccp/ccid.c. I also checked how
other subsystems handle comparable situations of module loading: the 
implementation details differ, but the principle is the same: there are
mutexes, semaphores, and spinlocks in use to protect those shared
structures that are related to the loaded module.

Hence your suggestion does not improve the code. I maintain that it is
correct. And it has proven to work in the test tree for more than one
year, including tests with up to 100 parallel (iperf) connections.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 03/37] dccp: List management for new feature nego..., Arnaldo Carvalho de Melo, (Thu Aug 28, 3:43 pm)
Re: [PATCH 0/37] --- Summary of revision changes so far, Gerrit Renker, (Sat Aug 30, 1:25 pm)
Re: net-next-2.6 [pull-request] [PATCH 0/37] dccp: Revised s..., Arnaldo Carvalho de Melo, (Tue Sep 2, 9:50 am)
Re: [PATCH 1/5] dccp: Basic data structure for feature negot..., Arnaldo Carvalho de Melo, (Mon Sep 22, 10:10 am)
Re: [PATCH 2/5] dccp: Implement lookup table for feature-neg..., Arnaldo Carvalho de Melo, (Mon Sep 22, 10:21 am)
Re: v2 [PATCH 2/5] dccp: Implement lookup table for feature-..., Arnaldo Carvalho de Melo, (Wed Sep 24, 10:01 am)
Re: v2 [PATCH 1/5] dccp: Basic data structure for feature ne..., Arnaldo Carvalho de Melo, (Wed Sep 24, 9:59 am)
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugin..., Arnaldo Carvalho de Melo, (Mon Dec 15, 9:48 am)
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugin..., Michał Mirosław, (Sat Dec 13, 9:55 am)
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugin..., Michał Mirosław, (Sun Dec 14, 10:50 am)
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugin..., Gerrit Renker, (Tue Dec 16, 1:55 am)
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugin..., Michał Mirosław, (Tue Dec 16, 7:31 am)
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugin..., Arnaldo Carvalho de Melo, (Tue Dec 16, 7:19 am)
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugin..., Arnaldo Carvalho de Melo, (Tue Dec 16, 6:25 pm)
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugin..., Arnaldo Carvalho de Melo, (Wed Dec 17, 9:13 am)
Re: [PATCH 2/5] dccp: Auto-load (when supported) CCID plugin..., Arnaldo Carvalho de Melo, (Thu Dec 18, 10:01 am)
Re: [PATCH 4/5] dccp: Initialisation and type-checking of fe..., Arnaldo Carvalho de Melo, (Mon Dec 15, 10:15 am)
[PATCH 3/6] dccp: Preference list reconciliation, Gerrit Renker, (Sun Nov 30, 9:22 am)
[PATCH 5/6] dccp: Processing Confirm options, Gerrit Renker, (Sun Nov 30, 9:22 am)
[PATCH 6/6] dccp: Feature activation handlers, Gerrit Renker, (Sun Nov 30, 9:22 am)
[PATCH 2/5] dccp: API to query the current TX/RX CCID, Gerrit Renker, (Sat Nov 22, 6:30 am)
[PATCH 4/5] dccp: Support for Mandatory options, Gerrit Renker, (Sat Nov 22, 6:30 am)
Re: [PATCH 4/5] dccp: Support for Mandatory options, David Miller, (Sun Nov 23, 8:09 pm)
[PATCH 1/5] dccp: Mechanism to resolve CCID dependencies, Gerrit Renker, (Sat Nov 15, 8:11 am)
[PATCH 2/5] dccp: Deprecate old setsockopt framework, Gerrit Renker, (Sat Nov 15, 8:11 am)
Re: [PATCH 2/5] dccp: Deprecate old setsockopt framework, Gerrit Renker, (Mon Nov 17, 11:31 am)
[PATCH 4/5] dccp: Deprecate Ack Ratio sysctl, Gerrit Renker, (Sat Nov 15, 8:11 am)
Re: [PATCH 4/5] dccp: Deprecate Ack Ratio sysctl, David Miller, (Mon Nov 17, 2:56 am)
[PATCH 5/5] dccp: Tidy up setsockopt calls, Gerrit Renker, (Sat Nov 15, 8:11 am)
Re: [PATCH 5/5] dccp: Tidy up setsockopt calls, David Miller, (Mon Nov 17, 2:57 am)
[PATCH 3/4] dccp: Query supported CCIDs, Gerrit Renker, (Thu Nov 6, 1:40 am)
v2 [PATCH 3/4] dccp: Query supported CCIDs, Gerrit Renker, (Wed Nov 12, 2:37 am)
Re: v2 [PATCH 3/4] dccp: Query supported CCIDs, David Miller, (Wed Nov 12, 4:49 am)
Re: [PATCH 3/4] dccp: Query supported CCIDs, David Miller, (Mon Nov 10, 5:16 pm)
Re: [PATCH 2/5] dccp: Implement lookup table for feature-neg..., Arnaldo Carvalho de Melo, (Mon Sep 22, 1:00 pm)
Re: [PATCH 2/5] dccp: Implement lookup table for feature-neg..., Arnaldo Carvalho de Melo, (Wed Sep 24, 9:58 am)
Re: [PATCH 2/5] dccp: Implement lookup table for feature-neg..., Arnaldo Carvalho de Melo, (Mon Sep 22, 12:49 pm)
Re: What to do with DCCP, David Miller, (Thu Sep 11, 1:53 am)
Re: What to do with DCCP, Gerrit Renker, (Fri Sep 12, 1:16 am)
Re: net-next-2.6 [pull-request] [PATCH 0/37] dccp: Revised s..., Arnaldo Carvalho de Melo, (Thu Sep 11, 10:02 am)
Re: [PATCH 04/37] dccp: Per-socket initialisation of feature..., Arnaldo Carvalho de Melo, (Thu Aug 28, 3:53 pm)
Re: [PATCH 06/37] dccp: Limit feature negotiation to connect..., Arnaldo Carvalho de Melo, (Thu Aug 28, 4:50 pm)
Re: [PATCH 07/37] dccp: Registration routines for changing f..., Arnaldo Carvalho de Melo, (Thu Aug 28, 4:54 pm)
[PATCH 08/37] dccp: Query supported CCIDs, Gerrit Renker, (Thu Aug 28, 1:44 pm)
Re: [PATCH 08/37] dccp: Query supported CCIDs, Arnaldo Carvalho de Melo, (Thu Aug 28, 5:00 pm)
Re: [PATCH 08/37] dccp: Query supported CCIDs, Gerrit Renker, (Sat Aug 30, 9:52 am)
Re: [PATCH 08/37] dccp: Query supported CCIDs, Gerrit Renker, (Fri Aug 29, 2:17 am)
Re: [PATCH 09/37] dccp: Resolve dependencies of features on ..., Arnaldo Carvalho de Melo, (Thu Aug 28, 5:07 pm)
Re: [PATCH 09/37] dccp: Resolve dependencies of features on ..., Arnaldo Carvalho de Melo, (Wed Sep 3, 8:59 pm)
[PATCH 11/37] dccp: Deprecate old setsockopt framework, Gerrit Renker, (Thu Aug 28, 1:44 pm)
Re: [PATCH 12/37] dccp: Feature negotiation for minimum-chec..., Arnaldo Carvalho de Melo, (Thu Aug 28, 5:25 pm)
[PATCH 13/37] dccp: Deprecate Ack Ratio sysctl, Gerrit Renker, (Thu Aug 28, 1:44 pm)
Re: [PATCH 13/37] dccp: Deprecate Ack Ratio sysctl, Arnaldo Carvalho de Melo, (Thu Aug 28, 5:26 pm)
[PATCH 14/37] dccp: Tidy up setsockopt calls, Gerrit Renker, (Thu Aug 28, 1:44 pm)
Re: [PATCH 14/37] dccp: Tidy up setsockopt calls, Eugene Teo, (Fri Aug 29, 5:25 am)
Re: [PATCH 14/37] dccp: Tidy up setsockopt calls, Gerrit Renker, (Sat Aug 30, 9:52 am)
Re: [PATCH 14/37] dccp: Tidy up setsockopt calls, Arnaldo Carvalho de Melo, (Thu Aug 28, 5:35 pm)
Re: [PATCH 14/37] dccp: Tidy up setsockopt calls, Gerrit Renker, (Fri Aug 29, 2:57 am)
Re: [PATCH 15/37] dccp: Set per-connection CCIDs via socket ..., Arnaldo Carvalho de Melo, (Thu Aug 28, 5:45 pm)
[PATCH 16/37] dccp: API to query the current TX/RX CCID, Gerrit Renker, (Thu Aug 28, 1:44 pm)
Re: [PATCH 16/37] dccp: API to query the current TX/RX CCID, Arnaldo Carvalho de Melo, (Thu Aug 28, 5:47 pm)
Re: [PATCH 17/37] dccp: Increase the scope of variable-lengt..., Arnaldo Carvalho de Melo, (Thu Aug 28, 5:48 pm)
[PATCH 18/37] dccp: Support for Mandatory options, Gerrit Renker, (Thu Aug 28, 1:44 pm)
Re: [PATCH 18/37] dccp: Support for Mandatory options, Arnaldo Carvalho de Melo, (Thu Aug 28, 5:50 pm)
[PATCH 22/37] dccp: Preference list reconciliation, Gerrit Renker, (Thu Aug 28, 1:44 pm)
[PATCH 24/37] dccp: Processing Confirm options, Gerrit Renker, (Thu Aug 28, 1:44 pm)
[PATCH 25/37] dccp: Feature activation handlers, Gerrit Renker, (Thu Aug 28, 1:45 pm)
Re: [PATCH 25/37] dccp: Feature activation handlers, Wei Yongjun, (Tue Sep 2, 2:34 am)
Re: [PATCH 25/37] dccp: Feature activation handlers, Gerrit Renker, (Wed Sep 3, 12:38 am)
Re: [PATCH 25/37] dccp: Feature activation handlers, Wei Yongjun, (Wed Sep 3, 1:42 am)
Re: [PATCH 25/37] dccp: Feature activation handlers, Gerrit Renker, (Thu Sep 4, 1:12 am)