Re: notifier_chain_register semantics query!!!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




 All,

Following definition of notifier_chain_register is from kernel/sys.c
and for kernel 2.6.20.1 .

static int notifier_chain_register(struct notifier_block **nl,
                struct notifier_block *n)
{
        while ((*nl) != NULL) {
                if (n->priority > (*nl)->priority)
                        break;
                nl = &((*nl)->next);
        }
        n->next = *nl;
        rcu_assign_pointer(*nl, n);
        return 0;
}

Since the first parameter is passed as a double ptr, the pointer
itself is changed by the traversal and by rcu_assign_pointer(*nl, n) ,
right? And the new value will be address of notifier_block n. This
means the new head of the notifier list is n with the highest
priority( in terms of magnitude atleast ).

Nopes. If you observe closely, *nl (head) is never touched. It is the nl that is changed.

Say,
head = 1000
nl = 5000 (&head)

So, first nl = 5000. Then nl = &(head->next) that will be 1004 (address of 'next' element of the structure)
and so on.
So, 'head' is never touched.

Regards,
- Ratnadeep

My query is ,why are we loosing the notifiers  during traversal in the
first while loop, which have a priority > n->priority ?

I am terribly confused here.
Can somebody help me out here?

Thank you
~psr

--
play the game

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux