Re: i386: apm(4): apm_thread(): sleep without lbolt

2020-12-23 Thread Scott Cheloha
On Tue, Dec 15, 2020 at 09:15:31AM -0300, Martin Pieuchot wrote:
> On 11/12/20(Fri) 19:17, Scott Cheloha wrote:
> > Here's another sleep that doesn't need lbolt.
> > 
> > The idea here is to call apm_periodic_check() once a second.
> > We can do that without lbolt.
> > 
> > Is there some other address that would be more appropriate for this
> > thread to sleep on?  It doesn't look like any apm(4) code calls
> > wakeup(9) on lbolt so I've just replaced with with a local channel.
> 
> Note sure we want to grow the stack just for that.  Any member of `sc',
> or even `sc' itself if this doesn't conflict, could be used as wait
> channel.

Assuming we go ahead with the global nowake channel, is this ok?

Index: apm.c
===
RCS file: /cvs/src/sys/arch/i386/i386/apm.c,v
retrieving revision 1.125
diff -u -p -r1.125 apm.c
--- apm.c   24 Jun 2020 22:03:40 -  1.125
+++ apm.c   23 Dec 2020 21:03:50 -
@@ -909,7 +909,7 @@ apm_thread(void *v)
rw_enter_write(>sc_lock);
(void) apm_periodic_check(sc);
rw_exit_write(>sc_lock);
-   tsleep_nsec(, PWAIT, "apmev", INFSLP);
+   tsleep_nsec(nowake, PWAIT, "apmev", SEC_TO_NSEC(1));
}
 }
 



Re: i386: apm(4): apm_thread(): sleep without lbolt

2020-12-15 Thread Martin Pieuchot
On 11/12/20(Fri) 19:17, Scott Cheloha wrote:
> Here's another sleep that doesn't need lbolt.
> 
> The idea here is to call apm_periodic_check() once a second.
> We can do that without lbolt.
> 
> Is there some other address that would be more appropriate for this
> thread to sleep on?  It doesn't look like any apm(4) code calls
> wakeup(9) on lbolt so I've just replaced with with a local channel.

Note sure we want to grow the stack just for that.  Any member of `sc',
or even `sc' itself if this doesn't conflict, could be used as wait
channel. 

> ok?
> 
> Index: apm.c
> ===
> RCS file: /cvs/src/sys/arch/i386/i386/apm.c,v
> retrieving revision 1.125
> diff -u -p -r1.125 apm.c
> --- apm.c 24 Jun 2020 22:03:40 -  1.125
> +++ apm.c 12 Dec 2020 01:17:38 -
> @@ -50,6 +50,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include 
>  #include 
> @@ -904,12 +905,13 @@ void
>  apm_thread(void *v)
>  {
>   struct apm_softc *sc = v;
> + int chan;
>  
>   for (;;) {
>   rw_enter_write(>sc_lock);
>   (void) apm_periodic_check(sc);
>   rw_exit_write(>sc_lock);
> - tsleep_nsec(, PWAIT, "apmev", INFSLP);
> + tsleep_nsec(, PWAIT, "apmev", SEC_TO_NSEC(1));
>   }
>  }
>  
> 



i386: apm(4): apm_thread(): sleep without lbolt

2020-12-11 Thread Scott Cheloha
Here's another sleep that doesn't need lbolt.

The idea here is to call apm_periodic_check() once a second.
We can do that without lbolt.

Is there some other address that would be more appropriate for this
thread to sleep on?  It doesn't look like any apm(4) code calls
wakeup(9) on lbolt so I've just replaced with with a local channel.

ok?

Index: apm.c
===
RCS file: /cvs/src/sys/arch/i386/i386/apm.c,v
retrieving revision 1.125
diff -u -p -r1.125 apm.c
--- apm.c   24 Jun 2020 22:03:40 -  1.125
+++ apm.c   12 Dec 2020 01:17:38 -
@@ -50,6 +50,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -904,12 +905,13 @@ void
 apm_thread(void *v)
 {
struct apm_softc *sc = v;
+   int chan;
 
for (;;) {
rw_enter_write(>sc_lock);
(void) apm_periodic_check(sc);
rw_exit_write(>sc_lock);
-   tsleep_nsec(, PWAIT, "apmev", INFSLP);
+   tsleep_nsec(, PWAIT, "apmev", SEC_TO_NSEC(1));
}
 }