HugePages

Post Reply
Arm420
Posts: 2
Joined: Thu Jan 03, 2019 10:38 am
languages_spoken: english
ODROIDs: xu4's
Has thanked: 4 times
Been thanked: 1 time
Contact:

HugePages

Post by Arm420 »

Greetings,
I got a little problem and I am graciously asking for some help.

After searching, i came to the realization that for some brilliant reason, a very (in-demand, popular setting) Hugepages: can not be enabled on any HK release of Ubuntu. The program I am working with requires Hugepages to operate with a recommended value of 1028pages.
I have read and followed the official Ubuntu guides the best I can and still = Zip, Zero. I googled this, found more tutorials = i had no luck.

Can anyone explain this, keeping in mind (im not a non-linux developer) but more like b]eli5[/b] ,, How would You go about getting a C4 release of (Ubuntu minimal, Ubuntu desktop, or any other Debian based linux) to be capable of allowing one to: 1)Activate and 2) Define number/size of a huge pages statement in any of the flavors that can be used to make this happen on C4?

ps....Ive got Hugepages running on all my microsoft boxes and it was painless and required no special steps, so their has to be a way to get this done on Linux :o

Thank You all in advance.
-Arm420

brad
Posts: 1351
Joined: Tue Mar 29, 2016 1:22 pm
languages_spoken: english
ODROIDs: C2 N1 N2 N2+ H2 H2+ (64 bit ftw)
Location: Australia
Has thanked: 113 times
Been thanked: 167 times
Contact:

Re: HugePages

Post by brad »

If I recall correctly it was related to the amlogic kernel using smaller pages sizes and a strange config to support the 32 bit drivers for some of their conponents.

I suggest you try a distribution using mainline kernel (mainline is not officially supported by hard kernel but depending on your use case can be very stable). Eg viewtopic.php?f=202&t=38557

Quick check shows it working fine (1028 pages x 2048kb page size is approx 2Gb so make sure you have the 4Gb model or will be nothing left for the system):

Code: Select all

brad@urbackup:~$ uname -a
Linux urbackup 5.9.0-odroid-arm64 #1 SMP PREEMPT Ubuntu 5.9.8-202011142254~focal (2020-11-14) aarch64 aarch64 aarch64 GNU/Linux
brad@urbackup:~$ grep huge /etc/sysctl.conf 
vm.nr_hugepages=1028
brad@urbackup:~$ grep Huge /proc/meminfo
AnonHugePages:     22528 kB
ShmemHugePages:        0 kB
FileHugePages:         0 kB
HugePages_Total:    1028
HugePages_Free:     1028
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
Hugetlb:         2105344 kB
These users thanked the author brad for the post:
tobetter (Mon Nov 23, 2020 2:05 am)

hominoid
Posts: 483
Joined: Tue Feb 28, 2017 3:55 am
languages_spoken: english
ODROIDs: C2, C4, XU4, MC1, N1, N2, N2+, HC4
Location: Lake Superior Basin, USA
Has thanked: 47 times
Been thanked: 159 times
Contact:

Re: HugePages

Post by hominoid »

@arm420, Huge Pages work on any of the HK images but they aren't fully enabled by default in the kernel.

Code: Select all

hominoid@odroid-c4:~/linux$ uname -a
Linux odroid-c4 4.9.236-51 #1 SMP PREEMPT Tue Nov 10 12:53:39 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

hominoid@odroid-c4:~/linux$ cat .config | grep HUGE

CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y
CONFIG_HAVE_ARCH_HUGE_VMAP=y
CONFIG_SYS_SUPPORTS_HUGETLBFS=y
CONFIG_ARCH_WANT_HUGE_PMD_SHARE=y
# CONFIG_TRANSPARENT_HUGEPAGE is not set
# CONFIG_HUGETLBFS is not set
# CONFIG_HUGETLB_PAGE is not set
There is a quick guide to huge pages, both Transparent and Pre-allocated and how to get them working so I'm not going to repeat it here. It is specifically for the N2/N2+ but every thing is the same for the C4/HC4 except 3 commands regarding the kernel compile. The git repository location, defconfig file and the dtb you will copy over. Use the wiki guide for more info on native and cross compile of the C4 kernel.

