From: Hsin-Hui Wu <hsinhuiwu@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: bugzilla-daemon@bugzilla.kernel.org, linux-mm@kvack.org
Subject: Re: [Bug 210023] New: Crash when allocating > 2 TB memory
Date: Wed, 4 Nov 2020 22:52:40 -0500 [thread overview]
Message-ID: <CANpob6LgoAw=k1wXwtWuu8eZDPt_EGi_Sz47p6Y77ifGFyjU+g@mail.gmail.com> (raw)
In-Reply-To: <20201104163822.95df9ee4e42ad5ec45852a19@linux-foundation.org>
[-- Attachment #1: Type: text/plain, Size: 1943 bytes --]
We don't use userspace program to allocate memory. We use kernel module to
do so.
Here is the sample kernel program you can use to test on a machine that has
more than 2 TB memory.
Use "insmod memtest.ko mb=2100000" to allocate more than 2 TB memory.
Use "rmmod memtest" to free the memory.
memtest.c
=============================================================
#include <linux/version.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
#ifdef MODVERSIONS
#include <linux/modversions.h>
#endif
#include <asm/io.h>
static char *mem_ptr;
MODULE_LICENSE("GPL");
int mb = 0;
MODULE_PARM_DESC(mb, "alloc MB memory");
module_param(mb, int, S_IWUSR | S_IRUGO);
static int __init memtest_init(void) {
mem_ptr = NULL;
if (mb > 0) {
unsigned long alloc_len;
alloc_len = mb * 1024 * 1024;
mem_ptr = vmalloc(alloc_len);
if (mem_ptr) {
printk("memtest: vmalloc for size %u MB.\n", mb);
} else {
printk("memtest: failed to vmalloc for bytes %u MB.\n", mb);
}
} else {
printk("memtest len_MB\n");
}
return(0);
}
static void __exit memtest_exit(void) {
if (mem_ptr) {
vfree(mem_ptr);
printk("memtest: vfree for size %u MB.\n", mb);
mem_ptr = NULL;
}
}
module_init(memtest_init);
module_exit(memtest_exit);
On Wed, Nov 4, 2020 at 7:38 PM Andrew Morton <akpm@linux-foundation.org>
wrote:
> On Wed, 4 Nov 2020 15:53:36 -0500 Hsin-Hui Wu <hsinhuiwu@gmail.com> wrote:
>
> > Did this require custom kernel changes? If not, precisely which system
> > calls were used to cause this allocation attempt?
> >
> > [Frank] No. vmalloc().
> >
>
> vmalloc() is not a system call.
>
> Please fully describe how vmalloc() came to be called with such a large
> request size. Fully. Are you able to provide example userspace code?
>
>
[-- Attachment #2: Type: text/html, Size: 2803 bytes --]
prev parent reply other threads:[~2020-11-05 3:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-210023-27@https.bugzilla.kernel.org/>
2020-11-04 0:27 ` Andrew Morton
2020-11-04 0:47 ` Matthew Wilcox
2020-11-04 13:55 ` Hsin-Hui Wu
2020-11-04 18:19 ` Andrew Morton
[not found] ` <CANpob6LY6oXqTG0GTJk-Z9qJtp9kpCCdoDAsbOJgTA8QfPCe2Q@mail.gmail.com>
[not found] ` <20201104163822.95df9ee4e42ad5ec45852a19@linux-foundation.org>
2020-11-05 3:52 ` Hsin-Hui Wu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANpob6LgoAw=k1wXwtWuu8eZDPt_EGi_Sz47p6Y77ifGFyjU+g@mail.gmail.com' \
--to=hsinhuiwu@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bugzilla-daemon@bugzilla.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox