Add liveness checks to user-level RCU model.
Quoted 7 lines · * Paul E. McKenney ([email protected]) wrote:
Break all potentially infinite loops in both
urcu_reader()andurcu_updater(), ensure thaturcu_reader()will process any memory barriers thaturcu_updater()might issue, and formulate a "never" claim that checks to make sure that if eitherurcu_reader()orurcu_updater()completes, then the other will eventually also complete. Sinceurcu_reader()now has a finite number of steps, it must eventually complete.
Quoted 5 lines
Also replace the code at the end of
urcu_reader()that previously absorbed late memory-barrier requests fromurcu_updaterwith code inurcu_writer()that checks to see ifurcu_reader()has completed.Signed-off-by Paul E. McKenney <[email protected]>
Thanks Paul, I'll merge it. However, I am currently reworking our spin tree so we can execute the tests in batch (rather that all at once, which consumes more memory than necessary) and also I am doing a nice build script which lets us create our own LTL formulaes for verification. The never claims will be automatically generated and verified. I'll keep you posted.
Mathieu
Quoted 249 lines
--- formal-model/urcu.sh | 26 ++++++++++- formal-model/urcu.spin | 113 ++++++++++++++++++++++------------------------- 2 files changed, 77 insertions(+), 62 deletions(-)formal-model/urcu.sh +24
-2@@ -1,3 +1,25 @@ +#!/bin/sh +# +# Compiles and runs the urcu.spin Promela model. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# Copyright (C) IBM Corporation, 2009 +# +# Authors: Paul E. McKenney <[email protected]> + spin -a urcu.spin -cc -DSAFETY -o pan pan.c -./pan +cc -o pan pan.c +./pan -aformal-model/urcu.spin +53
-60@@ -40,21 +40,28 @@ bit updater_done = 0; byte urcu_gp_ctr = 1; byte urcu_active_readers = 0; +/* must be at least the number of smp_mb() statements in urcu_updater(). */ +#define N_SMP_MB 9 + /* Model the RCU read-side critical section. */ proctype urcu_reader() { bit done = 0; + byte i; bit mbok; byte tmp; byte tmp_removed; byte tmp_free; /* Absorb any early requests for memory barriers. */ + i = 0; do - :: need_mb == 1 -> + :: i < N_SMP_MB && need_mb == 1 -> need_mb = 0; - :: !updater_done -> skip; + i++; + :: i < N_SMP_MB -> + i++; :: 1 -> break; od;@@ -91,12 +98,17 @@ proctype urcu_reader() if :: (tmp & RCU_GP_CTR_NEST_MASK) == 0 -> tmp = urcu_gp_ctr; + i = 0; do - :: (reader_progress[1] + + :: i < N_SMP_MB && + (reader_progress[1] + reader_progress[2] + - reader_progress[3] == 0) && need_mb == 1 -> + reader_progress[3] == 0) && + need_mb == 1 -> need_mb = 0; - :: !updater_done -> skip; + i++; + :: i < N_SMP_MB -> + i++; :: 1 -> break; od; urcu_active_readers = tmp;@@ -151,10 +163,13 @@ proctype urcu_reader() if :: mbok == 1 -> /* We get here if mb processing is safe. */ + i = 0; do - :: need_mb == 1 -> + :: i < N_SMP_MB && need_mb == 1 -> need_mb = 0; - :: !updater_done -> skip; + i++; + :: i < N_SMP_MB -> + i++; :: 1 -> break; od; :: else -> skip;@@ -169,36 +184,30 @@ proctype urcu_reader() :: else -> skip; fi od; + + /* Make sure any concurrent grace period was sufficiently long. */ assert((tmp_free == 0) || (tmp_removed == 1)); /* Reader has completed. */ reader_done = 1; - - /* Process any late-arriving memory-barrier requests. */ - do - :: need_mb == 1 -> - need_mb = 0; - :: !updater_done -> skip; - :: 1 -> break; - od; } +#define smp_mb() \ + need_mb = 1; \ + do \ + :: !reader_done && need_mb == 1 -> skip; \ + :: reader_done -> break; \ + :: need_mb == 0 -> break; \ + od + /* Model the RCU update process. */ proctype urcu_updater() { /* prior synchronize_rcu(), second counter flip. */ - need_mb = 1; - do - :: need_mb == 1 -> skip; - :: need_mb == 0 -> break; - od; + smp_mb(); urcu_gp_ctr = urcu_gp_ctr + RCU_GP_CTR_BIT; - need_mb = 1; - do - :: need_mb == 1 -> skip; - :: need_mb == 0 -> break; - od; + smp_mb(); do :: 1 -> if@@ -209,27 +218,15 @@ proctype urcu_updater() :: else -> break; fi; od; - need_mb = 1; - do - :: need_mb == 1 -> skip; - :: need_mb == 0 -> break; - od; + smp_mb(); /* Removal statement, e.g., list_del_rcu(). */ removed = 1; /* current synchronize_rcu(), first counter flip. */ - need_mb = 1; - do - :: need_mb == 1 -> skip; - :: need_mb == 0 -> break; - od; + smp_mb(); urcu_gp_ctr = urcu_gp_ctr + RCU_GP_CTR_BIT; - need_mb = 1; - do - :: need_mb == 1 -> skip; - :: need_mb == 0 -> break; - od; + smp_mb(); do :: 1 -> if@@ -240,24 +237,12 @@ proctype urcu_updater() :: else -> break; fi; od; - need_mb = 1; - do - :: need_mb == 1 -> skip; - :: need_mb == 0 -> break; - od; + smp_mb(); /* current synchronize_rcu(), second counter flip. */ - need_mb = 1; - do - :: need_mb == 1 -> skip; - :: need_mb == 0 -> break; - od; + smp_mb(); urcu_gp_ctr = urcu_gp_ctr + RCU_GP_CTR_BIT; - need_mb = 1; - do - :: need_mb == 1 -> skip; - :: need_mb == 0 -> break; - od; + smp_mb(); do :: 1 -> if@@ -268,11 +253,7 @@ proctype urcu_updater() :: else -> break; fi; od; - need_mb = 1; - do - :: need_mb == 1 -> skip; - :: need_mb == 0 -> break; - od; + smp_mb(); /* free-up step, e.g., kfree(). */ free = 1;@@ -299,3 +280,15 @@ init { run urcu_updater(); } } + +/* Require that both reader and updater eventually get done. */ + +never { + do + :: skip; + :: reader_done != 0 || updater_done != 0 -> break; + od; +accept: do + :: reader_done == 0 || updater_done == 0; + od; +}Signature · 1 line
1.5.2.5
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Quoted 12 lines · Mathieu Desnoyers
Quoted 11 lines · * Paul E. McKenney ([email protected]) wrote:
Break all potentially infinite loops in both
urcu_reader()andurcu_updater(), ensure thaturcu_reader()will process any memory barriers thaturcu_updater()might issue, and formulate a "never" claim that checks to make sure that if eitherurcu_reader()orurcu_updater()completes, then the other will eventually also complete. Sinceurcu_reader()now has a finite number of steps, it must eventually complete.Also replace the code at the end of
urcu_reader()that previously absorbed late memory-barrier requests fromurcu_updaterwith code inurcu_writer()that checks to see ifurcu_reader()has completed.
Quoted 8 lines
Quoted 1 line
Signed-off-by Paul E. McKenney <[email protected]>Thanks Paul, I'll merge it. However, I am currently reworking our spin tree so we can execute the tests in batch (rather that all at once, which consumes more memory than necessary) and also I am doing a nice build script which lets us create our own LTL formulaes for verification. The never claims will be automatically generated and verified. I'll keep you posted.
Sounds interesting! Not sure what you mean by "execute the tests in batch", but look forward to seeing it.
On the LTL, the formula "<>[] (reader_done != 0 && updater_done != 0)" didn't do what I want. The model would kick out an error with the reader sitting just before the "reader_done = 1" and the updater spinning waiting for the reader to respond to its memory-barrier request.
So I fell back to the hand-coded formula in the never clause, which translates to English as "if either the reader or the updater complete, then both the reader and the updater eventually complete". There might be a way to tranlate that into LTL, but I didn't immediately see one.
This morning I tried the weak fairness constraints (the "-f" argument to ./pan) and that did allow LTL to do what I want, as shown in the following patch (applied on top of my earlier patch).
I must confess that LTL is at best an acquired taste for me. "Let's see... '<>[](!reader_done || !updater_done)'... That means eventually we always must have neither the reader or the updater being done. Huh??? Oh, yeah, this is supposed to say what -cannot- happen..." At this point, I have an easier time with the hand-coded "never" claims. ;-)
But I am quite happy to leave further hacking on this model in your capable hands. The other item on my todo list was making the urcu_mbmin.spin model accurately handle omission of additional memory barriers. Are you willing to take that on as well?
Thanx, Paul
---
urcu.sh | 4 ++-- urcu.spin | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-)
formal-model/urcu.sh +2 -2
@@ -20,6 +20,6 @@ # # Authors: Paul E. McKenney <[email protected]> -spin -a urcu.spin +spin -a -f '<>[](!reader_done || !updater_done)' urcu.spin cc -o pan pan.c -./pan -a +./pan -a -f
formal-model/urcu.spin +0 -12
@@ -280,15 +280,3 @@ init { run urcu_updater(); } } - -/* Require that both reader and updater eventually get done. */ - -never { - do - :: skip; - :: reader_done != 0 || updater_done != 0 -> break; - od; -accept: do - :: reader_done == 0 || updater_done == 0; - od; -}
Quoted 46 lines · * Paul E. McKenney ([email protected]) wrote:
Quoted 12 lines · Mathieu Desnoyers
Quoted 11 lines · * Paul E. McKenney ([email protected]) wrote:
Break all potentially infinite loops in both
urcu_reader()andurcu_updater(), ensure thaturcu_reader()will process any memory barriers thaturcu_updater()might issue, and formulate a "never" claim that checks to make sure that if eitherurcu_reader()orurcu_updater()completes, then the other will eventually also complete. Sinceurcu_reader()now has a finite number of steps, it must eventually complete.Also replace the code at the end of
urcu_reader()that previously absorbed late memory-barrier requests fromurcu_updaterwith code inurcu_writer()that checks to see ifurcu_reader()has completed.Quoted 8 lines
Quoted 1 line
Signed-off-by Paul E. McKenney <[email protected]>Thanks Paul, I'll merge it. However, I am currently reworking our spin tree so we can execute the tests in batch (rather that all at once, which consumes more memory than necessary) and also I am doing a nice build script which lets us create our own LTL formulaes for verification. The never claims will be automatically generated and verified. I'll keep you posted.
Sounds interesting! Not sure what you mean by "execute the tests in batch", but look forward to seeing it.
On the LTL, the formula "<>[] (
reader_done!= 0 &&updater_done!= 0)" didn't do what I want. The model would kick out an error with the reader sitting just before the "reader_done= 1" and the updater spinning waiting for the reader to respond to its memory-barrier request.So I fell back to the hand-coded formula in the never clause, which translates to English as "if either the reader or the updater complete, then both the reader and the updater eventually complete". There might be a way to tranlate that into LTL, but I didn't immediately see one.
This morning I tried the weak fairness constraints (the "-f" argument to ./pan) and that did allow LTL to do what I want, as shown in the following patch (applied on top of my earlier patch).
I must confess that LTL is at best an acquired taste for me. "Let's see... '<>[](!reader_done || !updater_done)'... That means eventually we always must have neither the reader or the updater being done. Huh??? Oh, yeah, this is supposed to say what -cannot- happen..." At this point, I have an easier time with the hand-coded "never" claims. ;-)
Quoted 5 lines
But I am quite happy to leave further hacking on this model in your capable hands. The other item on my todo list was making the urcu_mbmin.spin model accurately handle omission of additional memory barriers. Are you willing to take that on as well?
I'll first get the translation of asserts into LTL formulaes, and try to see what should be fixed in the model. I have noticed that we would need to do this :
urcu_gp_ctr = (urcu_gp_ctr + RCU_GP_CTR_BIT) % (RCU_GP_CTR_BIT + 1);
Otherwise the overflow does not do what we expect (spin -f on the trail told me that it was overflowing to 1, which is not exactly what we want I guess). More to come on that side. When this will be settled, I'll dig further.
Mathieu
Quoted 43 lines
Thanx, Paul
Signed-off-by Paul E. McKenney <[email protected]>---
urcu.sh | 4 ++-- urcu.spin | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-)formal-model/urcu.sh +2
-2@@ -20,6 +20,6 @@ # # Authors: Paul E. McKenney <[email protected]> -spin -a urcu.spin +spin -a -f '<>[](!reader_done || !updater_done)' urcu.spin cc -o pan pan.c -./pan -a +./pan -a -fformal-model/urcu.spin +0
-12@@ -280,15 +280,3 @@ init { run urcu_updater(); } } - -/* Require that both reader and updater eventually get done. */ - -never { - do - :: skip; - :: reader_done != 0 || updater_done != 0 -> break; - od; -accept: do - :: reader_done == 0 || updater_done == 0; - od; -}
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Quoted 53 lines · * Mathieu Desnoyers ([email protected]) wrote:
Quoted 46 lines · * Paul E. McKenney ([email protected]) wrote:
Quoted 12 lines · Mathieu Desnoyers
Quoted 11 lines · * Paul E. McKenney ([email protected]) wrote:
Break all potentially infinite loops in both
urcu_reader()andurcu_updater(), ensure thaturcu_reader()will process any memory barriers thaturcu_updater()might issue, and formulate a "never" claim that checks to make sure that if eitherurcu_reader()orurcu_updater()completes, then the other will eventually also complete. Sinceurcu_reader()now has a finite number of steps, it must eventually complete.Also replace the code at the end of
urcu_reader()that previously absorbed late memory-barrier requests fromurcu_updaterwith code inurcu_writer()that checks to see ifurcu_reader()has completed.Quoted 8 lines
Quoted 1 line
Signed-off-by Paul E. McKenney <[email protected]>Thanks Paul, I'll merge it. However, I am currently reworking our spin tree so we can execute the tests in batch (rather that all at once, which consumes more memory than necessary) and also I am doing a nice build script which lets us create our own LTL formulaes for verification. The never claims will be automatically generated and verified. I'll keep you posted.
Sounds interesting! Not sure what you mean by "execute the tests in batch", but look forward to seeing it.
On the LTL, the formula "<>[] (
reader_done!= 0 &&updater_done!= 0)" didn't do what I want. The model would kick out an error with the reader sitting just before the "reader_done= 1" and the updater spinning waiting for the reader to respond to its memory-barrier request.So I fell back to the hand-coded formula in the never clause, which translates to English as "if either the reader or the updater complete, then both the reader and the updater eventually complete". There might be a way to tranlate that into LTL, but I didn't immediately see one.
This morning I tried the weak fairness constraints (the "-f" argument to ./pan) and that did allow LTL to do what I want, as shown in the following patch (applied on top of my earlier patch).
I must confess that LTL is at best an acquired taste for me. "Let's see... '<>[](!reader_done || !updater_done)'... That means eventually we always must have neither the reader or the updater being done. Huh??? Oh, yeah, this is supposed to say what -cannot- happen..." At this point, I have an easier time with the hand-coded "never" claims. ;-)
Quoted 5 lines
But I am quite happy to leave further hacking on this model in your capable hands. The other item on my todo list was making the urcu_mbmin.spin model accurately handle omission of additional memory barriers. Are you willing to take that on as well?
Quoted 5 lines
I'll first get the translation of asserts into LTL formulaes, and try to see what should be fixed in the model. I have noticed that we would need to do this :
urcu_gp_ctr= (urcu_gp_ctr+RCU_GP_CTR_BIT) % (RCU_GP_CTR_BIT+ 1);
urcu_gp_ctr = urcu_gp_ctr ^ RCU_GP_CTR_BIT;
is actually much nicer..
MAthieu
Quoted 62 lines
Otherwise the overflow does not do what we expect (spin -f on the trail told me that it was overflowing to 1, which is not exactly what we want I guess). More to come on that side. When this will be settled, I'll dig further.
Mathieu
Quoted 43 lines
Thanx, Paul
Signed-off-by Paul E. McKenney <[email protected]>---
urcu.sh | 4 ++-- urcu.spin | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-)formal-model/urcu.sh +2
-2@@ -20,6 +20,6 @@ # # Authors: Paul E. McKenney <[email protected]> -spin -a urcu.spin +spin -a -f '<>[](!reader_done || !updater_done)' urcu.spin cc -o pan pan.c -./pan -a +./pan -a -fformal-model/urcu.spin +0
-12@@ -280,15 +280,3 @@ init { run urcu_updater(); } } - -/* Require that both reader and updater eventually get done. */ - -never { - do - :: skip; - :: reader_done != 0 || updater_done != 0 -> break; - od; -accept: do - :: reader_done == 0 || updater_done == 0; - od; -}Signature · 7 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 _______________________________________________ ltt-dev mailing list [email protected] http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Quoted 54 lines · Mathieu Desnoyers
Quoted 53 lines · * Mathieu Desnoyers ([email protected]) wrote:
Quoted 51 lines · * Paul E. McKenney ([email protected]) wrote:
Quoted 12 lines · Mathieu Desnoyers
Quoted 11 lines · * Paul E. McKenney ([email protected]) wrote:
Break all potentially infinite loops in both
urcu_reader()andurcu_updater(), ensure thaturcu_reader()will process any memory barriers thaturcu_updater()might issue, and formulate a "never" claim that checks to make sure that if eitherurcu_reader()orurcu_updater()completes, then the other will eventually also complete. Sinceurcu_reader()now has a finite number of steps, it must eventually complete.Also replace the code at the end of
urcu_reader()that previously absorbed late memory-barrier requests fromurcu_updaterwith code inurcu_writer()that checks to see ifurcu_reader()has completed.Quoted 8 lines
Quoted 1 line
Signed-off-by Paul E. McKenney <[email protected]>Thanks Paul, I'll merge it. However, I am currently reworking our spin tree so we can execute the tests in batch (rather that all at once, which consumes more memory than necessary) and also I am doing a nice build script which lets us create our own LTL formulaes for verification. The never claims will be automatically generated and verified. I'll keep you posted.
Sounds interesting! Not sure what you mean by "execute the tests in batch", but look forward to seeing it.
On the LTL, the formula "<>[] (
reader_done!= 0 &&updater_done!= 0)" didn't do what I want. The model would kick out an error with the reader sitting just before the "reader_done= 1" and the updater spinning waiting for the reader to respond to its memory-barrier request.So I fell back to the hand-coded formula in the never clause, which translates to English as "if either the reader or the updater complete, then both the reader and the updater eventually complete". There might be a way to tranlate that into LTL, but I didn't immediately see one.
This morning I tried the weak fairness constraints (the "-f" argument to ./pan) and that did allow LTL to do what I want, as shown in the following patch (applied on top of my earlier patch).
I must confess that LTL is at best an acquired taste for me. "Let's see... '<>[](!reader_done || !updater_done)'... That means eventually we always must have neither the reader or the updater being done. Huh??? Oh, yeah, this is supposed to say what -cannot- happen..." At this point, I have an easier time with the hand-coded "never" claims. ;-)
But I am quite happy to leave further hacking on this model in your capable hands. The other item on my todo list was making the urcu_mbmin.spin model accurately handle omission of additional memory barriers. Are you willing to take that on as well?
Quoted 8 lines
Quoted 5 lines
I'll first get the translation of asserts into LTL formulaes, and try to see what should be fixed in the model. I have noticed that we would need to do this :
urcu_gp_ctr= (urcu_gp_ctr+RCU_GP_CTR_BIT) % (RCU_GP_CTR_BIT+ 1);
urcu_gp_ctr=urcu_gp_ctr^RCU_GP_CTR_BIT;is actually much nicer..
Good point -- I was forgetting that Promela supports "^".
Thanx, Paul
Quoted 72 lines
MAthieu
Quoted 62 lines
Otherwise the overflow does not do what we expect (spin -f on the trail told me that it was overflowing to 1, which is not exactly what we want I guess). More to come on that side. When this will be settled, I'll dig further.
Mathieu
Quoted 43 lines
Thanx, Paul
Signed-off-by Paul E. McKenney <[email protected]>---
urcu.sh | 4 ++-- urcu.spin | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-)formal-model/urcu.sh +2
-2@@ -20,6 +20,6 @@ # # Authors: Paul E. McKenney <[email protected]> -spin -a urcu.spin +spin -a -f '<>[](!reader_done || !updater_done)' urcu.spin cc -o pan pan.c -./pan -a +./pan -a -fformal-model/urcu.spin +0
-12@@ -280,15 +280,3 @@ init { run urcu_updater(); } } - -/* Require that both reader and updater eventually get done. */ - -never { - do - :: skip; - :: reader_done != 0 || updater_done != 0 -> break; - od; -accept: do - :: reader_done == 0 || updater_done == 0; - od; -}Signature · 7 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 _______________________________________________ ltt-dev mailing list [email protected] http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-devSignature · 7 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Quoted 56 lines · Mathieu Desnoyers
Quoted 46 lines · * Paul E. McKenney ([email protected]) wrote:
Quoted 12 lines · Mathieu Desnoyers
Quoted 11 lines · * Paul E. McKenney ([email protected]) wrote:
Break all potentially infinite loops in both
urcu_reader()andurcu_updater(), ensure thaturcu_reader()will process any memory barriers thaturcu_updater()might issue, and formulate a "never" claim that checks to make sure that if eitherurcu_reader()orurcu_updater()completes, then the other will eventually also complete. Sinceurcu_reader()now has a finite number of steps, it must eventually complete.Also replace the code at the end of
urcu_reader()that previously absorbed late memory-barrier requests fromurcu_updaterwith code inurcu_writer()that checks to see ifurcu_reader()has completed.Quoted 8 lines
Quoted 1 line
Signed-off-by Paul E. McKenney <[email protected]>Thanks Paul, I'll merge it. However, I am currently reworking our spin tree so we can execute the tests in batch (rather that all at once, which consumes more memory than necessary) and also I am doing a nice build script which lets us create our own LTL formulaes for verification. The never claims will be automatically generated and verified. I'll keep you posted.
Sounds interesting! Not sure what you mean by "execute the tests in batch", but look forward to seeing it.
On the LTL, the formula "<>[] (
reader_done!= 0 &&updater_done!= 0)" didn't do what I want. The model would kick out an error with the reader sitting just before the "reader_done= 1" and the updater spinning waiting for the reader to respond to its memory-barrier request.So I fell back to the hand-coded formula in the never clause, which translates to English as "if either the reader or the updater complete, then both the reader and the updater eventually complete". There might be a way to tranlate that into LTL, but I didn't immediately see one.
This morning I tried the weak fairness constraints (the "-f" argument to ./pan) and that did allow LTL to do what I want, as shown in the following patch (applied on top of my earlier patch).
I must confess that LTL is at best an acquired taste for me. "Let's see... '<>[](!reader_done || !updater_done)'... That means eventually we always must have neither the reader or the updater being done. Huh??? Oh, yeah, this is supposed to say what -cannot- happen..." At this point, I have an easier time with the hand-coded "never" claims. ;-)
Quoted 4 lines
But I am quite happy to leave further hacking on this model in your capable hands. The other item on my todo list was making the urcu_mbmin.spin model accurately handle omission of additional memory barriers. Are you willing to take that on as well?
I'll first get the translation of asserts into LTL formulaes, and try to see what should be fixed in the model. I have noticed that we would need to do this :
Quoted 6 lines
urcu_gp_ctr= (urcu_gp_ctr+RCU_GP_CTR_BIT) % (RCU_GP_CTR_BIT+ 1);Otherwise the overflow does not do what we expect (spin -f on the trail told me that it was overflowing to 1, which is not exactly what we want I guess). More to come on that side. When this will be settled, I'll dig further.
Hmmm... The two legal values for urcu_gp_ctr are 1 and 129, so isn't this in fact the desired behavior? This is with your optimization that cuts a half-cycle from rcu_read_lock() by making the initial value of urcu_gp_ctr be 1 rather than 0.
One way of getting rid of the warning would be something like the following:
atomic {
if
:: urcu_gp_ctr == 1 -> urcu_gp_ctr = 129;
:: urcu_gp_ctr == 129 -> urcu_gp_ctr = 1;
fi;
}On converting the assert() to LTL, better you than me! :-)
Thanx, Paul
Quoted 55 lines
Mathieu
Quoted 43 lines
Thanx, Paul
Signed-off-by Paul E. McKenney <[email protected]>---
urcu.sh | 4 ++-- urcu.spin | 12 ------------ 2 files changed, 2 insertions(+), 14 deletions(-)formal-model/urcu.sh +2
-2@@ -20,6 +20,6 @@ # # Authors: Paul E. McKenney <[email protected]> -spin -a urcu.spin +spin -a -f '<>[](!reader_done || !updater_done)' urcu.spin cc -o pan pan.c -./pan -a +./pan -a -fformal-model/urcu.spin +0
-12@@ -280,15 +280,3 @@ init { run urcu_updater(); } } - -/* Require that both reader and updater eventually get done. */ - -never { - do - :: skip; - :: reader_done != 0 || updater_done != 0 -> break; - od; -accept: do - :: reader_done == 0 || updater_done == 0; - od; -}Signature · 7 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Quoted 1 line · Paul E. McKenney
On Fri, Feb 20, 2009 at 02:46:21PM -0500, Mathieu Desnoyers wrote:
[ . . . ]
Quoted 19 lines
Quoted 10 lines
I'll first get the translation of asserts into LTL formulaes, and try to see what should be fixed in the model. I have noticed that we would need to do this :
urcu_gp_ctr= (urcu_gp_ctr+RCU_GP_CTR_BIT) % (RCU_GP_CTR_BIT+ 1);Otherwise the overflow does not do what we expect (spin -f on the trail told me that it was overflowing to 1, which is not exactly what we want I guess). More to come on that side. When this will be settled, I'll dig further.
Hmmm... The two legal values for
urcu_gp_ctrare 1 and 129, so isn't this in fact the desired behavior? This is with your optimization that cuts a half-cycle fromrcu_read_lock()by making the initial value ofurcu_gp_ctrbe 1 rather than 0.One way of getting rid of the warning would be something like the following:
Quoted 8 lines
atomic { if :: urcu_gp_ctr == 1 -> urcu_gp_ctr = 129; :: urcu_gp_ctr == 129 -> urcu_gp_ctr = 1; fi; }On converting the
assert()to LTL, better you than me! :-)
Perhaps I should explain myself here...
Promela usually handles asserts() much more efficiently than it does LTL or hand-code "never" clauses. One reason is that "never" clauses act as a separate Promela process that runs one step interleaved between every step from any other process. This obviously increases the run time, but more importantly blows up the state space.
In addition, adding additional assert()s to a Promela program is easy to do and has predictable consequences. Combining a pair of LTL statements is another thing altogether.
Of course, it is entirely possible that I would appreciate LTL more if I were to use it more heavily. ;-)
Thanx, Paul