libfc mutex under RCU read section error since "libfc: Fixup disc_mutex handling"
The libfc and libfcoe modules look to have issues with mutexs being used under rcu_read_lock, which triggers "Illegal context switch in RCU read side critical section" warnings under debug kernels.
I started looking at fc_disc.c where rport discovery code appears to take a mutex for each rport in fc_rport_login/fc_rport_logoff while being called under rcu_read_lock from fc_disc_done.
With the rdata->kref held, I know rcu_read_unlock can be safely called before login fc_rport_login/logoff. But I don't know if it's safe to then recall rcu_read_lock and simply continue on with the list_for_each_entry_rcu or not.
And as I start looking into this one case, I also get the same class of problem popping up in at least libfcoe:fcoe_ctrl.c from fcoe_ctrl_timer_work as well :(
- Chris Leech
Quoted 8 lines · Chris Leech
The libfc and libfcoe modules look to have issues with mutexs being used under
rcu_read_lock, which triggers "Illegal context switch in RCU read side critical section" warnings under debug kernels.I started looking at
fc_disc.cwhere rport discovery code appears to take a mutex for each rport in fc_rport_login/fc_rport_logoff while being called underrcu_read_lockfromfc_disc_done.
Quoted 9 lines
With the
rdata->krefheld, I knowrcu_read_unlockcan be safely called before login fc_rport_login/logoff. But I don't know if it's safe to then recallrcu_read_lockand simply continue on with thelist_for_each_entry_rcuor not.And as I start looking into this one case, I also get the same class of problem popping up in at least libfcoe:fcoe_ctrl.c from
fcoe_ctrl_timer_workas well :(
This should've been fixed by my patch series "libfc/fcoe: disc_mutex fixes".
Can you check if this series is applied in your tree?
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) _______________________________________________ fcoe-devel mailing list [email protected] http://lists.open-fcoe.org/mailman/listinfo/fcoe-devel
Quoted 14 lines · Hannes Reinecke
Quoted 13 lines · Chris Leech
The libfc and libfcoe modules look to have issues with mutexs being used under
rcu_read_lock, which triggers "Illegal context switch in RCU read side critical section" warnings under debug kernels.I started looking at
fc_disc.cwhere rport discovery code appears to take a mutex for each rport in fc_rport_login/fc_rport_logoff while being called underrcu_read_lockfromfc_disc_done.With the
rdata->krefheld, I knowrcu_read_unlockcan be safely called before login fc_rport_login/logoff. But I don't know if it's safe to then recallrcu_read_lockand simply continue on with thelist_for_each_entry_rcuor not.
Quoted 7 lines
Quoted 4 lines
And as I start looking into this one case, I also get the same class of problem popping up in at least libfcoe:fcoe_ctrl.c from
fcoe_ctrl_timer_workas well :(This should've been fixed by my patch series "libfc/fcoe:
disc_mutexfixes".Can you check if this series is applied in your tree?
Thanks, I missed those and they do fix things up!
One question about "Add WARN_ON() when deleting rports"
Quoted 10 lines
--- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c @@ -184,6 +184,7 @@ void fc_rport_destroy(struct kref *kref) struct fc_rport_priv *rdata; rdata = container_of(kref, struct fc_rport_priv, kref); + WARN_ON(!list_empty(&rdata->peers)); kfree_rcu(rdata, rcu); } EXPORT_SYMBOL(fc_rport_destroy);
The list_head isn't reinitialized to make list_empty() return true after list_del_rcu(), as there may still be readers traversing the list.
So doesn't this warning trigger on every deleted rport?
Thanks!
- Chris
Quoted 38 lines · Chris Leech
Quoted 14 lines · Hannes Reinecke
Quoted 13 lines · Chris Leech
The libfc and libfcoe modules look to have issues with mutexs being used under
rcu_read_lock, which triggers "Illegal context switch in RCU read side critical section" warnings under debug kernels.I started looking at
fc_disc.cwhere rport discovery code appears to take a mutex for each rport in fc_rport_login/fc_rport_logoff while being called underrcu_read_lockfromfc_disc_done.With the
rdata->krefheld, I knowrcu_read_unlockcan be safely called before login fc_rport_login/logoff. But I don't know if it's safe to then recallrcu_read_lockand simply continue on with thelist_for_each_entry_rcuor not.Quoted 7 lines
Quoted 4 lines
And as I start looking into this one case, I also get the same class of problem popping up in at least libfcoe:fcoe_ctrl.c from
fcoe_ctrl_timer_workas well :(This should've been fixed by my patch series "libfc/fcoe:
disc_mutexfixes".Can you check if this series is applied in your tree?
Thanks, I missed those and they do fix things up!
One question about "Add
WARN_ON()when deleting rports"Quoted 10 lines
--- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c @@ -184,6 +184,7 @@ void fc_rport_destroy(struct kref *kref) struct fc_rport_priv *rdata; rdata = container_of(kref, struct fc_rport_priv, kref); + WARN_ON(!list_empty(&rdata->peers)); kfree_rcu(rdata, rcu); } EXPORT_SYMBOL(fc_rport_destroy);
Quoted 5 lines
The
list_headisn't reinitialized to makelist_empty()return true afterlist_del_rcu(), as there may still be readers traversing the list.So doesn't this warning trigger on every deleted rport?
Not that I've seen, but I'll check.
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) _______________________________________________ fcoe-devel mailing list [email protected] http://lists.open-fcoe.org/mailman/listinfo/fcoe-devel