linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* how to reserve memory in linux?
@ 2006-10-20 14:27 Ming Liu
  2006-10-21  5:15 ` a sudheer
  0 siblings, 1 reply; 9+ messages in thread
From: Ming Liu @ 2006-10-20 14:27 UTC (permalink / raw)
  To: linuxppc-embedded

Dear all,
My situation is, I want to reserve some amount of memory and make it shared 
by both Linux kernel and another hardware peripheral. That is, when I boot 
linux and execute some user space programs, this part of memory should be 
reserved for other use and cannot be used by both the kernel and those 
applications. But it could be accessed by Linux with some certain kind of 
application and also be accessed by another hardware peripheral with DMA or 
something like that. 

I am not sure if I am right but I think it's just like the situation of 
multiprocessing (if we can treat that hardware peripheral as another 
processor, or just use another processor to realize its functions.) and 
that part of memory is just like the hardware shared memory by 
multiprocessor. Am I right? 

Then my question is, how to reserve such part of memory in Linux? Does 
Linux has such a function? 

I am not falimiar with such a topic, so any hint related to this is 
appreciated.

Thanks for your ideals and suggestions.

Regards
Ming

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to reserve memory in linux?
  2006-10-20 14:27 how to reserve memory in linux? Ming Liu
@ 2006-10-21  5:15 ` a sudheer
  2006-10-21 14:22   ` Ming Liu
  0 siblings, 1 reply; 9+ messages in thread
From: a sudheer @ 2006-10-21  5:15 UTC (permalink / raw)
  To: Ming Liu; +Cc: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 1819 bytes --]

Hello Ming Lu

On 10/20/06, Ming Liu <eemingliu@hotmail.com> wrote:
>
> Dear all,
> My situation is, I want to reserve some amount of memory and make it
> shared
> by both Linux kernel and another hardware peripheral. That is, when I boot
> linux and execute some user space programs, this part of memory should be
> reserved for other use and cannot be used by both the kernel and those
> applications.


Considering your setup as normal desktop, I hope this can be done by giving
"mem= xxm"  as the boot arguments.  Say the dmesg in your system shows   "
495MB LOWMEM available."  .  In the boot arguments you can give mem=490m
saying the linux to use only 490MB . The rest 5MB can be used later as you
wish.

Please correct if i am wrong.

Thanks
Sudheer



But it could be accessed by Linux with some certain kind of
> application and also be accessed by another hardware peripheral with DMA
> or
> something like that.
>
> I am not sure if I am right but I think it's just like the situation of
> multiprocessing (if we can treat that hardware peripheral as another
> processor, or just use another processor to realize its functions.) and
> that part of memory is just like the hardware shared memory by
> multiprocessor. Am I right?
>
> Then my question is, how to reserve such part of memory in Linux? Does
> Linux has such a function?
>
> I am not falimiar with such a topic, so any hint related to this is
> appreciated.
>
> Thanks for your ideals and suggestions.
>
> Regards
> Ming
>
> _________________________________________________________________
> 与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn
>
>
>
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>
>

[-- Attachment #2: Type: text/html, Size: 2554 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to reserve memory in linux?
  2006-10-21  5:15 ` a sudheer
@ 2006-10-21 14:22   ` Ming Liu
  2006-10-21 17:48     ` Eric Nuckols
                       ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ming Liu @ 2006-10-21 14:22 UTC (permalink / raw)
  To: urwithsudheer; +Cc: linuxppc-embedded

Dear sudheer,
About the "mem=xx" argument, I checked it from the website and got such a 
explanation:

This argument has several purposes: The original purpose was to specify the 
amount of installed memory (or a value less than that if you wanted to 
limit the amount of memory available to linux).

>From the argument above, it says "mem=xx" is to specify the amount of 
memory available to Linux. I am not sure if I am right, but I think if I 
use such an argument, that reserved part (that 5MB you mentioned), is not 
available any more for Linux to access it. 

My original meaning is: specify a fixed physical address for a mount of 
memory for reserved use. The point is to make this part of memory fixed in 
the memory of physical address, and then another I/O peripheral could use 
DMA to access such a fixed physical address memory. However if I don't 
reserve such a part, I must let Linux to allocate such a memory part. And 
then Linux will not put it in a fixed physical address and then the 
peripheral will not know where is this part.

