LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-18-2018, 03:00 AM   #1
915086731
Member
 
Registered: Apr 2010
Posts: 144
Blog Entries: 6

Rep: Reputation: 2
why does `synchronize_rcu()` not deadlock when beening called inside a read lock block?


synchronize_rcu() is used to waits only for ongoing RCU read-side critical sections to complete. If so, it should been blocked forever when beening called inside a read block. However, the following code works well on my linux kernel, why?

Code:
void port_range_clean( void ) 
{
    struct port_range *p;

redo:
    rcu_read_lock();
    list_for_each_entry_rcu(p, &port_rt->ports, list) {
        list_del_rcu(&p->list);
        synchronize_rcu();
         rcu_read_unlock();           
        kfree(p);
        goto redo;
    }
}

Last edited by 915086731; 08-18-2018 at 08:14 AM.
 
Old 08-18-2018, 04:07 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,879

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
I do not really understand what do you wrote, but you have a lock call outside of the redo loop and an unlock inside the loop.
Also your code is incomplete.
 
Old 08-18-2018, 07:29 AM   #3
915086731
Member
 
Registered: Apr 2010
Posts: 144

Original Poster
Blog Entries: 6

Rep: Reputation: 2
Code:
void list_clean( void ) 
{
    struct port_range *p;
    list_for_each_entry_rcu(p, &port_rt->ports, list) {
        list_del_rcu(&p->list);    
        kfree(p);
        goto redo;
    }
}
The original code is to clean a list, delete from first to the last.

Code:
rcu_read_lock();
synchronize_rcu();  // deadlock?
rcu_read_unlock();
What I really care is why synchronize_rcu() not cause dead lock?
 
  


Reply

Tags
kernel, linux, module



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to find out if a java program called inside a shell script throws an exception author_unknown Linux - General 2 06-11-2012 07:40 AM
[SOLVED] Can't read lock file tmp .x0-lock xinit: stale nfs file handle everal Slackware 2 10-31-2011 07:11 AM
Deadlock due to crash inside critical section Jerry Mcguire Programming 3 05-12-2011 08:16 AM
*ERROR* radeon_cp_init called without lock held introuble *BSD 2 05-22-2006 07:02 AM
Can't read lock file /tmp/.X0-lock squinn Linux - Newbie 3 07-13-2004 03:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration