notifier_chain_register semantics query!!!
Hi 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 ).
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
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: notifier_chain_register semantics query!!!
------=_Part_45337_25662827.1179416437564
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
> 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
>
------=_Part_45337_25662827.1179416437564
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
<br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> All,<br><br>Following definition of notifier_chain_register is from kernel/sys.c<br>
and for kernel 2.6.20.1 .<br><br>static int notifier_chain_register(struct notifier_block **nl,<br> struct notifier_block *n)<br>{<br> while ((*nl) != NULL) {<br> if (n->priority > (*nl)->priority)
<br> break;<br> nl = &((*nl)->next);<br> }<br> n->next = *nl;<br> rcu_assign_pointer(*nl, n);<br> return 0;<br>}<br><br>Since the first parameter is passed as a double ptr, the pointer
<br>itself is changed by the traversal and by rcu_assign_pointer(*nl, n) ,<br>right? And the new value will be address of notifier_block n. This<br>means the new head of the notifier list is n with the highest<br>priority( in terms of magnitude atleast ).
</blockquote><div><br>Nopes. If you observe closely, *nl (head) is never touched. It is the nl that is changed. <br><br>Say,<br>head = 1000<br>nl = 5000 (&head)<br><br>So, first nl = 5000. Then nl = &(head->next) that will be 1004 (address of 'next' element of the structure)
<br>and so on.<br>So, 'head' is never touched.<br><br>Regards,<br>- Ratnadeep<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
My query is ,why are we loosing the notifiers during traversal in the<br>first while loop, which have a priority > n->priority ?<br><br>I am terribly confused here.<br>Can somebody help me out here?<br><br>Thank you
<br>~psr<br><br>--<br>play the game<br></blockquote></div>
------=_Part_45337_25662827.1179416437564--
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis [at] nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ
Re: notifier_chain_register semantics query!!!
On 5/17/07, Ratnadeep Joshi <ratn.josh [at] gmail.com> wrote:
>
>
> > 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.
Thanks Ratan, missed that easily though :-(
Should have been more careful.
Thank you
~psr
>
> 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
> >
>
--
play the game
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs