All of lore.kernel.org
 help / color / mirror / Atom feed
* [Adeos-main] Behaviour of adeos_catch_event when domain unregistered
@ 2004-10-14 13:41 Currie Reid
  2004-10-14 16:30 ` Philippe Gerum
  0 siblings, 1 reply; 5+ messages in thread
From: Currie Reid @ 2004-10-14 13:41 UTC (permalink / raw)
  To: adeos-main

Hello all,

I am just trying to understand the underlying behaviour of adeos, and in
my testing I have come across some behaviour that I want to verify is
correct.  If I set a handler for ADEOS_EXIT_PROCESS without registering a
domain, then the handler is in the root domain and behaves as expected
(thank you printk!).  Next, I do a handler in a registered domain for
ADEOS_EXIT_PROCESS and perform 2 tests - 1 where the handler doesn't
propagate the event to the root domain, and one where it does.  These both
behave as expected - when propagated, I see the handler executing once for
each domain.  But when I unload the module and unregister the domain, the
handler in the root domain no longer executes - I would have thought that
the handler would still be in place.

If I register 2 domains and duplicate the test, when the higher priority
domain is unregistered, the lower priority domain starts handling the
events again, as expected.  I haven't delved into to code to see how easy
this is to change - mostly because I'm not sure that this isn't
uninitended behaviour.

I am currently performing testing on a g4 powermac using
adeos-linuxppc-2.6.8rc1-r6c8.patch.

Currie



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

* Re: [Adeos-main] Behaviour of adeos_catch_event when domain unregistered
  2004-10-14 13:41 [Adeos-main] Behaviour of adeos_catch_event when domain unregistered Currie Reid
@ 2004-10-14 16:30 ` Philippe Gerum
  2004-10-14 18:13   ` Currie Reid
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Gerum @ 2004-10-14 16:30 UTC (permalink / raw)
  To: Currie Reid; +Cc: adeos-main

On Thu, 2004-10-14 at 15:41, Currie Reid wrote:
> Hello all,
> 
> I am just trying to understand the underlying behaviour of adeos, and in
> my testing I have come across some behaviour that I want to verify is
> correct.  If I set a handler for ADEOS_EXIT_PROCESS without registering a
> domain, then the handler is in the root domain and behaves as expected
> (thank you printk!).  Next, I do a handler in a registered domain for
> ADEOS_EXIT_PROCESS and perform 2 tests - 1 where the handler doesn't
> propagate the event to the root domain, and one where it does.  These both
> behave as expected - when propagated, I see the handler executing once for
> each domain.  But when I unload the module and unregister the domain, the
> handler in the root domain no longer executes - I would have thought that
> the handler would still be in place.
> 
> If I register 2 domains and duplicate the test, when the higher priority
> domain is unregistered, the lower priority domain starts handling the
> events again, as expected.  I haven't delved into to code to see how easy
> this is to change - mostly because I'm not sure that this isn't
> uninitended behaviour.
> 

Actually, this is. I mean: a bug. Please try applying the following
patch to adeos/generic.c and let me know of the outcome. This said, keep
in mind that fixing this bug will make your box crash if you intend to
keep a handler attached which ends up disappearing from the address
space after the module is unloaded.
Thanks for the report.

--- generic.c	4 Oct 2004 17:34:19 -0000	1.17
+++ generic.c	14 Oct 2004 16:24:53 -0000
@@ -173,7 +173,7 @@
 
     for (event = 0; event < ADEOS_NR_EVENTS; event++)
 	/* Need this to update the monitor count. */
-	adeos_catch_event(event,NULL);
+	adeos_catch_event_from(adp,event,NULL);
 
 #ifdef CONFIG_SMP
     {
-- 

Philippe.



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

* Re: [Adeos-main] Behaviour of adeos_catch_event when domain unregistered
  2004-10-14 16:30 ` Philippe Gerum
@ 2004-10-14 18:13   ` Currie Reid
  2004-10-14 19:09     ` Philippe Gerum
  0 siblings, 1 reply; 5+ messages in thread
From: Currie Reid @ 2004-10-14 18:13 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: adeos-main

Hello Philippe,

The patch works, but raises one or two questions (sorry!).  First, I
understood what you meant about the disappearing handler crashing the box,
so what I did in the root level domain is on module unloading I reset the
handler to null -

