2

I have a server rocking FreeBSD 13.

From the documentation of sysctl I can read that hw.pagesize cannot be changes on the go. This makes sense to me as this type of parameter depends on the kernel.

I can read also there this:

Some of the variables which cannot  be modified during normal system oper-
ation can be initialized via loader(8) tunables.  This can  for example be
done by setting them in loader.conf(5).  Please refer to loader.conf(5)
for more information on which tunables are  available and how to set them.

Sadly I cannot find in the documentation of loader(8) nor loader.conf(5) any reference to this I need.

In a naive attempt, I just added the hw.pagesize=... to my /etc/sysctl config file, without any success. Now, when I run pagesize I get my sad 4096 bytes value:

jose@miner:~ $ pagesize
4096

But, how can I make it larger? I would like to use 1GB pages in a system, yet I cannot find anywhere how to enable so.

Navarro
  • 470
  • 1
  • 5
  • 13
  • Do you actually need to change a setting? AFAICT FreeBSD automatically uses huge pages in some circumstances. I doubt that there's an option to systematically use 1GB pages: you wouldn't even be able to boot unless you had an immense amount of RAM. – Gilles 'SO- stop being evil' Jun 11 '21 at 12:42
  • I am running a process that _does_ benefit from the 1GB pages. When I am running that process it cannot detect the large pages being enabled. I am unaware if they are dynamically used as the process munches memory. In any case invoking `pagesize` does not return a value higher than 4MB. – Navarro Jun 11 '21 at 15:06
  • 1
    You can check that with `vm.pmap.pg_ps_enabled`. In FreeBSD it is called `superpages`. See [Usenix 2020 paper](https://www.usenix.org/system/files/atc20-zhu-weixi_0.pdf) and references in a previous (unwanted) [answer](https://unix.stackexchange.com/a/500372/74393) – Claus Andersen Jun 11 '21 at 15:11
  • Thank you for sharing this paper! – Navarro Jun 11 '21 at 15:27

2 Answers2

1

FreeBSD has fairly well documented man pages. I am surprised with your link to sysctl that you cannot find the remaining info. Read aboud them using

 man man
 

This will show the different sections:

  The sections of the manual are:
       1.   FreeBSD General Commands Manual
       2.   FreeBSD System Calls Manual
       3.   FreeBSD Library Functions Manual
       4.   FreeBSD Kernel Interfaces Manual
       5.   FreeBSD File Formats Manual
       6.   FreeBSD Games Manual
       7.   FreeBSD Miscellaneous Information Manual
       8.   FreeBSD System Manager's Manual
       9.   FreeBSD Kernel Developer's Manual

In you case you can find the proper pages without specifying the sections.

man loader.conf
man loader

But you can specify the sections:

man 8 loader
man 5 loader.conf

And you can find them online as well: loader(8) loader.conf(5)

You are close to your solution. The file you are looking for is:

/boot/loader.conf

If it does not exists simply create it. This is read during bootstrapping. You have already got the syntax right.

If this is new to you then beware of this important notice:

 BUGS
     The loader(8) stops reading loader.conf when it encounters a syntax er-
     ror, so any options which are vital for booting a particular system
     (i.e., "hw.ata.ata_dma=0") should precede any experimental additions to
     loader.conf.
     

If you make really bad edits to /boot/loader.conf you risk that you system cannot boot. If this happens then you need to boot into "Single User Mode". When booting press a key to get to the boot prompt. At the boot: prompt enter boot -s. You can then mount your filesystem with /sbin/mount -ruw / and edit your config (vi is your friend!).

Claus Andersen
  • 3,239
  • 1
  • 12
  • 24
  • Sadly, the `loader.conf` does not work either. I will give a read to the whole documentation and try to find why that value is not honoured. – Navarro Jun 11 '21 at 15:03
  • I'm a bit sad that this post is just an elaborate version of mine, but mine is getting downvoted. – arrowd Jun 17 '21 at 18:55
  • I respectfully disagree but do not wish to take this discussion any further. I did however not downvote your answer. – Claus Andersen Jun 18 '21 at 19:51
-2

man loader.conf has the following sentence almost at the beginning:

 All settings have the following format:

       variable="value"

And there is no /etc/sysctl file, it is called /etc/sysctl.conf.

arrowd
  • 847
  • 6
  • 12