Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Oct 2022 10:47:30 +0800
From:      Archimedes Gaviola <archimedes.gaviola@gmail.com>
To:        Mark Millard <marklmi@yahoo.com>
Cc:        freebsd-current <freebsd-current@freebsd.org>
Subject:   Re: 14.0-CURRENT failed to reclaim memory error in RPi 3B build
Message-ID:  <CAJFbk7FfYPSe3eF00HgDdebW70HKp5zKR0JaChTVniUDPG2qxQ@mail.gmail.com>
In-Reply-To: <84376CC9-B991-4BF3-AF5F-0AA09CB28339@yahoo.com>
References:  <84376CC9-B991-4BF3-AF5F-0AA09CB28339.ref@yahoo.com> <84376CC9-B991-4BF3-AF5F-0AA09CB28339@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000c615c905ec4ba1e6
Content-Type: text/plain; charset="UTF-8"

On Mon, Oct 31, 2022 at 1:29 AM Mark Millard <marklmi@yahoo.com> wrote:

> Archimedes Gaviola <archimedes.gaviola_at_gmail.com>wrote on
> Date: Sun, 30 Oct 2022 13:41:52 UTC :
>
> > I am building a kernel and world in 14.0-CURRENT
> >
> https://download.freebsd.org/ftp/snapshots/arm64/aarch64/ISO-IMAGES/14.0/FreeBSD-14.0-CURRENT-arm64-aarch64-RPI-20221027-769b884e2e2-258837.img.xz
> > with Raspberry Pi 3B  (ARM kernel config file and in default system
> > configurations) and compilation breaks due to "failed to reclaim memory"
> > error as found in the dmesg.
> >
> > pid 91224 (llvm-tblgen), jid 0, uid 0, was killed: failed to reclaim
> memory
> > pid 91131 (make), jid 0, uid 0, was killed: failed to reclaim memory
> >
> > Here's the set of the build commands I invoked.
> >
> > root@generic# cd /usr/src ; make KERNCONF=ARM TARGET_ARCH=aarch64
> > buildkernel buildworld installkernel installworld distribution
> > DESTDIR=/home/freebsd/rpi3b
> >
> > . . .
> >
> > Any thoughts? As I don't have any idea about VM pageout.
>

Hi Mark,


>
> Multiple configuration things from what I use:
>
> I use a swap partition (not a swap file!) to give the system
> someplace to put copies of inactive memory pages (paging):
>
> # swapinfo
> Device          1K-blocks     Used    Avail Capacity
> /dev/gpt/Rock64swp2   3670016        0  3670016     0%
>

Oh I see, there's no swap partition in the default installation.

root@generic:~ # swapinfo
Device          1K-blocks     Used    Avail Capacity

root@generic:~ # top -S
last pid: 92429;  load averages:  0.00,  0.00,  0.00
                                    up 1+12:49:11  23:41:10
52 processes:  2 running, 48 sleeping, 2 waiting
CPU:  0.0% user,  0.0% nice,  0.6% system,  0.0% interrupt, 99.4% idle
Mem: 2000K Active, 626M Inact, 223M Wired, 97M Buf, 20M Free

Let me try to create a swap partition. Let me mount a spare USB flash drive
for swap as during the installation all my microSD card storage was
allocated in the root filesystem with growfs.


>
> where gpart show -p lists it as (a gpt context, not MBR):
>
>       534528     7340032  da0p2  freebsd-swap  (3.5G)
>
> and gpart show -pl lists it as:
>
>       534528     7340032  da0p2  Rock64swp2  (3.5G)
>

Okay noted on GPT not MBR method with gpart. By the way, what's the proper
allocation size of swap in FreeBSD? This RPi 3B has 1GB of RAM (~947 MB),
do I need to set twice the capacity of this physical RAM?


>
> (Note: swap file usage is subject to deadlock conditions
> avoided by use of swap partitions.)
>

This is noted.


>
> I use a serial console & ssh session only context to avoid
> having sizable competition for RAM.
>
> I avoid using tmpfs because it competes for RAM use.
>
> I use the likes of ( in, say, /boot/loader/conf ):
>
> #
> # Delay when persistent low free RAM leads to
> # Out Of Memory killing of processes:
> vm.pageout_oom_seq=120
>
> This delays potential "killed: failed to reclaim memory" kills,
> possibly long enough to reach a state where sufficient memory is
> reclaimed.
>

Alright this is well noted too.


>
> I'll note that the status "killed: failed to reclaim memory" does
> not require that swap be used much at all. Sustained low free RAM
> from just one process that always stays runnable and has a
> sufficiently large active set of pages can be sufficient to end up
> with such kills. Having swap allows for inactive pages to get out
> of the way, which can help.
>
> I use the likes of ( in, say, /etc/ssyctl.conf ):
>
> #
> # Together this pair avoids swapping out the process kernel stacks.
> # This avoids processes for interacting with the system from being
> # hung-up.
> vm.swap_enabled=0
> vm.swap_idle_enabled=0
>
> This allows paging to the swap space but disallows moving
> kernel thread stacks to the swap space. Otherwise the
> processes used to interact with the RPi3 can become
> non-runnable, preventing such interactions.
>

Okay this too is well noted.


>
> I have NVMe or SSD based USB media, not microsd cards nor
> spinning rust. (I use just bootcode.bin and timeout files
> on microsd media for the RPi3B. Even the rest of the RPi*
> firmware is on the USB media, as well as u-boot.bin .)
>
> My usage of such a configuration struture for building
> software (world, kernel, ports) applies to all the
> systems I do such with, including ones with a lot more
> resources, including a lot more RAM.
>

Thanks for these inputs, noted on these things! I haven't tried NVMe and
SSD media in my RPi 3B. So, they are far more superior as compared to
microSD cards when it comes to building software?

Thanks and best regards,
Archimedes

--000000000000c615c905ec4ba1e6
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Mon, Oct 31, 2022 at 1:29 AM Mark =
Millard &lt;<a href=3D"mailto:marklmi@yahoo.com">marklmi@yahoo.com</a>&gt; =
wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0=
px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Archimede=
s Gaviola &lt;<a href=3D"http://archimedes.gaviola_at_gmail.com" rel=3D"nor=
eferrer" target=3D"_blank">archimedes.gaviola_at_gmail.com</a>&gt;wrote on<=
br>
Date: Sun, 30 Oct 2022 13:41:52 UTC :<br>
<br>
&gt; I am building a kernel and world in 14.0-CURRENT<br>
&gt; <a href=3D"https://download.freebsd.org/ftp/snapshots/arm64/aarch64/IS=
O-IMAGES/14.0/FreeBSD-14.0-CURRENT-arm64-aarch64-RPI-20221027-769b884e2e2-2=
58837.img.xz" rel=3D"noreferrer" target=3D"_blank">https://download.freebsd=
.org/ftp/snapshots/arm64/aarch64/ISO-IMAGES/14.0/FreeBSD-14.0-CURRENT-arm64=
-aarch64-RPI-20221027-769b884e2e2-258837.img.xz</a><br>
&gt; with Raspberry Pi 3B=C2=A0 (ARM kernel config file and in default syst=
em<br>
&gt; configurations) and compilation breaks due to &quot;failed to reclaim =
memory&quot;<br>
&gt; error as found in the dmesg.<br>
&gt; <br>
&gt; pid 91224 (llvm-tblgen), jid 0, uid 0, was killed: failed to reclaim m=
emory<br>
&gt; pid 91131 (make), jid 0, uid 0, was killed: failed to reclaim memory<b=
r>
&gt; <br>
&gt; Here&#39;s the set of the build commands I invoked.<br>
&gt; <br>
&gt; root@generic# cd /usr/src ; make KERNCONF=3DARM TARGET_ARCH=3Daarch64<=
br>
&gt; buildkernel buildworld installkernel installworld distribution<br>
&gt; DESTDIR=3D/home/freebsd/rpi3b<br>
&gt; <br>
&gt; . . .<br>
&gt; <br>
&gt; Any thoughts? As I don&#39;t have any idea about VM pageout.<br></bloc=
kquote><div><br></div><div>Hi Mark,</div><div>=C2=A0<br></div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px soli=
d rgb(204,204,204);padding-left:1ex">
<br>
Multiple configuration things from what I use:<br>
<br>
I use a swap partition (not a swap file!) to give the system<br>
someplace to put copies of inactive memory pages (paging):<br>
<br>
# swapinfo<br>
Device=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 1K-blocks=C2=A0 =C2=A0 =C2=A0Used=
=C2=A0 =C2=A0 Avail Capacity<br>
/dev/gpt/Rock64swp2=C2=A0 =C2=A03670016=C2=A0 =C2=A0 =C2=A0 =C2=A0 0=C2=A0 =
3670016=C2=A0 =C2=A0 =C2=A00%<br></blockquote><div><br></div><div>Oh I see,=
 there&#39;s no swap partition in the default installation.</div><div><br><=
