Re: OpenBSD File systems , on Flash / SSD CPE (in sites with uncontrolled power (CPE customer sites)

2022-11-28 Thread dirk coetzee
We had a similar challenge. My advice would be to leave all the filesystems as 
is - and add the 'sync' flag. 

It slows down disk access - but makes the filesystem resilient to power 
outages. See sync option - https://man.openbsd.org/mount


   On Tuesday, 29 November 2022 at 09:03:28 am AWST, Yoshihiro Kawamata 
 wrote:  
 
 Hi,

In the case of CPE, I do not think that programs will be added or
removed after the start of operation, so I think that the following
partition can be mounted as read-only to reduce the impact of power
failure.

/bin
/sbin
/usr
/usr/local (with wxallowed)

For the rest, you can just mount them with mfs in conjunction with
persistent storage.

Yoshihiro Kawamata
https://fuguita.org/

  


Re: OpenBSD File systems , on Flash / SSD CPE (in sites with uncontrolled power (CPE customer sites)

2022-11-28 Thread Yoshihiro Kawamata
Hi,

In the case of CPE, I do not think that programs will be added or
removed after the start of operation, so I think that the following
partition can be mounted as read-only to reduce the impact of power
failure.

/bin
/sbin
/usr
/usr/local (with wxallowed)

For the rest, you can just mount them with mfs in conjunction with
persistent storage.

Yoshihiro Kawamata
https://fuguita.org/



Re: OpenBSD File systems , on Flash / SSD CPE (in sites with uncontrolled power (CPE customer sites)

2022-11-28 Thread Brian Conway
On Mon, Nov 28, 2022, at 4:06 PM, Tom Smyth wrote:
> /dev/sd0a / ffs rw,softdep,noatime 1 1
> /dev/sd0d /usr/local ffs rw,wxallowed,nodev,softdep,noatime 1 1

softdep is a useful option for metadata-heavy workloads, but it is not a 
magical go-fast flag. While it's possible that characterization is true for 
your /usr/local mount, I would guess it is probably not for /.

Brian



Re: OpenBSD File systems , on Flash / SSD CPE (in sites with uncontrolled power (CPE customer sites)

2022-11-28 Thread Tom Smyth
sorry  there was an omission in my /etc/fstab
i had left out the softdep,noatime flags on the filessytems that were
funning off the disk using FFS
Thanks
#begin corrected /etc/fstab##
/dev/sd0a / ffs rw,softdep,noatime 1 1
/dev/sd0d /usr/local ffs rw,wxallowed,nodev,softdep,noatime 1 1
swap /tmp mfs rw,nosuid,noexec,nodev,-s=256000,-P=/persist-fs/tmp 0 0
swap /var mfs rw,nosuid,noexec,nodev,-s=512000,-P=/persist-fs/var 0 0
swap /dev mfs rw,nosuid,noexec,-P=/persist-fs/dev,-i=2048,-s=102400 0 0

##end-corrected /etc/fstab##


On Mon, 28 Nov 2022 at 21:46, Tom Smyth 
wrote:

> Hello, Folks,
>
> Im reviewing our filesystem setup for OpenBSD CPEs that we deploy in the
> field
>
> in order to minimise the impact of Power Outages / Customer interference
> on the boxes,
> we install a 4G root partition /
> and a 2GB /usr/local (to allow the wxallowed flag for the filesystem)
>
> we use mfs for /tmp and /var  so that there the probability that there is
> a filessytem write to the SSD is reduced (so that power failures dont cause
> file system corruption)
>
> we use the following  fstabl
>
> #begin /etc/fstab/###
> /dev/sd0a / ffs rw 1 1
> /dev/sd0d /usr/local ffs rw,wxallowed,nodev 1 1
> swap /tmp mfs rw,nosuid,noexec,nodev,-s=256000,-P=/persist-fs/tmp 0 0
> swap /var mfs rw,nosuid,noexec,nodev,-s=512000,-P=/persist-fs/var 0 0
> swap /dev mfs rw,nosuid,noexec,-P=/persist-fs/dev,-i=2048,-s=102400 0 0
> #end  /etc/fstab/###
>
> and the persist-fs folders are created by installing OpenBSD, installing
> packages and running
> the following commands to copy /var /tmp and /dev to a persistent location
> on /
> ###setup commands #
> mkdir -p /persist-fs/dev
> mkdir -p /persist-fs/tmp
> mkdir -p /persist-fs/var
> cp -Rp /var/* /persist-fs/var
> cp -Rp /tmp/* /persist-fs/tmp
> cp -p /dev/MAKEDEV /persist-fs/dev/
> cd /persist-fs/dev/
> /persist-fs/dev/MAKEDEV all
>
> any feedback welcome, are there other folders that could be heavily
> written to ?
> is there shortcommings  I have ommited swap (because of flash and ssd wear
> concerns)
> I hope this helps...
> Tom Smyth
>
>
> --
> Kindest regards,
> Tom Smyth.
>


-- 
Kindest regards,
Tom Smyth.


OpenBSD File systems , on Flash / SSD CPE (in sites with uncontrolled power (CPE customer sites)

2022-11-28 Thread Tom Smyth
Hello, Folks,

Im reviewing our filesystem setup for OpenBSD CPEs that we deploy in the
field

in order to minimise the impact of Power Outages / Customer interference on
the boxes,
we install a 4G root partition /
and a 2GB /usr/local (to allow the wxallowed flag for the filesystem)

we use mfs for /tmp and /var  so that there the probability that there is a
filessytem write to the SSD is reduced (so that power failures dont cause
file system corruption)

we use the following  fstabl

#begin /etc/fstab/###
/dev/sd0a / ffs rw 1 1
/dev/sd0d /usr/local ffs rw,wxallowed,nodev 1 1
swap /tmp mfs rw,nosuid,noexec,nodev,-s=256000,-P=/persist-fs/tmp 0 0
swap /var mfs rw,nosuid,noexec,nodev,-s=512000,-P=/persist-fs/var 0 0
swap /dev mfs rw,nosuid,noexec,-P=/persist-fs/dev,-i=2048,-s=102400 0 0
#end  /etc/fstab/###

and the persist-fs folders are created by installing OpenBSD, installing
packages and running
the following commands to copy /var /tmp and /dev to a persistent location
on /
###setup commands #
mkdir -p /persist-fs/dev
mkdir -p /persist-fs/tmp
mkdir -p /persist-fs/var
cp -Rp /var/* /persist-fs/var
cp -Rp /tmp/* /persist-fs/tmp
cp -p /dev/MAKEDEV /persist-fs/dev/
cd /persist-fs/dev/
/persist-fs/dev/MAKEDEV all

any feedback welcome, are there other folders that could be heavily written
to ?
is there shortcommings  I have ommited swap (because of flash and ssd wear
concerns)
I hope this helps...
Tom Smyth


-- 
Kindest regards,
Tom Smyth.


Re: Query on installing Solaris 9 into an OBSD LDOM

2022-11-28 Thread Stuff Received

On 2022-11-28 00:16, Bodie wrote:

On 28.11.2022 05:50, Kevin Williams wrote (in part):

Greetings.

Has anyone tried to install Solaris 9 into an OBSD LDOM running on a 
TS2000?


(I found some information on the mailing list pertaining to different
machines and Solaris versions.)

Sincerely,
N.


We need more information to better assist you.

By LDOM, do you mean you want to use Oracle VM Server for Sparc? Does
that even run on OpenBSD?


He obviously talks about OpenBSD technology ldomd(8) ;-)


Yes.




Or are you using OpenBSD’s native vmm?

Are you using the Sparc or Intel version of Solaris 9?

Which architecture does the host machine use?


The T2000 (not the TS2000 -- my mistake above) is a T1 Sparc machine 
(https://en.wikipedia.org/wiki/Sun_Fire_T2000).


Various OBSD people wrote about running LDOMs on T1000/T2000 (for 
example, https://marc.info/?l=openbsd-misc=162080102109613=2) but 
nothing about Solaris 9.


Sincerely,
N.



Re: Configure OpenBSD for remote server rarely used

2022-11-28 Thread James Johnson
Ah, pretty cool, I'll keep it in mind for my next project ;)

On 28.11.2022 10:36, Bodie wrote:

And if you really need low consumption, rugged computer and do not mind
about the costs you can go eg. this way :-)

https://teguar.com/ip67-box-pc-twb-2945 
/


Re: pcengines apu{1,4} can't adjust CPU frequency automatically anymore

2022-11-28 Thread Lévai , Dániel
On Monday, November 28th, 2022 at 08:43, Jan Johansson 
 wrote:
> 
> 
> 
> 
> "Lévai, Dániel" l...@ecentrum.hu wrote:
> 
> > I don't know since when, unfortunately, but it seems
> > auto-adjusting CPU frequency doesn't work anymore on my APU1
> > and an APU4 PCEngines boards (I only have these versions at
> > hand atm). They're both running an updated fw at v4.17.0.2.
> > 
[...]
> 
> 
> Hello!
> 
> Since some time auto scaling (by OpenBSD) is disabled while the
> system is connected to AC power. This might not be a problem
> since many systems seems to handle scaling by themself.

Oh, got you [1]. Thanks!


[1] - https://marc.info/?l=openbsd-cvs=163563630606615=2



Re: Configure OpenBSD for remote server rarely used

2022-11-28 Thread Bodie




On 28.11.2022 11:18, James Johnson wrote:
Thanks a lot for all the great advice, that is very useful. It all 
makes sense.




And if you really need low consumption, rugged computer and do not mind
about the costs you can go eg. this way :-)

https://teguar.com/ip67-box-pc-twb-2945/


On 27 Nov 2022, at 21:10, Tomasz Rola  wrote:

On Sun, Nov 27, 2022 at 09:37:19AM +, James Johnson wrote:

Hi all,

OpenBSD is amazing. But I need help in configuring it correctly as a
remote server, rarely used.


The main thing I am trying to do is to make it sleep every now and
then to protect resources. I am very flexible on how to do this, but
have been unable to do so.
Here's what I tried :

[...]

So to sum up your requirements, you want a self driving box which
waits, and once every month or six wakes up, does something, then goes
idle again.

I would avoid power down/up completely - boot takes time, and fsck
takes some more time. Also, AFAIK electronics wears down every time it
goes on-off.

Modern HDD are said to live to 5 on-off cycles, so assume 2
cold boots. But random things can happen, because on-off means power
spike. If you have no problem with eletricity, I would keep it going
all the time. I would however minimise writes. Work on temporary data
in ramdisk, write results to disk. Something like this.

BIOS battery goes down faster when computer is powered down. When it
is up, clock gets power from the wall and saves the battery. I assume
the modern CMOS battery will only keep the clock for about a year
without power and it will not recharge when you power up. After that
time (and before that time, too, but less necessary), every boot
should include query to time server and adjusting the hardware clock.

I would buy a decent PSU. Last time I wanted to know, Seasonic was the
maker of best ones a mortal could buy. Their last unit I bought came
with 10 years warranty. AND, according to description, it was built
with classic electronic art, analog parts, no digital. So if you are
so inclined, you can ask your electronic buddy to inspect it and
perhaps even replace some parts with better ones. Or repair it. If
microcontroller goes bunk, you are out of luck, I assume they somehow
protect their eproms.

If you plan to store some long term data on this box, I would avoid
SSD. They are fast but they also can go bunk and when they do, chance
of recovering data is close to nil (from what I have read).

I would consider putting the box in a plastic bag to protect from dust
and humidity. Dust will clog into radiators, make chips go hotter,
ventillators work harder. I have not tested this, however. I assume
thermal exchange with loose bag over the box should go ok, but you
need to test it very carefully, monitoring temps all the time - all
temps.

HTH

--
Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **




Re: Configure OpenBSD for remote server rarely used

2022-11-28 Thread James Johnson
Thanks a lot for all the great advice, that is very useful. It all makes sense.

> On 27 Nov 2022, at 21:10, Tomasz Rola  wrote:
> 
> On Sun, Nov 27, 2022 at 09:37:19AM +, James Johnson wrote:
>> Hi all,
>> 
>> OpenBSD is amazing. But I need help in configuring it correctly as a
>> remote server, rarely used. 
>> 
>> 
>> The main thing I am trying to do is to make it sleep every now and
>> then to protect resources. I am very flexible on how to do this, but
>> have been unable to do so.
>> Here's what I tried :
> [...]
> 
> So to sum up your requirements, you want a self driving box which
> waits, and once every month or six wakes up, does something, then goes
> idle again.
> 
> I would avoid power down/up completely - boot takes time, and fsck
> takes some more time. Also, AFAIK electronics wears down every time it
> goes on-off.
> 
> Modern HDD are said to live to 5 on-off cycles, so assume 2
> cold boots. But random things can happen, because on-off means power
> spike. If you have no problem with eletricity, I would keep it going
> all the time. I would however minimise writes. Work on temporary data
> in ramdisk, write results to disk. Something like this.
> 
> BIOS battery goes down faster when computer is powered down. When it
> is up, clock gets power from the wall and saves the battery. I assume
> the modern CMOS battery will only keep the clock for about a year
> without power and it will not recharge when you power up. After that
> time (and before that time, too, but less necessary), every boot
> should include query to time server and adjusting the hardware clock.
> 
> I would buy a decent PSU. Last time I wanted to know, Seasonic was the
> maker of best ones a mortal could buy. Their last unit I bought came
> with 10 years warranty. AND, according to description, it was built
> with classic electronic art, analog parts, no digital. So if you are
> so inclined, you can ask your electronic buddy to inspect it and
> perhaps even replace some parts with better ones. Or repair it. If
> microcontroller goes bunk, you are out of luck, I assume they somehow
> protect their eproms.
> 
> If you plan to store some long term data on this box, I would avoid
> SSD. They are fast but they also can go bunk and when they do, chance
> of recovering data is close to nil (from what I have read).
> 
> I would consider putting the box in a plastic bag to protect from dust
> and humidity. Dust will clog into radiators, make chips go hotter,
> ventillators work harder. I have not tested this, however. I assume
> thermal exchange with loose bag over the box should go ok, but you
> need to test it very carefully, monitoring temps all the time - all
> temps.
> 
> HTH
> 
> -- 
> Regards,
> Tomasz Rola
> 
> --
> ** A C programmer asked whether computer had Buddha's nature.  **
> ** As the answer, master did "rm -rif" on the programmer's home**
> ** directory. And then the C programmer became enlightened...  **
> ** **
> ** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **



Re: IPv6: ifconfig & rad messages fight disabling routes

2022-11-28 Thread Stuart Henderson
On 2022-11-28, Geoff Steckel  wrote:
> Short form:
>    I'm using rad to update local machines with the IPv6 address prefix
> currently assigned by Verizon. It runs on my firewall/external router.
> The router advertisement destructively changes the route and interface
> of an address on that machine.
>
> dhcpcd gets /56 from Verizon fiber service.
> manually ifconfig interface1 inet6 ::9/56
> netstat -rn -f inet6 shows
>    :: and ::9 routed via interface1
> everything works.
> rad message sent out from interface1:
>    /56 valid 1000 preferred 1

IPv6 stateless autoconfig on ethernet only supports /64 prefixes.

https://www.rfc-editor.org/rfc/rfc2464#section-4

   An IPv6 address prefix used for stateless autoconfiguration [ACONF]
   of an Ethernet interface must have a length of 64 bits.

What is supposed to happen is that dhcpcd assigns /64s to your "inside"
interfaces listed on the ia_pd line, and installs a -reject localhost
route for the wider prefix - it's your side of the link, so if you send
packets upstream they'll loop back to you, it installs the reject route
to avoid this. It's not intended that you assign delegated prefixes
manually.


-- 
Please keep replies on the mailing list.



Re: Configure OpenBSD for remote server rarely used

2022-11-28 Thread Greg Thomas
You should reboot whenever patches or upgrades require it.  Was that a
trick question or something?

On Mon, Nov 28, 2022 at 12:51 AM Greg Thomas 
wrote:

>
>
> On Sun, Nov 27, 2022 at 12:08 PM James Johnson 
> wrote:
>
>> Thank you for this interesting perspective.
>>
>> Combined with the previous advice, I am convinced. I will not try to have
>> the machine sleep, or even try to put the drives in spun down. From what
>> you guys are saying, it seems doing so would be over-engineering.
>>
>> What are your thoughts regarding reboots? Should I do a daily, weekly,
>> monthly reboot?
>>
>>
>> > On 27 Nov 2022, at 20:00, Bodie  wrote:
>> >
>> >
>> >
>> > On 27.11.2022 10:37, James Johnson wrote:
>> >> Hi all,
>> >> OpenBSD is amazing. But I need help in configuring it correctly as a
>> >> remote server, rarely used.
>> >> The main thing I am trying to do is to make it sleep every now and
>> >> then to protect resources. I am very flexible on how to do this, but
>> >> have been unable to do so.
>> >> Here's what I tried :
>> >> 1) Make it sleep and wake up when woken up remotely
>> >> I investigated Wake On Lan, which I enabled via ifconfig. However,
>> >> this system is deployed remotely, and I have no access to other
>> >> computers on the LAN, so I am unable to make this work.
>> >> 2) Make it sleep for a few hours and then wake up
>> >> After 3hours+ of research in man pages and the internet, I have not
>> >> seen any solution for that.
>> >> 3) hard drives Spin down, CPU lower freq
>> >> I have been able to lower the CPU speed by running `apm -L`.
>> >> I haven't been able to spin down the hard drives.
>> >> How important is it to manually send a command to spin down the unused
>> >> harddrives? Will it be down by the system automatically?
>> >> I am trying to get info on the drives from the system but `atactl sd0
>> >> checkpower ` always shows `standby` even after I have just written on
>> >> the disk. I understand this does not work because my drives are SCSI
>> >> and not ATA.
>> >> I read the man page for scsi, and I see the command to spin down hard
>> >> drives : `scsi -f /dev/rsd2c -c "1b 0 0 0 0 0"`
>> >> However, I see no command to spin them back up. Is it automatic?
>> >> How can I request information on the spin state of the drive. I am
>> >> just a little worried about starting to send low levels instructions
>> >> to the hard drive, with little understanding of it. Is it safe to send
>> >> this command?
>> >> Thanks all !
>> >> PS : dmesg : I cannot share the full dmesg for security reasons, but
>> >> it is a fairly standard i386 machine, with 2 drives mounted as SCSI.
>> >
>> > As already pointed out by others. Don't do that ;-) Unless you explain
>> > why you need to do that (I'm sure it is possible without disclosing
>> much)
>> >
>> > I build systems running for eg. 12 years, amd64 architecture, SATA
>> disks,
>> > DDR RAM and so on. Serving number of virtual machines with constantly
>> > higher number of utilizations and in dozens of them only 2 problems
>> > during those years - battery for internal RAID run out :-)
>> >
>> > Saw systems which were running for over 30 years and nothing wrong with
>> > them.
>> >
>> > Can't talk about electricity as those are basically underground cities
>> > and there are different problems then if CPU is running 3 or 1GHz ;-)
>> >
>> > Sounds like maybe some IoT solution, but then go for ARM or use virtual
>> > machine in eg. OpenBSD Amsterdam or you really need compute power on
>> > demand then go for free options in eg. Azure (12 months free basic
>> Linux)
>> > or Oracle Cloud Infrastructure or whatever else you find fit.
>> >
>> > Either it is so important, need to be physically under your control and
>> > then small differences in electricity does not matter or solutions above
>> > are perfectly fine for your needs.
>> >
>> > Just one hint. No matter if own machine or something rented you want
>> that
>> > machine to be worth the money that means to do something on it and not
>> > have it shut down ;-)
>>
>>


Re: Configure OpenBSD for remote server rarely used

2022-11-28 Thread Greg Thomas
On Sun, Nov 27, 2022 at 12:08 PM James Johnson 
wrote:

> Thank you for this interesting perspective.
>
> Combined with the previous advice, I am convinced. I will not try to have
> the machine sleep, or even try to put the drives in spun down. From what
> you guys are saying, it seems doing so would be over-engineering.
>
> What are your thoughts regarding reboots? Should I do a daily, weekly,
> monthly reboot?
>
>
> > On 27 Nov 2022, at 20:00, Bodie  wrote:
> >
> >
> >
> > On 27.11.2022 10:37, James Johnson wrote:
> >> Hi all,
> >> OpenBSD is amazing. But I need help in configuring it correctly as a
> >> remote server, rarely used.
> >> The main thing I am trying to do is to make it sleep every now and
> >> then to protect resources. I am very flexible on how to do this, but
> >> have been unable to do so.
> >> Here's what I tried :
> >> 1) Make it sleep and wake up when woken up remotely
> >> I investigated Wake On Lan, which I enabled via ifconfig. However,
> >> this system is deployed remotely, and I have no access to other
> >> computers on the LAN, so I am unable to make this work.
> >> 2) Make it sleep for a few hours and then wake up
> >> After 3hours+ of research in man pages and the internet, I have not
> >> seen any solution for that.
> >> 3) hard drives Spin down, CPU lower freq
> >> I have been able to lower the CPU speed by running `apm -L`.
> >> I haven't been able to spin down the hard drives.
> >> How important is it to manually send a command to spin down the unused
> >> harddrives? Will it be down by the system automatically?
> >> I am trying to get info on the drives from the system but `atactl sd0
> >> checkpower ` always shows `standby` even after I have just written on
> >> the disk. I understand this does not work because my drives are SCSI
> >> and not ATA.
> >> I read the man page for scsi, and I see the command to spin down hard
> >> drives : `scsi -f /dev/rsd2c -c "1b 0 0 0 0 0"`
> >> However, I see no command to spin them back up. Is it automatic?
> >> How can I request information on the spin state of the drive. I am
> >> just a little worried about starting to send low levels instructions
> >> to the hard drive, with little understanding of it. Is it safe to send
> >> this command?
> >> Thanks all !
> >> PS : dmesg : I cannot share the full dmesg for security reasons, but
> >> it is a fairly standard i386 machine, with 2 drives mounted as SCSI.
> >
> > As already pointed out by others. Don't do that ;-) Unless you explain
> > why you need to do that (I'm sure it is possible without disclosing much)
> >
> > I build systems running for eg. 12 years, amd64 architecture, SATA disks,
> > DDR RAM and so on. Serving number of virtual machines with constantly
> > higher number of utilizations and in dozens of them only 2 problems
> > during those years - battery for internal RAID run out :-)
> >
> > Saw systems which were running for over 30 years and nothing wrong with
> > them.
> >
> > Can't talk about electricity as those are basically underground cities
> > and there are different problems then if CPU is running 3 or 1GHz ;-)
> >
> > Sounds like maybe some IoT solution, but then go for ARM or use virtual
> > machine in eg. OpenBSD Amsterdam or you really need compute power on
> > demand then go for free options in eg. Azure (12 months free basic Linux)
> > or Oracle Cloud Infrastructure or whatever else you find fit.
> >
> > Either it is so important, need to be physically under your control and
> > then small differences in electricity does not matter or solutions above
> > are perfectly fine for your needs.
> >
> > Just one hint. No matter if own machine or something rented you want that
> > machine to be worth the money that means to do something on it and not
> > have it shut down ;-)
>
>


Re: pcengines apu{1,4} can't adjust CPU frequency automatically anymore

2022-11-28 Thread Jan Johansson
"Lévai, Dániel"  wrote:
> I don't know since when, unfortunately, but it seems
> auto-adjusting CPU frequency doesn't work anymore on my APU1
> and an APU4 PCEngines boards (I only have these versions at
> hand atm).  They're both running an updated fw at v4.17.0.2.
> 
> IIRC `apmd -A' + `sysctl hw.perfpolicy=auto' did the trick
> earlier, but I'll be honest, I haven't checked this since
> forever.
> 
> APU1 has two and the APU4 has three frequencies to set:
> cpu0: 1000 MHz: speeds: 1000 800 MHz
> cpu0: 998 MHz: speeds: 1000 800 600 MHz
> 
> I can manually adjust this with hw.setperf when hw.perfpolicy
> is 'manual', so setting the frequency actually works, it's just
> that it can't seems to "detect" load/change when it's set to
> 'auto'.

Hello!

Since some time auto scaling (by OpenBSD) is disabled while the
system is connected to AC power. This might not be a problem
since many systems seems to handle scaling by themself.

My APU4 has about the same temperature as before the upgrade.
Setting the CPU speed to 600MHz does not lower the temperature.
While perfpolicy is set to auto, if I start four "openssl speed"
the temperature will quickly rise.

My conclusion from this is that the APU4 will handle scaling on
its own.

Best regards,
Jan J



Re: pcengines apu{1,4} can't adjust CPU frequency automatically anymore

2022-11-28 Thread Stuart Henderson
On 2022-11-28, Lévai  Dániel  wrote:
> Hi all,
>
> I don't know since when, unfortunately, but it seems auto-adjusting CPU 
> frequency doesn't work anymore on my APU1 and an APU4 PCEngines boards (I 
> only have these versions at hand atm).
> They're both running an updated fw at v4.17.0.2.
>
> IIRC `apmd -A' + `sysctl hw.perfpolicy=auto' did the trick earlier, but I'll 
> be honest, I haven't checked this since forever.
>
> APU1 has two and the APU4 has three frequencies to set:
> cpu0: 1000 MHz: speeds: 1000 800 MHz
> cpu0: 998 MHz: speeds: 1000 800 600 MHz
>
> I can manually adjust this with hw.setperf when hw.perfpolicy is 'manual', so 
> setting the frequency actually works, it's just that it can't seems to 
> "detect" load/change when it's set to 'auto'.

One option is to use a diff like below, I'm not sure how much difference
it will make to power consumption on APU though.

It can depend on what the machine is doing too; if it's idle a lot then
it will already be spending a fair bit of time in mwait, reducing the
clock speed either won't help or may even make things use more power
(takes longer to execute code before it can go back in low power mwait
state) - if it's not quite as idle then this probably helps more.

It gives a measurable improvement on my main laptop (partly lower
power use from cpu, partly less power use from the fan because it's on
less often - obviously the latter doesn't help apu :)

If you want to see if it's helping and can't measure power consumption
directly, checking the temperature under normal conditions is probably
not a bad proxy.

Index: kern/sched_bsd.c
===
RCS file: /cvs/src/sys/kern/sched_bsd.c,v
retrieving revision 1.72
diff -u -p -r1.72 sched_bsd.c
--- kern/sched_bsd.c14 Aug 2022 01:58:27 -  1.72
+++ kern/sched_bsd.c28 Nov 2022 08:09:47 -
@@ -543,7 +543,7 @@ setperf_auto(void *v)
if (cpu_setperf == NULL)
return;
 
-   if (hw_power) {
+   if (0 && hw_power) {
speedup = 1;
goto faster;
}