Am I right? Thanks for your idea.

Also other ideas are appreciated.

Regards
Ming

>Considering your setup as normal desktop, I hope this can be done by 
>giving
>"mem= xxm"  as the boot arguments.  Say the dmesg in your system 
>shows   "
>495MB LOWMEM available."  .  In the boot arguments you can give 
>mem=490m
>saying the linux to use only 490MB . The rest 5MB can be used later 
>as you
>wish.

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com  

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to reserve memory in linux?
  2006-10-21 14:22   ` Ming Liu
@ 2006-10-21 17:48     ` Eric Nuckols
  2006-10-22 11:21       ` Ming Liu
  2006-10-22  0:36     ` Michael Richardson
  2006-10-22  6:48     ` Rahul
  2 siblings, 1 reply; 9+ messages in thread
From: Eric Nuckols @ 2006-10-21 17:48 UTC (permalink / raw)
  To: eemingliu, urwithsudheer; +Cc: linuxppc-embedded

Have you tried the function

alloc_bootmem_low() early in the boot process in main.c ?



----Original Message Follows----
From: "Ming Liu" <eemingliu@hotmail.com>
To: urwithsudheer@gmail.com
CC: linuxppc-embedded@ozlabs.org
Subject: Re: how to reserve memory in linux?
Date: Sat, 21 Oct 2006 14:22:25 +0000

Dear sudheer,
About the "mem=xx" argument, I checked it from the website and got such a 
explanation:

This argument has several purposes: The original purpose was to specify the 
amount of installed memory (or a value less than that if you wanted to limit 
the amount of memory available to linux).

>From the argument above, it says "mem=xx" is to specify the amount of memory 
available to Linux. I am not sure if I am right, but I think if I use such 
an argument, that reserved part (that 5MB you mentioned), is not available 
any more for Linux to access it.

My original meaning is: specify a fixed physical address for a mount of 
memory for reserved use. The point is to make this part of memory fixed in 
the memory of physical address, and then another I/O peripheral could use 
DMA to access such a fixed physical address memory. However if I don't 
reserve such a part, I must let Linux to allocate such a memory part. And 
then Linux will not put it in a fixed physical address and then the 
peripheral will not know where is this part.

Am I right? Thanks for your idea.

Also other ideas are appreciated.

Regards
Ming

>Considering your setup as normal desktop, I hope this can be done by giving
>"mem= xxm"  as the boot arguments.  Say the dmesg in your system shows   "
>495MB LOWMEM available."  .  In the boot arguments you can give mem=490m
>saying the linux to use only 490MB . The rest 5MB can be used later as you
>wish.

_________________________________________________________________
ÏíÓÃÊÀ½çÉÏ×î´óµÄµç×ÓÓʼþϵͳ¡ª MSN Hotmail¡£  http://www.hotmail.com



_______________________________________________
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded

_________________________________________________________________
Get FREE company branded e-mail accounts and business Web site from 
Microsoft Office Live 
http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to reserve memory in linux?
  2006-10-21 14:22   ` Ming Liu
  2006-10-21 17:48     ` Eric Nuckols
@ 2006-10-22  0:36     ` Michael Richardson
  2006-10-22  6:48     ` Rahul
  2 siblings, 0 replies; 9+ messages in thread
From: Michael Richardson @ 2006-10-22  0:36 UTC (permalink / raw)
  To: linuxppc-embedded

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On x86, many BIOSs reported the wrong amount of memory.
Either they screwed up and reported too much (which means the system
would crash if it tried to use), or failed to report more than 64MB
of ram through that interface.

(Which was the physical limit on one generation of systems due to number
of pins that came out of processors/support chips/etc.) 

The point of mem= is to let you override it.
It only became useful later on to people who wanted contiguous DMA
regions.  Frankly: it's a terrible hack.  

On any reasonable embedded system you should get yourself sufficiently
involved in the linux memory management, and do it early enough
(i.e. not as a module. Why would you need modules on a single-purpose
embedded system, except because you want to play non-GPL games).

The question about whether or not the MMU is setup is nonsense --- you
don't understand the system properly. mem= is telling the system how
much PHYSICAL memory there is, not how much virtual address space setup.

On some architectures, the kernel gets a 1:1 mapping of all virtual to
physical, on others, you don't.  You can trivially add new mappings to
head.S, if you need them very early on, or you can map the physical
spaces afterward if you can deal later on.

- -- 
]            Bear: "Me, I'm just the shape of a bear."          |  firewalls  [
]   Michael Richardson,    Xelerance Corporation, Ottawa, ON    |net architect[
] mcr@xelerance.com      http://www.sandelman.ottawa.on.ca/mcr/ |device driver[
] panic("Just another Debian GNU/Linux using, kernel hacking, security guy"); [





-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Finger me for keys

iQEVAwUBRTq834CLcPvd0N1lAQJdpQgAo0+sYTTi/FBgyFA3Lyn6HTNZ6xHQ0BMf
40h1B2qXvB0cWeGaHndfXFe04r3w0w/z0RKsjE5ultVxGO/WNBb8gCYDbmA/M4y0
DuTjMh+unn63o7iVwtJbPeSWA8T5KK8RW1y0NNRnwVzMkjzxo2IZbGblwreSXJWg
MF1Hsh79MTfIlpel7BkxFmcBWTUj16W0XQljmyBW6F5zK7DZ5di2WYbWKM+khzVs
ydlems1Nns8Qk8bI8s0Jq8NBx+J1VSV95qRvCtLIAfVyiO9lRZgeozvsB3Ri0cbA
C4usgAL4yUgUPG3DeN9PfL+uVELzWo1CyB7JOiyYDGYDKswau8vmoA==
=4THO
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to reserve memory in linux?
  2006-10-21 14:22   ` Ming Liu
  2006-10-21 17:48     ` Eric Nuckols
  2006-10-22  0:36     ` Michael Richardson