/div><div>root@generic:~ # swapinfo<br>Device =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A01K-blocks =C2=A0 =C2=A0 Used =C2=A0 =C2=A0Avail Capacity<br><br>root@=
generic:~ # top -S<br>last pid: 92429; =C2=A0load averages: =C2=A00.00, =C2=
=A00.00, =C2=A00.00 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 u=
p 1+12:49:11 =C2=A023:41:10<br>52 processes: =C2=A02 running, 48 sleeping, =
2 waiting<br>CPU: =C2=A00.0% user, =C2=A00.0% nice, =C2=A00.6% system, =C2=
=A00.0% interrupt, 99.4% idle<br>Mem: 2000K Active, 626M Inact, 223M Wired,=
 97M Buf, 20M Free</div><div><br></div><div>Let me try to create a swap par=
tition. Let me mount a spare USB flash drive for swap as during the install=
ation all my microSD card storage was allocated in the root filesystem with=
 growfs.=C2=A0 <br></div><div>=C2=A0 </div><blockquote class=3D"gmail_quote=
" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);=
padding-left:1ex">
<br>
where gpart show -p lists it as (a gpt context, not MBR):<br>
<br>
=C2=A0 =C2=A0 =C2=A0 534528=C2=A0 =C2=A0 =C2=A07340032=C2=A0 da0p2=C2=A0 fr=
eebsd-swap=C2=A0 (3.5G)<br>
<br>
and gpart show -pl lists it as:<br>
<br>
=C2=A0 =C2=A0 =C2=A0 534528=C2=A0 =C2=A0 =C2=A07340032=C2=A0 da0p2=C2=A0 Ro=
ck64swp2=C2=A0 (3.5G)<br></blockquote><div><br></div><div>Okay noted on GPT=
 not MBR method with gpart. By the way, what&#39;s the proper allocation si=
ze of swap in FreeBSD? This RPi 3B has 1GB of RAM (~947 MB), do I need to s=
et twice the capacity of this physical RAM?<br></div><div>=C2=A0<br></div><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l=
eft:1px solid rgb(204,204,204);padding-left:1ex">
<br>
(Note: swap file usage is subject to deadlock conditions<br>
avoided by use of swap partitions.)<br></blockquote><div><br></div><div>Thi=
s is noted.</div><div>=C2=A0<br></div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddi=
ng-left:1ex">
<br>
I use a serial console &amp; ssh session only context to avoid<br>
having sizable competition for RAM.<br>
<br>
I avoid using tmpfs because it competes for RAM use.<br>
<br>
I use the likes of ( in, say, /boot/loader/conf ):<br>
<br>
#<br>
# Delay when persistent low free RAM leads to<br>
# Out Of Memory killing of processes:<br>
vm.pageout_oom_seq=3D120<br>
<br>
This delays potential &quot;killed: failed to reclaim memory&quot; kills,<b=
r>
possibly long enough to reach a state where sufficient memory is<br>
reclaimed.<br></blockquote><div><br></div><div>Alright this is well noted t=
oo.</div><div>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:=
1ex">
<br>
I&#39;ll note that the status &quot;killed: failed to reclaim memory&quot; =
does<br>
not require that swap be used much at all. Sustained low free RAM<br>
from just one process that always stays runnable and has a<br>
sufficiently large active set of pages can be sufficient to end up<br>
with such kills. Having swap allows for inactive pages to get out<br>
of the way, which can help.<br>
<br>
I use the likes of ( in, say, /etc/ssyctl.conf ):<br>
<br>
#<br>
# Together this pair avoids swapping out the process kernel stacks.<br>
# This avoids processes for interacting with the system from being<br>
# hung-up.<br>
vm.swap_enabled=3D0<br>
vm.swap_idle_enabled=3D0<br>
<br>
This allows paging to the swap space but disallows moving<br>
kernel thread stacks to the swap space. Otherwise the<br>
processes used to interact with the RPi3 can become<br>
non-runnable, preventing such interactions.<br></blockquote><div><br></div>=
<div>Okay this too is well noted.</div><div>=C2=A0<br></div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex">
<br>
I have NVMe or SSD based USB media, not microsd cards nor<br>
spinning rust. (I use just bootcode.bin and timeout files<br>
on microsd media for the RPi3B. Even the rest of the RPi*<br>
firmware is on the USB media, as well as u-boot.bin .)<br>
<br>
My usage of such a configuration struture for building<br>
software (world, kernel, ports) applies to all the<br>
systems I do such with, including ones with a lot more<br>
resources, including a lot more RAM.<br></blockquote><div><br></div><div>Th=
anks for these inputs, noted on these things! I haven&#39;t tried NVMe and =
SSD media in my RPi 3B. So, they are far more superior as compared to micro=
SD cards when it comes to building software?</div><div><br></div><div></div=
><div>Thanks and best regards,</div><div>Archimedes<br></div></div></div>

--000000000000c615c905ec4ba1e6--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJFbk7FfYPSe3eF00HgDdebW70HKp5zKR0JaChTVniUDPG2qxQ>