EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login

Linux HugePages

By Alokananda GhoshalAlokananda Ghoshal

Home » Software Development » Software Development Tutorials » Linux Tutorial » Linux HugePages

Linux HugePages

Definition of Linux HugePages

In this article, we are going to talk and learn about a management system in Linux which mainly drives the memory management. Through this article we will talk about ways of enabling or disabling Hugepages in Linux, how can one determine value of a hugepage and many other intricate information. So, formally defining hugepage, it is a utility that drives virtual memory management in the Linux system. And as the name itself suggests, “huge” sized pages which are in addition to the standard 4KB page size can be managed using the concept. One can easily handle pages as huge as 1GB. Now, one must be wondering that which are those pages that require such high size and to answer that we have an example just for you! Think about using a database with high requirement of memory.

Syntax of Linux HugePages

There is no particular fixed syntax for hugepages. But according to the usability of the user, there are a bunch of them which we would discuss in this section. The first one refers to the usability of checking the current huge page details. The syntax for the same is:

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

grep Huge /proc/meminfo

Once the user has checked for details, one would need to know the number of huge pages the system would require currently. There is a script, also present in Oracle which we would describe in the example section. Now, once the user has checked for the details, it entails them to configure in case it is required. That can be done in /etc/sysctl.conf and once the variable is changed there, the following syntax can be used for reloading the configuration:

sysctl -p

Apart from syntaxes, one must also be wary about the configuration, when changed. For example, in case the number of hugepages is changed then the corresponding locked memory needs to be changed as well. Also, once the changes to the configuration is done, it is very important to restart the application so as to make the effects to the configuration take place.

How does HugePages Work in Linux?

Now, it is time for our understanding of the working of hugepages in Linux. In modern day architecture, multiple page size support is provided, for example, x86 CPUs have capability of supporting 4K and 2M page sizes (if architectural support is present, 1G of page size is also supported) and ia64 supports 4K, 8K, 64K, 256K and so on. There are many such examples. Hugepages have something known as translation lookaside buffer (abbreviated as TLB) which facilitates caching of virtual to physical translations. With bigger and bigger physical memory now getting available, the optimization of the scarce TLB resource in supporting hugepages are getting more and more critical.

Now that we have a fair idea of the importance, it is very important to know some common parameters, so as to make the flow of information in subsequent paragraph seamless. HugePages_Total is one such parameter which mentions the size of the pool of huge pages. HugePages_Free denotes the number of the hugepages from the pool which is not allocated yet. HugePages_Rsvd denotes the reserved number of huge pages, but these pages are not yet allocated and just “reserved”. HugePages_Surp is the “surplus” pages which is a number above and beyond the current hugepages the system needs currently.

Popular Course in this category
Kali Linux Training (3 Courses, 3+ Projects)3 Online Courses | 3 Hands-on Projects | 21+ Hours | Verifiable Certificate of Completion | Lifetime Access
4.5 (5,494 ratings)
Course Price

View Course

Related Courses
Linux Training Program (16 Courses, 3+ Projects)Red Hat Linux Training Program (4 Courses, 1+ Projects)

Now the reserved hugepages return to the pool of hugepages when freed up by a task and also reserved hugepages memory inside kernel can’t be used for any other purposes along with incapability of swapping out under memory pressure. Now the pre-allocation of the hugepages is done to the kernel and once the allocation is complete a user with privilege as appropriate can use either map system call or calls from a shared memory system for using huge pages. Persistent hugepages can be allocated on the kernel boot line command by administrator when one changes the nr_hugepages parameter. This allocation can be freeing up hugepages as well, if required.

Now, once the pre-allocation is done, the kernel will attempt distribution of the hugepage pool over the set of allowed nodes. These nodes are specified by the NUMA memory policy. Any allowed node with insufficient continuous memory will be silently skipped when persistent hugepages are allocated. In case of unavailable continuous memory while the allocation of the huge pages may result into success or failure of huge page allocation. Hence in the following way, the allocation or freeing up of space is done in Linux hugepages.

One important thing to be kept as a warning or a pinch of note is in case the administrator shrink the hugepages via nr_hugepages to a number which is less than the number of huge pages in currently in use will convert the balance of the in-use huge pages to surplus hugepages till a point where it equals to the sum of nr_hugepages and overcommit hugepages. Once it crosses that, no more surplus hugepages will be allocated.

Examples of Linux HugePages

In this section, we will go through all the options we have talked about earlier through a particular example.

Example #1

Code:

grep Huge /proc/meminfo

Output:

Linux HugePages-1.1

Explanation: Using the grep command, we get all the details corresponding to hugepages, where all the properties like, total hugepages, free hugepages, etc. are zero, and incase a hugepage is allocated some size, it will have 2048 kB by default.

Example #2

Code:

Enter the command:

vi /etc/sysctl.conf

Inside the conf file:

vm.nr_hugepages=128

Close the earlier file and then enter the command:

vi /etc/security/limits.conf

Inside the conf file:

soft memlock 262144
hard memlock 262144

Once all changes are done then run the command:

sysctl -p

Output:

Sysctl.conf file:

Linux HugePages-1.2

Limits.conf file:

Linux HugePages-1.3

