Kernel Newbies archive on lore.kernel.org
 help / color / Atom feed
From: "孙世龙 sunshilong" <sunshilong369@gmail.com>
To: Greg KH <greg@kroah.com>
Cc: Kernelnewbies@kernelnewbies.org
Subject: Re: Are there some potential problems that I should be aware of if I allocate the memory which doesn't have any relation to peripheral hardwares(i.e. DMA, PCI, serial port and etc) by vmalloc() instead of kmalloc()?
Date: Fri, 26 Jun 2020 23:36:05 +0800
Message-ID: <CAAvDm6aZc5js0NKJZPdcTjNkKgg+3QGXLPyYaVosjgdvJcZq5w@mail.gmail.com> (raw)
In-Reply-To: <20200626141319.GC4140284@kroah.com>

Thank you for your attention to this matter.

>Why are you having so many issues in allocating memory?
I often saw the page allocation failure recently. I must resolve this problem.
I have no choice other than disabling these options
(i.e. CONFIG-MIGRATION and CONFIG-COMPACTION)
since I am using a real-time OS.
It's easier to encounter such a problem since the said options are disabled.

>Does the kernel not provide enough different ways to do this for your
driver/device/use case?
The current code snippet is using kmalloc() and often encounter the
aforementioned problem.
So I want to use vmalloc() instead of kmalloc(). What do you think about it?
The memory to be allocated doesn't have any relation to any peripheral
hardware (i.e. DMA, PCI, serial port, etc) indeed. It's just used to
store a struct
array which indicates the usage of other resources.

Best regards.

Greg KH <greg@kroah.com> 于2020年6月26日周五 下午10:13写道:

>
> On Fri, Jun 26, 2020 at 04:30:48PM +0800, 孙世龙 sunshilong wrote:
> > Hi, list
> >
> > Besides kmalloc() is more efficient, are there some potential problems that
> > I should be aware of if I allocate the memory which doesn't have any
> > relation to peripheral hardwares(i.e. DMA,PCI,serial port and etc) by
> > vmalloc() instead of kmalloc() to avoid the page allocation failure(caused
> > by kmalloc() while there are too much memory fragment)?
>
> It all depends on what you want to do with that memory.
>
> Why are you having so many issues in allocating memory?  Does the kernel
> not provide enough different ways to do this for your driver/device/use
> case?
>
> If not, what are you trying to do that is not fitting with the existing
> interfaces?
>
> thanks,
>
> greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26  8:30 孙世龙 sunshilong
2020-06-26 14:13 ` Greg KH
2020-06-26 15:36   ` 孙世龙 sunshilong [this message]
2020-06-26 17:22     ` Valdis Klētnieks
2020-06-27  5:16       ` 孙世龙 sunshilong
2020-06-27  5:23         ` Greg KH
2020-06-27  6:00           ` 孙世龙 sunshilong
2020-06-27  7:05             ` Greg KH
2020-06-27  5:05     ` Greg KH

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=CAAvDm6aZc5js0NKJZPdcTjNkKgg+3QGXLPyYaVosjgdvJcZq5w@mail.gmail.com \
    --to=sunshilong369@gmail.com \
    --cc=Kernelnewbies@kernelnewbies.org \
    --cc=greg@kroah.com \
    /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

Kernel Newbies archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kernelnewbies/0 kernelnewbies/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kernelnewbies kernelnewbies/ https://lore.kernel.org/kernelnewbies \
		kernelnewbies@kernelnewbies.org
	public-inbox-index kernelnewbies

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernelnewbies.kernelnewbies


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git