kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* smp_processor_id used in preemptable context ?
@ 2022-04-28  9:15 Vincent Ray
  2022-04-29 23:59 ` Valdis Klētnieks
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Ray @ 2022-04-28  9:15 UTC (permalink / raw)
  To: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 925 bytes --]

Hi Linux hackers ! 

I'm reading some code in net/core/dev.c and something puzzles me : somewhere in __dev_queue_xmit, we have : 
int cpu = smp_processor_id(); /* ok because BHs are off */ 

and, indeed, a few lines up there is : 
/* Disable soft irqs for various locks below. Also 
* stops preemption for RCU. 
*/ 
rcu_read_lock_bh(); 

Now I'm wondering : is this really ok ? 
From what I understand, this code can very well run in user context, with hard IRQs ON, and in fact it should, according to the following comment : 

* When calling this method, interrupts MUST be enabled. This is because 
* the BH enable code must have IRQs enabled so that it will not deadlock. 
* --BLG 

Then I guess it could be preempted at any time, especially with aggressive versions of preemptions ? 
And if so, are we not at risk that our thread is migrated to an other CPU just after smp_processor_id returned ? 

Cheers, 

V Ray 





[-- Attachment #1.2: Type: text/html, Size: 1573 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-30  2:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28  9:15 smp_processor_id used in preemptable context ? Vincent Ray
2022-04-29 23:59 ` Valdis Klētnieks
2022-04-30  2:27   ` Vincent Ray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).