static void __exit my_cleanup( void ){

   adeos_catch_event( ADEOS_EXIT_PROCESS, 0 );
   adeos_unregister_domain( &domain_desc );
}

which works in the root domain.  So I figured that this might be a proper
clean-up procedure in higher priority domains.  So I did the same thing in
the module cleanup routine when registering a domain for the same event.
When this module is unloaded, the handler does not default back to the
root domain handler.  Without the cleanup, it works as I would have
expected, but if I reset the handler in the higher priority domain, it
seems to wipe out the handler further down the pipe.  Again, I don't know
if this is intended behaviour, but I would have thought that setting the
event handler in a higher priority domain to null would have no affect on
lower priority (or root) domains.  These lower priority domains would
retain the handler attributed to them at the time of their entry.

Currie


On Thu, 14 Oct 2004, Philippe Gerum wrote:

> On Thu, 2004-10-14 at 15:41, Currie Reid wrote:
> > Hello all,
> >
> > I am just trying to understand the underlying behaviour of adeos, and in
> > my testing I have come across some behaviour that I want to verify is
> > correct.  If I set a handler for ADEOS_EXIT_PROCESS without registering a
> > domain, then the handler is in the root domain and behaves as expected
> > (thank you printk!).  Next, I do a handler in a registered domain for
> > ADEOS_EXIT_PROCESS and perform 2 tests - 1 where the handler doesn't
> > propagate the event to the root domain, and one where it does.  These both
> > behave as expected - when propagated, I see the handler executing once for
> > each domain.  But when I unload the module and unregister the domain, the
> > handler in the root domain no longer executes - I would have thought that
> > the handler would still be in place.
> >
> > If I register 2 domains and duplicate the test, when the higher priority
> > domain is unregistered, the lower priority domain starts handling the
> > events again, as expected.  I haven't delved into to code to see how easy
> > this is to change - mostly because I'm not sure that this isn't
> > uninitended behaviour.
> >
>
> Actually, this is. I mean: a bug. Please try applying the following
> patch to adeos/generic.c and let me know of the outcome. This said, keep
> in mind that fixing this bug will make your box crash if you intend to
> keep a handler attached which ends up disappearing from the address
> space after the module is unloaded.
> Thanks for the report.
>
> --- generic.c	4 Oct 2004 17:34:19 -0000	1.17
> +++ generic.c	14 Oct 2004 16:24:53 -0000
> @@ -173,7 +173,7 @@
>
>      for (event = 0; event < ADEOS_NR_EVENTS; event++)
>  	/* Need this to update the monitor count. */
> -	adeos_catch_event(event,NULL);
> +	adeos_catch_event_from(adp,event,NULL);
>
>  #ifdef CONFIG_SMP
>      {
> --
>
> Philippe.
>
>



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

* Re: [Adeos-main] Behaviour of adeos_catch_event when domain unregistered
  2004-10-14 18:13   ` Currie Reid
@ 2004-10-14 19:09     ` Philippe Gerum
  2004-10-14 20:32       ` Currie Reid
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Gerum @ 2004-10-14 19:09 UTC (permalink / raw)
  To: Currie Reid; +Cc: adeos-main

On Thu, 2004-10-14 at 20:13, Currie Reid wrote:
> Hello Philippe,
> 
> The patch works, but raises one or two questions (sorry!).  First, I
> understood what you meant about the disappearing handler crashing the box,
> so what I did in the root level domain is on module unloading I reset the
> handler to null -
> 
> static void __exit my_cleanup( void ){
> 
>    adeos_catch_event( ADEOS_EXIT_PROCESS, 0 );
>    adeos_unregister_domain( &domain_desc );
> }
> 
> which works in the root domain.  So I figured that this might be a proper
> clean-up procedure in higher priority domains.  So I did the same thing in
> the module cleanup routine when registering a domain for the same event.
> When this module is unloaded, the handler does not default back to the
> root domain handler.  Without the cleanup, it works as I would have
> expected, but if I reset the handler in the higher priority domain, it
> seems to wipe out the handler further down the pipe.  Again, I don't know
> if this is intended behaviour, but I would have thought that setting the
> event handler in a higher priority domain to null would have no affect on
> lower priority (or root) domains.  These lower priority domains would
> retain the handler attributed to them at the time of their entry.
> 

First guess: maybe because you are using adeos_catch_event() to nullify
it, which implicitely does
adeos_catch_event_from(adp_current,event,NULL) [i.e. it's a shorthand] ,
and on behalf of a module cleanup routine, adp_current == adp_root, i.e.
Linux?

So, if you want to clean it up at the most prioritary level, you have to
write adeos_catch_event_from(&domain_desc,event,NULL), this way, the
current domain (Linux) won't be implicitely used for the operation.

However, unregistering a domain (now) properly releases all events for
it since the stage it occupies disappears, so you don't need to clear
the event handlers manually for this domain.

> Currie
> 
> 
> On Thu, 14 Oct 2004, Philippe Gerum wrote:
> 
> > On Thu, 2004-10-14 at 15:41, Currie Reid wrote:
> > > Hello all,
> > >
> > > I am just trying to understand the underlying behaviour of adeos, and in
> > > my testing I have come across some behaviour that I want to verify is
> > > correct.  If I set a handler for ADEOS_EXIT_PROCESS without registering a
> > > domain, then the handler is in the root domain and behaves as expected
> > > (thank you printk!).  Next, I do a handler in a registered domain for
> > > ADEOS_EXIT_PROCESS and perform 2 tests - 1 where the handler doesn't
> > > propagate the event to the root domain, and one where it does.  These both
> > > behave as expected - when propagated, I see the handler executing once for
> > > each domain.  But when I unload the module and unregister the domain, the
> > > handler in the root domain no longer executes - I would have thought that
> > > the handler would still be in place.
> > >
> > > If I register 2 domains and duplicate the test, when the higher priority
> > > domain is unregistered, the lower priority domain starts handling the
> > > events again, as expected.  I haven't delved into to code to see how easy
> > > this is to change - mostly because I'm not sure that this isn't
> > > uninitended behaviour.
> > >
> >
> > Actually, this is. I mean: a bug. Please try applying the following
> > patch to adeos/generic.c and let me know of the outcome. This said, keep
> > in mind that fixing this bug will make your box crash if you intend to
> > keep a handler attached which ends up disappearing from the address
> > space after the module is unloaded.
> > Thanks for the report.
> >
> > --- generic.c	4 Oct 2004 17:34:19 -0000	1.17
> > +++ generic.c	14 Oct 2004 16:24:53 -0000
> > @@ -173,7 +173,7 @@
> >
> >      for (event = 0; event < ADEOS_NR_EVENTS; event++)
> >  	/* Need this to update the monitor count. */
> > -	adeos_catch_event(event,NULL);
> > +	adeos_catch_event_from(adp,event,NULL);
> >
> >  #ifdef CONFIG_SMP
> >      {
> > --
> >
> > Philippe.
> >
> >
> 
> 
> _______________________________________________
> Adeos-main mailing list
> Adeos-main@domain.hid
> https://mail.gna.org/listinfo/adeos-main
-- 

Philippe.



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

* Re: [Adeos-main] Behaviour of adeos_catch_event when domain unregistered
  2004-10-14 19:09     ` Philippe Gerum
@ 2004-10-14 20:32       ` Currie Reid
  0 siblings, 0 replies; 5+ messages in thread
From: Currie Reid @ 2004-10-14 20:32 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: adeos-main

Makes perfect sense - I was assuming (erroneously) that the module exit
routine WAS within the non-root domain and you could use the shorthand
form.  I have put in the explicit form:

adeos_catch_event_from(&domain_desc,event,NULL)

and this works great - I also note that you say it is unecessary; I just
wanted to verify your theory.

Thanks for your help,

Currie


On Thu, 14 Oct 2004, Philippe Gerum wrote:

> On Thu, 2004-10-14 at 20:13, Currie Reid wrote:
> > Hello Philippe,
> >
> > The patch works, but raises one or two questions (sorry!).  First, I
> > understood what you meant about the disappearing handler crashing the box,
> > so what I did in the root level domain is on module unloading I reset the
> > handler to null -
> >
> > static void __exit my_cleanup( void ){
> >
> >    adeos_catch_event( ADEOS_EXIT_PROCESS, 0 );
> >    adeos_unregister_domain( &domain_desc );
> > }
> >
> > which works in the root domain.  So I figured that this might be a proper
> > clean-up procedure in higher priority domains.  So I did the same thing in
> > the module cleanup routine when registering a domain for the same event.
> > When this module is unloaded, the handler does not default back to the
> > root domain handler.  Without the cleanup, it works as I would have
> > expected, but if I reset the handler in the higher priority domain, it
> > seems to wipe out the handler further down the pipe.  Again, I don't know
> > if this is intended behaviour, but I would have thought that setting the
> > event handler in a higher priority domain to null would have no affect on
> > lower priority (or root) domains.  These lower priority domains would
> > retain the handler attributed to them at the time of their entry.
> >
>
> First guess: maybe because you are using adeos_catch_event() to nullify
> it, which implicitely does
> adeos_catch_event_from(adp_current,event,NULL) [i.e. it's a shorthand] ,
> and on behalf of a module cleanup routine, adp_current == adp_root, i.e.
> Linux?
>
> So, if you want to clean it up at the most prioritary level, you have to
> write adeos_catch_event_from(&domain_desc,event,NULL), this way, the
> current domain (Linux) won't be implicitely used for the operation.
>
> However, unregistering a domain (now) properly releases all events for
> it since the stage it occupies disappears, so you don't need to clear
> the event handlers manually for this domain.
>
> > Currie
> >
> >
> > On Thu, 14 Oct 2004, Philippe Gerum wrote:
> >
> > > On Thu, 2004-10-14 at 15:41, Currie Reid wrote:
> > > > Hello all,
> > > >
> > > > I am just trying to understand the underlying behaviour of adeos, and in
> > > > my testing I have come across some behaviour that I want to verify is
> > > > correct.  If I set a handler for ADEOS_EXIT_PROCESS without registering a
> > > > domain, then the handler is in the root domain and behaves as expected
> > > > (thank you printk!).  Next, I do a handler in a registered domain for
> > > > ADEOS_EXIT_PROCESS and perform 2 tests - 1 where the handler doesn't
> > > > propagate the event to the root domain, and one where it does.  These both
> > > > behave as expected - when propagated, I see the handler executing once for
> > > > each domain.  But when I unload the module and unregister the domain, the
> > > > handler in the root domain no longer executes - I would have thought that
> > > > the handler would still be in place.
> > > >
> > > > If I register 2 domains and duplicate the test, when the higher priority
> > > > domain is unregistered, the lower priority domain starts handling the
> > > > events again, as expected.  I haven't delved into to code to see how easy
> > > > this is to change - mostly because I'm not sure that this isn't
> > > > uninitended behaviour.
> > > >
> > >
> > > Actually, this is. I mean: a bug. Please try applying the following
> > > patch to adeos/generic.c and let me know of the outcome. This said, keep
> > > in mind that fixing this bug will make your box crash if you intend to
> > > keep a handler attached which ends up disappearing from the address
> > > space after the module is unloaded.
> > > Thanks for the report.
> > >
> > > --- generic.c	4 Oct 2004 17:34:19 -0000	1.17
> > > +++ generic.c	14 Oct 2004 16:24:53 -0000
> > > @@ -173,7 +173,7 @@
> > >
> > >      for (event = 0; event < ADEOS_NR_EVENTS; event++)
> > >  	/* Need this to update the monitor count. */
> > > -	adeos_catch_event(event,NULL);
> > > +	adeos_catch_event_from(adp,event,NULL);
> > >
> > >  #ifdef CONFIG_SMP
> > >      {
> > > --
> > >
> > > Philippe.
> > >
> > >
> >
> >
> > _______________________________________________
> > Adeos-main mailing list
> > Adeos-main@domain.hid
> > https://mail.gna.org/listinfo/adeos-main
> --
>
> Philippe.
>
>





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

end of thread, other threads:[~2004-10-14 20:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-14 13:41 [Adeos-main] Behaviour of adeos_catch_event when domain unregistered Currie Reid
2004-10-14 16:30 ` Philippe Gerum
2004-10-14 18:13   ` Currie Reid
2004-10-14 19:09     ` Philippe Gerum
2004-10-14 20:32       ` Currie Reid

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.