@ 2006-10-22  6:48     ` Rahul
  2006-10-22 11:40       ` Ming Liu
  2 siblings, 1 reply; 9+ messages in thread
From: Rahul @ 2006-10-22  6:48 UTC (permalink / raw)
  To: Ming Liu; +Cc: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 2180 bytes --]

On 10/21/06, Ming Liu <eemingliu@hotmail.com> wrote:
>
> Dear sudheer,
> About the "mem=xx" argument, I checked it from the website and got such a
> explanation:
>
> This argument has several purposes: The original purpose was to specify
> the
> amount of installed memory (or a value less than that if you wanted to
> limit the amount of memory available to linux).
>
> From the argument above, it says "mem=xx" is to specify the amount of
> memory available to Linux. I am not sure if I am right, but I think if I
> use such an argument, that reserved part (that 5MB you mentioned), is not
> available any more for Linux to access it.
>
> My original meaning is: specify a fixed physical address for a mount of
> memory for reserved use. The point is to make this part of memory fixed in
> the memory of physical address, and then another I/O peripheral could use
> DMA to access such a fixed physical address memory. However if I don't
> reserve such a part, I must let Linux to allocate such a memory part. And
> then Linux will not put it in a fixed physical address


yes

and then the
> peripheral will not know where is this part.


why do you think so ?
Can't you give the physical address of the allocated memory from linux
kernel to peripheral's DMA.?
Unless you need to hardcode the physicall address i hope
virt_to_phys(kmalloc_address) can be given to DMA.
Sorry if i am still wrong in understanding your requirement.


Am I right? Thanks for your idea.
>
> Also other ideas are appreciated.
>
> Regards
> Ming
>
> >Considering your setup as normal desktop, I hope this can be done by
> >giving
> >"mem= xxm"  as the boot arguments.  Say the dmesg in your system
> >shows   "
> >495MB LOWMEM available."  .  In the boot arguments you can give
> >mem=490m
> >saying the linux to use only 490MB . The rest 5MB can be used later
> >as you
> >wish.
>
> _________________________________________________________________
> 享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com
>
>
>
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>
>