Explanation: This is to increase the hugepages from any number to our required number 128. Now, as we discussed earlier, the memory limit should also be increased or decreased as deemed fit in the limits.conf file.

Conclusion

In this article, we have discussed the usage of hugepages in today’s architecture and how it is becoming increasingly important to have a confident knowledge about these so as to explore the power of hugepages in one’s everyday work. With ever increasing database size having knowledge about the hugepages is a boon in disguise.

Recommended Articles

This is a guide to Linux HugePages. Here we discuss the definition and how does hugepages work in linux? along with different examples and its code implementation. You may also have a look at the following articles to learn more –

  1. Create Folder in Linux
  2. Linux Container
  3. Linux Find File by Name
  4. Linux List Groups

All in One Software Development Bundle (600+ Courses, 50+ projects)

600+ Online Courses

50+ projects

3000+ Hours

Verifiable Certificates

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
Linux Tutorial
  • Advanced
    • Install VMware
    • Install GRUB
    • Chown Command in Linux
    • Linux Network Command
    • Configuring Linux Network Environment
    • DNS Configuration in Linux
    • Linux Users
    • Create User in Linux
    • DHCP Server in Linux
    • FTP Server in Linux
    • Linux Regular Expression
    • IP Command in Linux
    • Set IP Address in Linux
    • Tar Command in Linux
    • Dynamic Host Configuration Protocol
    • Linux Kill Signals
    • Linux File Permissions
    • Linux File System
    • Linux Create File
    • Linux Concatenate Files
    • Linux Join
    • Linux Process Management
    • Linux Proxy Server
    • Linux System Commands
    • Linux System Logging
    • NFS in Linux
    • Linux LVM
    • Linux Repository
    • Samba Server in Linux
    • Top Commands in Linux
    • Types of Shells in Linux
    • Shell Script Types For Linux
    • GCC Command in Linux
    • Monolithic Kernel
    • YARN Package Manager
    • Linux Sed Replace
    • Linux List Groups
    • Linux Container
    • Linux Find File by Name
    • Create Folder in Linux
    • Linux Move Folder
    • Linux Error Codes
    • Linux Automount
    • Linux HugePages
  • Basic
    • Introduction to Linux
    • What is Linux
    • Careers in Linux
    • How to Install Linux
    • How to Install Ubuntu
    • How to Install Ubuntu Server
    • How To Install Debian
    • Advantage Of Linux
    • What is Raid in Linux
    • What is Raid 5?
    • Raid 5 vs Raid 6
    • Careers in Linux Administration
    • What is Shell in Linux?
    • Bash Shell in Linux
    • Linux Emulator
    • Linux Operators
    • Linux Apps
    • Linux Keyboard Shortcuts
    • Linux Crontab
    • What is Raid Storage
    • What is Vmware
    • What is RedHat
    • What is Debian
    • Uses of Ubuntu
    • Career In RedHat
    • Linux Distributions
    • Linux From Scratch
    • Linux Format
    • Cheat Sheet Linux
  • Linux Commands
    • CAT Command in Linux
    • PS command in Linux
    • Mkdir Command in Linux
    • rmdir command in Linux
    • mv command in Linux
    • Linux rm Command
    • CHMOD Command in Linux
    • Zip Command in Linux
    • Linux Route Command
    • SCP Command in Linux
    • du Command in Linux
    • Less Command in Linux
    • Copy Command in Linux
    • Head Command in Linux
    • Help Command in Linux
    • Linux History Command
    • hostname Command in Linux
    • GREP Command in Linux
    • Linux Curl Command
    • Linux List Users
    • Linux List Directories
    • Linux Directory Permissions
    • Find Directory Linux
    • Linux User Permission
    • Linux Add User
    • Linux Delete User
    • Linux uniq
    • Linux Filter Commands
    • Linux sort Command
    • Linux Sort by Size
    • Remove dir Linux
    • Linux tr Command
    • Linux Touch Command
    • Linux More Command
    • Linux Cal Command
    • Linux OD
    • Linux Zcat
    • Linux tracepath
    • Linux Sleep
    • Linux bg Command
    • Linux WC
    • Linux Read
    • Linux Write
    • Linux Rename Command
    • Linux Free Command
    • Linux tac
    • Linux Shred
    • Linux wget
    • Linux Date
    • Linux Untar
    • Linux JQ
    • Linux Xargs
    • Linux Mount Command
    • Linux mdadm
    • Linux comm
    • Linux tee Command
    • Tail Command in Linux
    • Linux gzip
    • Linux Directory Structure
    • Linux Alias Command
    • Linux Inode
    • Linux Ping
    • Linux Watch Command
    • Linux Split Command
    • Linux Size
    • Linux Network Stack
    • Linux Diff Command
    • Vim Command in Linux
    • Linux nslookup
  • Kali Linux
    • Install Kali Linux
    • Kali Linux Uses
    • Kali Linux Commands
    • Kali Linux Repository
    • Kali Linux Packages
    • Kali Linux root password
    • Kali Linux Alternative
  • Interview Questions
    • Linux Interview Questions
    • Linux System Administration Interview
    • Red Hat Interview Questions

Related Courses

Kali Linux Training

Linux Training Course

Red Hat Training Course

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA Login

Forgot Password?

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - Kali Linux Training Learn More