Code: Select all

git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidg12-4.9.y
cd linux
make odroidc4_defconfig
...
sudo cp -f arch/arm64/boot/Image.gz arch/arm64/boot/dts/amlogic/meson64_odroidc4.dtb /media/boot/
After the kernel compile you can verify their availability and configure pre-allocated huge pages as usual, if needed.

Code: Select all

hominoid@odroid-c4:~$ ls /sys/kernel/mm/
hugepages  transparent_hugepage
These users thanked the author hominoid for the post (total 2):
tobetter (Mon Nov 23, 2020 2:05 am) • brad (Mon Nov 23, 2020 6:55 am)

mdrjr
Site Admin
Posts: 11776
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Has thanked: 1 time
Been thanked: 34 times
Contact:

Re: HugePages

Post by mdrjr »

Hello Guys :)

Can you guys explain why/when hugepages would be required on a computer with so little amount of ram?
Are there any benefits I'm not seeing it?

arm64 supports 4k, 2M and 1G pages.
1G being pretty much useless I believe...

hominoid
Posts: 483
Joined: Tue Feb 28, 2017 3:55 am
languages_spoken: english
ODROIDs: C2, C4, XU4, MC1, N1, N2, N2+, HC4
Location: Lake Superior Basin, USA
Has thanked: 47 times
Been thanked: 159 times
Contact:

Re: HugePages

Post by hominoid »

There definitely are some specific applications that benefit from huge pages like databases, crypto apps and others. Testing needs to be conducted to verify if using huge pages yields a performance gain for any given application. It’s the only way to know for sure. Developers have to write their applications to take advantage of them as well.

I’m not so sure that it is so much about the amount of memory, but is about accessing more memory then the range that can be mapped by all of the small page entries in the translation lookaside buffer (TLB). The one clear advantage of using huge pages is to reduce page walk and the more page levels a MMU design has the more likely there may be a significant benefit from using huge pages. I think ARMv8 supports 4-level lookup so the worst case scenario is traversing all four levels.

Here is an example of an application using transparent huge pages with a 4k page size that realized a 15.9% increase in performance. In the post I first run it without huge pages and then with transparent huge pages. viewtopic.php?f=180&t=34150&start=24

brad
Posts: 1351
Joined: Tue Mar 29, 2016 1:22 pm
languages_spoken: english
ODROIDs: C2 N1 N2 N2+ H2 H2+ (64 bit ftw)
Location: Australia
Has thanked: 113 times
Been thanked: 167 times
Contact:

Re: HugePages

Post by brad »

mdrjr wrote:
Wed Nov 25, 2020 11:40 am
Hello Guys :)

Can you guys explain why/when hugepages would be required on a computer with so little amount of ram?
Are there any benefits I'm not seeing it?

arm64 supports 4k, 2M and 1G pages.
1G being pretty much useless I believe...
Yes basically what @hominoid said. Some applications require hugepages as they allocate (usually shared) memory areas in hugepages space. it allows an area of memory where the application can basically allocate RAM in whatever size it wants and manage itself. The area is a contiguous area of memory defined at boot time (if defined manually and not transparent). It means the app can manage it how it want's and is not limited by the linux kernel's virtual memory management in small chunks such as 4k which can create a large overhead in certain circumstances.

I don't use hugepages on odroid's but I do on larger x64 systems running Oracle databases with large memory requirements (64Gb up to 256Gb). I usually define the hugepages manually and configure the database to use it so I can have a predictable performance for shared memory access with 1000's of users. For smaller DB's it can be transparent but as it is dynamic performance is not as predicable depending on what else might be happening on the system at the time.

I too would be interested to know which application the OP is using on odroid using hugepages :)

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 1 guest