// SPDX-License-Identifier: GPL-2.0 /* * hugepage-shm: * * Example of using huge page memory in a user application using Sys V shared * memory system calls. In this example the app is requesting 256MB of * memory that is backed by huge pages. The application uses the flag * SHM_HUGETLB in the shmget system call to inform the kernel that it is * requesting huge pages. * * Note: The default shared memory limit is quite low on many kernels, * you may need to increase it via: * * echo 268435456 > /proc/sys/kernel/shmmax * * This will increase the maximum size per shared memory segment to 256MB. * The other limit that you will hit eventually is shmall which is the * total amount of shared memory in pages. To set it to 16GB on a system * with a 4kB pagesize do: * * echo 4194304 > /proc/sys/kernel/shmall
*/
dprintf("Starting the writes:\n"); for (i = 0; i < LENGTH; i++) {
shmaddr[i] = (char)(i); if (!(i % (1024 * 1024)))
dprintf(".");
}
dprintf("\n");
dprintf("Starting the Check..."); for (i = 0; i < LENGTH; i++) if (shmaddr[i] != (char)i) {
printf("\nIndex %lu mismatched\n", i); exit(3);
}
dprintf("Done.\n");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.