[-- Attachment #2: Type: text/html, Size: 3146 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to reserve memory in linux?
  2006-10-21 17:48     ` Eric Nuckols
@ 2006-10-22 11:21       ` Ming Liu
  2006-10-23  0:20         ` Eric Nuckols
  0 siblings, 1 reply; 9+ messages in thread
From: Ming Liu @ 2006-10-22 11:21 UTC (permalink / raw)
  To: jrocnuck; +Cc: linuxppc-embedded

Dear Eric,

>Have you tried the function
>
>alloc_bootmem_low() early in the boot process in main.c ?
>
Yes, it sounds reasonable. With this function, I can reserve a large amount 
of buffer during booting time. But I think maybe it will be better to put 
this function in the device driver and when booting time, the driver is 
loaded and the memory part is reserved for later use, right?

Thanks for your idea so much. It's really helpful.

Regards
Ming

_________________________________________________________________
免费下载 MSN Explorer:   http://explorer.msn.com/lccn  

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to reserve memory in linux?
  2006-10-22  6:48     ` Rahul
@ 2006-10-22 11:40       ` Ming Liu
  0 siblings, 0 replies; 9+ messages in thread
From: Ming Liu @ 2006-10-22 11:40 UTC (permalink / raw)
  To: rahul.theraja; +Cc: linuxppc-embedded

Dear Rahul,

>why do you think so ?
>Can't you give the physical address of the allocated memory from 
>linux
>kernel to peripheral's DMA.?
>Unless you need to hardcode the physicall address i hope
>virt_to_phys(kmalloc_address) can be given to DMA.
>Sorry if i am still wrong in understanding your requirement.
>

In fact, I have considered this method before. Just to dynamically allocate 
such a memory buffer and then tell the peripheral its physical address for 
accessing. However, because I really know little about the memory 
management in Linux, so I am not sure if the following question could be 
guaranteed:
Q. When I dynamically allocate a large amount of memory, I am not sure if I 
can allocate a physically continous large amount of memory. For the 
peripheral, it hopes the continous physical address, unless it has 
scatter-gather function. 

I think I must dig deeply into LDD memory management chapter to find the 
answer. :)

Of course, I appreciate your idea and suggestion. This is really a 
candidate method to solve my problem.

Thanks a lot.
Regards
Ming

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to reserve memory in linux?
  2006-10-22 11:21       ` Ming Liu
@ 2006-10-23  0:20         ` Eric Nuckols
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Nuckols @ 2006-10-23  0:20 UTC (permalink / raw)
  To: eemingliu; +Cc: linuxppc-embedded

>Dear Eric,

>>Have you tried the function
>>
>>alloc_bootmem_low() early in the boot process in main.c ?
>>
>Yes, it sounds reasonable. With this function, I can reserve a large amount 
>of buffer during >booting time. But I think maybe it will be better to put 
>this function in the device driver and when >booting time, the driver is 
>loaded and the memory part is reserved for later use, right?

Actually, you can only do this at boot time before any of the standard 
memory setup routines run.
Consult the linux device drivers book and also do some internet research on 
the subject to get the "official" documentation of this functionality.  I'd 
rather you get the information from these sources than from me, since there 
is plenty of room for error when using these functions.

Here's a link I found to the book: (the 2nd Edition)
http://www.xml.com/ldd/chapter/book/ch07.html



>Thanks for your idea so much. It's really helpful.

>Regards
>Ming

_________________________________________________________________
Ãâ·ÑÏÂÔØ MSN Explorer:   http://explorer.msn.com/lccn

_________________________________________________________________
All-in-one security and maintenance for your PC.  Get a free 90-day trial! 
http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http://www.windowsonecare.com/?sc_cid=msn_hotmail

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-10-23  0:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-20 14:27 how to reserve memory in linux? Ming Liu
2006-10-21  5:15 ` a sudheer
2006-10-21 14:22   ` Ming Liu
2006-10-21 17:48     ` Eric Nuckols
2006-10-22 11:21       ` Ming Liu
2006-10-23  0:20         ` Eric Nuckols
2006-10-22  0:36     ` Michael Richardson
2006-10-22  6:48     ` Rahul
2006-10-22 11:40       ` Ming Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).