<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Linux Kernel Newbies Forum - Memory Management</title>
        <description></description>
        <link>http://forum.kernelnewbies.org/list.php?13</link>
        <lastBuildDate>Fri, 10 Sep 2010 18:38:34 -0400</lastBuildDate>
        <generator>Phorum 5.2-dev</generator>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,2023,2023#msg-2023</guid>
            <title>redzoning (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,2023,2023#msg-2023</link>
            <description><![CDATA[ Hi,<br />
I am reading through linux 2.4.18 slab allocator source code. There, I frequently encounter the term &quot;redzoning&quot;. When I googled for the term, I found out that a lot of people discussed about it but nobody bothered to give an exact definition. Also, Bovet &amp; Cessati do not define the term. <br />
<br />
Do anybody knows what &quot;redzoning&quot; means?]]></description>
            <dc:creator>guest</dc:creator>
            <category>Memory Management</category>
            <pubDate>Sun, 29 Aug 2010 00:57:57 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1971,1971#msg-1971</guid>
            <title>min_free_kbytes: how does it work (no replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1971,1971#msg-1971</link>
            <description><![CDATA[ I came to know that min_free_kbytes can be used to<br />
ensure the availability of contiguous memory.<br />
I want to know how actually it works?<br />
Particularly why is this memory not fragmented?]]></description>
            <dc:creator>tenuppunet</dc:creator>
            <category>Memory Management</category>
            <pubDate>Thu, 19 Aug 2010 12:56:30 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1970,1970#msg-1970</guid>
            <title>allocating very big contiguous memory (no replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1970,1970#msg-1970</link>
            <description><![CDATA[ I need to allocate 30M of contiguous memory in my driver.<br />
I think kmalloc, get_free_pages and friends can allocate 4M at maximum.<br />
Is there any other API that can allocate more than this?]]></description>
            <dc:creator>tenuppunet</dc:creator>
            <category>Memory Management</category>
            <pubDate>Thu, 19 Aug 2010 12:53:27 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1755,1755#msg-1755</guid>
            <title>AdvancedPageReplacement (no replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1755,1755#msg-1755</link>
            <description><![CDATA[ Hello,<br />
<br />
I am Keval Vora, currently a student of B.Tech. in Computer Engineering at VJTI, Mumbai. I was exploring various research / projects (ongoing or new) in the Linux Kernel and I found &quot;AdvancedPageReplacement&quot; in LinuxMM.<br />
<br />
I have a few questions regarding this project. Can anyone please let me know whom to contact to work on this project? Can students join in and contribute to this project?<br />
<br />
We have a 1 year B.Tech. project in our institute. We are four of us together and we can dedicate the entire year in this project if possible.<br />
<br />
Thanks &amp; Regards,<br />
Keval Vora]]></description>
            <dc:creator>Keval Vora</dc:creator>
            <category>Memory Management</category>
            <pubDate>Wed, 21 Jul 2010 08:50:04 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1754,1754#msg-1754</guid>
            <title>memory mangment in liunx (no replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1754,1754#msg-1754</link>
            <description><![CDATA[ what type of memory mangment use in liunx , and what the diffrent type between liunx and windos for use memory mangment ???<br />
<br />
<br />
<br />
PLZ can you answer ??]]></description>
            <dc:creator>S.IDk</dc:creator>
            <category>Memory Management</category>
            <pubDate>Wed, 21 Jul 2010 04:59:02 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1729,1729#msg-1729</guid>
            <title>What controls page cache to ~ 90 % of total when writing files to hd? (no replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1729,1729#msg-1729</link>
            <description><![CDATA[ Hi, <br />
<br />
I have a situation where I'm constantly writing to the hard drive (and when necessary files are removed). The cache according to vmstat reaches about 90 % of the total amount of memory and then stays there. The thing is that I occasionally read from the disk, and then I need fast read access. I use the deadline scheduler, but I think the driver regards the parameters mostly as a joke or some kind of guideline. Anyways, when reading I would like to have memory left in order to let the writes stay in memory (and grow the cache) during the reads. Of course, this is not possible since the cache is already 90 %.<br />
<br />
I imagine that if I could understand what controls this &quot;cache ratio&quot; I could tune/hack it and maybe fix my problem. Since I'm writing continuously (24/7, really) I don't see the point of letting all data sit in memory for a while before getting written.<br />
<br />
The harddrive can cope with the I/O until I start to read too much too fast, then it breaks down until the read ends.<br />
<br />
<strong class="bbcode">Question in summary:</strong> Is there any way to let the kernel have a favorable size of the io cache but still allow it to grow during reads?<br />
<br />
/Z]]></description>
            <dc:creator>janzon</dc:creator>
            <category>Memory Management</category>
            <pubDate>Mon, 12 Jul 2010 12:33:23 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1698,1698#msg-1698</guid>
            <title>ioremap.c: BUG in __ioremap_caller() in arch/x86/mm/ioremap.c ? (no replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1698,1698#msg-1698</link>
            <description><![CDATA[ I am currently working with a 2.6.32.15 kernel and have tried to map one or more pages of RAM with ioremap (non cached).<br />
<br />
I know that this is not the way of doing it. But during my evaluation i detected a sanity check  within <br />
__ioremap_caller() - see comment 'Don't allow anybody to remap normal RAM that we're using' . <br />
<br />
I am of the opinion that this check is wrong (it has been possible for me to map one page of RAM with ioreamp() - if i map more than one page, ioremap() returns NULL).<br />
<br />
Here is my proposed solution to fix this:<br />
<br /><pre class="bbcode">
--- arch/x86/mm/ioremap.c.orig  2009-12-03 04:51:21.000000000 +0100
+++ arch/x86/mm/ioremap.c       2010-07-02 10:05:24.330120000 +0200
@@ -1,4 +1,4 @@
-/*
+*
  * Re-map IO memory to kernel address space so that we can access it.
  * This is needed for high PCI addresses that aren't mapped in the
  * 640k-1MB IO memory area on PC's
@@ -138,12 +138,12 @@
         * Don't allow anybody to remap normal RAM that we're using..
         */
        for (pfn = phys_addr &gt;&gt; PAGE_SHIFT;
-                               (pfn &lt;&lt; PAGE_SHIFT) &lt; (last_addr &amp; PAGE_MASK);
+                               (pfn &lt;&lt; PAGE_SHIFT) &lt;= (last_addr &amp; PAGE_MASK);
                                pfn++) {
 
                int is_ram = page_is_ram(pfn);
 
-               if (is_ram &amp;&amp; pfn_valid(pfn) &amp;&amp; !PageReserved(pfn_to_page(pfn)))
+               if (is_ram &amp;&amp; pfn_valid(pfn) &amp;&amp; PageReserved(pfn_to_page(pfn)))
                        return NULL;
                WARN_ON_ONCE(is_ram);
        }
</pre>]]></description>
            <dc:creator>Werner Spies</dc:creator>
            <category>Memory Management</category>
            <pubDate>Fri, 02 Jul 2010 04:17:04 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1695,1695#msg-1695</guid>
            <title>pd_data_t is the base element for a node (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1695,1695#msg-1695</link>
            <description><![CDATA[ pd_data_t is the base element for a node <br />
<br />
I am a kernel newbies. <br />
<br />
When I studied kernel memory management, pg_data_t is the first data structure.<br />
<br />
1. to distinguish between NUMA and UMA systems.<br />
2.  RAM is divided into nodes which are represented by pg_data_t.<br />
3. Each node is split into zones.<br />
4. Each zone is an array of struct page.<br />
<br /><blockquote class="bbcode">Quote:<div>
 600typedef struct pglist_data {<br />
 601        struct zone node_zones[MAX_NR_ZONES];<br />
 602        struct zonelist node_zonelists[MAX_ZONELISTS];<br />
 603        int nr_zones;<br />
 604#ifdef CONFIG_FLAT_NODE_MEM_MAP /* means !SPARSEMEM */<br />
 605        struct page *node_mem_map;<br />
 606#ifdef CONFIG_CGROUP_MEM_RES_CTLR<br />
 607        struct page_cgroup *node_page_cgroup;<br />
 608#endif<br />
 609#endif<br />
 610#ifndef CONFIG_NO_BOOTMEM<br />
 611        struct bootmem_data *bdata;<br />
 612#endif<br />
 613#ifdef CONFIG_MEMORY_HOTPLUG<br />
 614        /*<br />
 615         * Must be held any time you expect node_start_pfn, node_present_pages<br />
 616         * or node_spanned_pages stay constant.  Holding this will also<br />
 617         * guarantee that any pfn_valid() stays that way.<br />
 618         *<br />
 619         * Nests above zone-&gt;lock and zone-&gt;size_seqlock.<br />
 620         */<br />
 621        spinlock_t node_size_lock;<br />
 622#endif<br />
 623        unsigned long node_start_pfn;<br />
 624        unsigned long node_present_pages; /* total number of physical pages */<br />
 625        unsigned long node_spanned_pages; /* total size of physical page<br />
 626                                             range, including holes */<br />
 627        int node_id;<br />
 628        wait_queue_head_t kswapd_wait;<br />
 629        struct task_struct *kswapd;<br />
 630        int kswapd_max_order;<br />
 631} pg_data_t;<br /></div></blockquote>
<br />
<a rel="nofollow"  href="http://lxr.linux.no/#linux+v2.6.34/include/linux/mmzone.h#L631">http://lxr.linux.no/#linux+v2.6.34/include/linux/mmzone.h#L631</a>]]></description>
            <dc:creator>fishchip2</dc:creator>
            <category>Memory Management</category>
            <pubDate>Sat, 03 Jul 2010 12:28:35 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1669,1669#msg-1669</guid>
            <title>How to get the file cached in kernel buffer w/o copying it to user buffer? (2 replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1669,1669#msg-1669</link>
            <description><![CDATA[ Hello, <br />
<br />
I have a requirement to warm the cache( read file from disk to kernel buffer) without coping it to any user buffer. Is there any way (eg. interfaces, IOCTL) to do this. Thank you very much.<br />
<br />
-Deng Liu]]></description>
            <dc:creator>luludede</dc:creator>
            <category>Memory Management</category>
            <pubDate>Mon, 28 Jun 2010 17:19:34 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1668,1668#msg-1668</guid>
            <title>Allocating HugeTLB pages in kernel space (no replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1668,1668#msg-1668</link>
            <description><![CDATA[ How can you allocate a HugeTLB page in a device driver? If I allocate a page using __GFP_COMP, does this make it a compound HugeTLB page, or do I have to do something else to make it one?<br />
<br />
I've found lots of pages on google about doing this in user space, but nothing about how to do it in kernel space.<br />
<br />
Thanks]]></description>
            <dc:creator>bob</dc:creator>
            <category>Memory Management</category>
            <pubDate>Sun, 20 Jun 2010 22:49:56 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1667,1667#msg-1667</guid>
            <title>Maximum malloc-able user virtual memory (no replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1667,1667#msg-1667</link>
            <description><![CDATA[ Hi !<br />
<br />
I have a small piece of code which mallocs 1MB of memory in an infinite loop till malloc fails. The code goes like this:<br /><pre class="bbcode">
    void *mem;
    while (1) {
        mem = (void *) malloc(1024 * 1024); //1MB
        if  (!mem) {
            dump_mem_info(); //Prints total memory malloced using details from /proc/&lt;pid&gt;/status
            break;  
    }</pre>
I'm aware that Linux uses optimistic memory allocation, i.e., malloc returns memory although there may not be enough memory available on the RAM.<br />
<br />
For a 32 bit x86 machine, I can go up to 3GB with malloc. This is because of the 3GB/1GB user/kernel virtual memory split.<br />
<br />
I'm working on a powerPC system in which malloc fails at 1.3GB. I have checked the following:<br />
1. Resource limit (ulimit -a), and it is set to unlimited.<br />
2. Configuration in /etc/security/limits.conf, and there is no memory limit set.<br />
<br />
I have been desperately trying to find answers to the following questions: (I have already googled a lot before posting post):<br />
a. Why is the virtual memory restricted to 1.3GB in the user space ? For a 32 bit machine, shouldn't 3GB be the limit ? Is this limit specific to powerPC ?<br />
b. In general, how do I find the maximum user virtual memory limit without running the above code which I wrote ? Is there a configuration file<br />
or command to check this ?<br />
<br />
Thanks in advance !]]></description>
            <dc:creator>Wagaboy</dc:creator>
            <category>Memory Management</category>
            <pubDate>Sun, 20 Jun 2010 15:37:27 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1544,1544#msg-1544</guid>
            <title>memory control (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1544,1544#msg-1544</link>
            <description><![CDATA[ I'm writing kernel module for checking consistency of program text segments in main memory. These control is realized by checking Crc32 checksums of code segments for every process. So I use such algorithm:<br />
- go through the list of active tasks<br />
- for each task go through list of vm_area_struct structures<br />
- check if these VMA is code segment <br />
- check if area is fully loaded in main memory<br />
- translate address from user virtual address space to kernel<br />
- find checksum of these area<br />
- compare with checksum computed at previous circle<br />
After long working period my module got result that everything has changed)) So, there is small problem: all these memory areas turned out to be mutable!) As I think, code segments shouldn't change because of there is no overlays in kernel or program realization.<br />
<br />
Can somebody explain me the reason of these fact?]]></description>
            <dc:creator>bushlyamax</dc:creator>
            <category>Memory Management</category>
            <pubDate>Wed, 28 Apr 2010 14:08:26 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1533,1533#msg-1533</guid>
            <title>Problems with get_user (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1533,1533#msg-1533</link>
            <description><![CDATA[ Hi, all, <br />
<br />
        I have a problem with get_user() macro. What I did is as follows:<br />
<br />
       I run the following program<br />
<br />
        int main()<br />
        {<br />
             int a = 20;<br />
             printf(&quot;address of a: %p&quot;, &amp;a);<br />
             sleep(200);<br />
             return 0;<br />
        }<br />
<br />
        When the program runs, it outputs the address of a, say, 0xbff91914.<br />
<br />
        Then I pass this address to a module running in Kernel Mode that retrieves the contents at this address (at the time when I did this, I also made sure the process didn't terminate, because I put it to sleep for 200 seconds... ):<br />
<br />
        The address is firstly sent as a string, and I cast them into pointer type.<br />
<br />
         int * ptr = (int*)simple_strtol(buffer, NULL,16);<br />
         printk(&quot;address: %p&quot;,ptr); // I use this line to make sure the cast is correct. When running, it outputs bff91914, as expected.<br />
         int val = 0;<br />
         int res;<br />
         res= get_user(val,  (int*) ptr);<br />
        <br />
        However, res is always not 0, meaning that get_user returns error. I am wondering what is the problem....<br />
<br />
        Thank you!!]]></description>
            <dc:creator>wolfel</dc:creator>
            <category>Memory Management</category>
            <pubDate>Wed, 28 Apr 2010 04:47:01 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1489,1489#msg-1489</guid>
            <title>Page cache size capped at 9 GB (5 replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1489,1489#msg-1489</link>
            <description><![CDATA[ I'm running some disk IO tests, and for one of my tests, I need an entire large file to fit in memory. I have a Nehalem EP server with 24GB RAM, and my file size is 20GB (it doesn't matter what size I use, so long as it is greater than 9 GB ) (which resides on an SSD). I'm running the Fedora 11 with 2.6.29.5 and 2.6.30 kernel versions.<br />
<br />
I'm faced with the following problem: For some reason, the page cache reaches a cap at ~9GB of memory, as shown by the vmstat output below.<br />
<br />
I see this problem consistently across different kernel versions on this machine. Any thoughts on why the page cache size is capped at 9GB ? <br />
<br />
I tried the same test on another machine (with much larger memory -- 144GB ), and don't see this issue -- the entire file fits nicely in RAM.<br />
<br />
What am I missing?<br />
<br />
 0  1      0 15266484  23948 7905468    0    0 20784     5 5424 10424  0  1 87 12  0<br />
 0  1      0 15204236  23948 7967780    0    0 20776     0 5394 10415  0  1 88 12  0<br />
 1  1      0 15141864  23948 8030088    0    0 20780     0 5438 10420  0  1 88 11  0<br />
 0  1      0 15079584  23948 8092412    0    0 20781     0 5414 10431  0  1 88 11  0<br />
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----<br />
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st<br />
 1  0      0 15017212  23948 8154708    0    0 20775     0 5423 10441  0  1 88 11  0<br />
 0  1      0 14954964  23948 8217416    0    0 20781     0 5431 10425  0  1 87 12  0<br />
 0  1      0 14892592  23948 8279716    0    0 20777     0 5405 10418  0  1 87 12  0<br />
 0  1      0 14830084  23948 8342020    0    0 20776     0 5418 10431  0  1 88 11  0<br />
 0  1      0 14767972  23948 8404336    0    0 20779     0 5402 10424  0  1 88 11  0<br />
 0  1      0 14705536  23948 8466636    0    0 20776     0 5434 10436  0  1 88 11  0<br />
 0  1      0 14643172  23948 8528956    0    0 20781     0 5436 10421  0  1 87 12  0<br />
 0  1      0 14580924  23948 8591256    0    0 20777     0 5403 10423  0  1 87 12  0<br />
 0  1      0 14518552  23948 8653560    0    0 20776     1 5401 10416  0  1 88 11  0<br />
 0  1      0 14456304  23948 8715876    0    0 20783     0 5417 10422  0  1 88 11  0<br />
 0  1      0 14393932  23948 8778184    0    0 20776     0 5456 10431  0  1 87 12  0<br />
 0  1      0 14331684  23948 8840492    0    0 20779     0 5427 10421  0  1 88 11  0<br />
 0  1      0 14269304  23948 8902800    0    0 20777     0 5405 10421  0  1 87 12  0<br />
 0  1      0 14206796  23948 8965120    0    0 20775     0 5420 10423  0  1 88 11  0<br />
 0  1      0 14144684  23948 9027424    0    0 20784     0 5419 10419  0  1 87 12  0<br />
 0  1      0 14120936  12328 9062656    0    0 20697     0 5512 10396  0  1 88 11  0<br />
 0  1      0 14120828   7092 9067980    0    0 20649     0 5576 10353  0  1 87 11  0<br />
 0  1      0 14120956   7092 9067868    0    0 20599     0 5422 10332  0  1 88 11  0<br />
 0  1      0 14120824   7092 9067652    0    0 20583     0 5379 10325  0  1 87 12  0<br />
 0  1      0 14120836   7100 9067904    0    0 20576     5 5398 10321  0  1 88 11  0<br />
 0  1      0 14120948   7100 9067620    0    0 20564     0 5389 10320  0  1 88 11  0<br />
<br />
Thanks,<br />
MV]]></description>
            <dc:creator>mv</dc:creator>
            <category>Memory Management</category>
            <pubDate>Mon, 26 Apr 2010 23:36:39 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1488,1488#msg-1488</guid>
            <title>How memory mapping works in virtual address space ?? (7 replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1488,1488#msg-1488</link>
            <description><![CDATA[ Hi All,<br />
<br />
I would like to know how virtual address mapping to physical memory works.<br />
<br />
1) I read that there is kernal code and kernal static data structures which are directly stored in physical memory without virtual memory mapping. Is it right ?<br />
2) Other than kernal static data structures and code, there is dynamic memory for both kernal mode and user mode process address space. In the kernal mode, kernal dynamic data structures are allocated in kernal linear address space. Also, usermode memory requirements are satisfied in this dynamic memory. am i right ?<br />
3) how dynamic memory is split between usermode and kernal mode memory requirements ?<br />
4) Also, there are 3 levels of memory mapping between virtual and physical address space. That is, a) less than 896 b) between 896 and 4096, c) above 4096. so, why they specifically selected this 3 ranges ??<br />
5) Is there any online documents which explains these concepts clearly with an example ??<br />
6) i read the book &quot;Understand Linux Kernel&quot;. but, i am not able to fully understand the memory management concept. Please provide me some material which can explain these concepts clearly with an example.<br />
<br />
Thanks,<br />
Rajaram.]]></description>
            <dc:creator>Rajaraman</dc:creator>
            <category>Memory Management</category>
            <pubDate>Thu, 09 Sep 2010 09:32:30 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1479,1479#msg-1479</guid>
            <title>relocation, virtual addressing etc (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1479,1479#msg-1479</link>
            <description><![CDATA[ Hi,<br />
<br />
I have 3 questions <br />
<br />
1) Sometimes, the kernel is relocated on the target. When is this necessary ? <br />
<br />
2) The kernel is linked at the virtual load-address ( eg: 0xC0000000).<br />
Until MMU is enabled, how does the kernel execute ? (  I read about some trick in kernel to do this.  But forgot )<br />
<br />
3)  In MIPS,  the  user-kernel VA division is 2:2.  But in ARM and x86,  it  is  3:1 ratio.  <br />
Why they differ ?<br />
<br />
                                 thanks]]></description>
            <dc:creator>shankar</dc:creator>
            <category>Memory Management</category>
            <pubDate>Mon, 26 Apr 2010 15:05:28 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1478,1478#msg-1478</guid>
            <title>accessing stack of non-current  task (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1478,1478#msg-1478</link>
            <description><![CDATA[ Hi,<br />
<br />
Is it possible for the kernel to access the user-stack data of a<br />
task different from &quot;current&quot; ?  ( This is needed for stack-dump as well as backtrace. )<br />
<br />
I thought the answer is &quot;no&quot;. ( Kernel sees memory through the page-table of &quot;current&quot; )<br />
<br />
But I found few places in kernel where this is done. ( eg: debug_rt_mutex_print_deadlock() in rtmutex-debug.c )<br />
<br />
What is the explanation ? <br />
<br />
                     thanks<br />
                              shankar]]></description>
            <dc:creator>shankar</dc:creator>
            <category>Memory Management</category>
            <pubDate>Mon, 26 Apr 2010 15:08:49 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1477,1477#msg-1477</guid>
            <title>Memory increase without leaks :) (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1477,1477#msg-1477</link>
            <description><![CDATA[ I am experiencing some continuous memory increasing problem without any memory leak.  I am saying that there is no memory leak, because<br />
•	I have checked with Purify<br />
•	And confirm that there is no any Intentional memory leak that cannot find with tools like Purify<br />
<br />
My binary is 32 bit version and it is running in a 64 bit machine and uses the top command to check the memory usage.<br />
My program is written in c++ and it is bit difficult to describe the exact logic here, but basically what it does when consider the memory allocation side is,<br />
1)	Create some data structures by allocating small size memory blocks (by inserting some data). Total allocation will be around 3Gb <br />
2)	Again insert the same data (repeat the step 1)<br />
<br />
When insert the same data set in the second time, it should not increase the total allocated memory (that is how it was designed). But unfortunately it is increasing in my case.<br />
<br />
Seems like, this increase has some pattern. Second insert will increase the memory usage by a big amount, from next increase the memory increment is less.<br />
<br />
Is this due to memory fragmentation, or due to running the 32bit binary in 64bit environment, or some kind of issue with top command output? Does anyone have any suggestion about why this kind of thing happened..?]]></description>
            <dc:creator>rpjanaka</dc:creator>
            <category>Memory Management</category>
            <pubDate>Mon, 26 Apr 2010 15:11:05 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1475,1475#msg-1475</guid>
            <title>question about COW (no replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1475,1475#msg-1475</link>
            <description><![CDATA[ There is an &quot;early COW&quot; mechanism in __do_fault which, if the page was not present and the fault was FAULT_PAGE_WRITE goes ahead and copies the page in order to prevent the next exception. <br />
<br />
The question - why the code in __do_fault does not decrease the shared map count of the old page as do_wp_page does ?]]></description>
            <dc:creator>Demiurg</dc:creator>
            <category>Memory Management</category>
            <pubDate>Fri, 16 Apr 2010 18:38:08 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1466,1466#msg-1466</guid>
            <title>help needed page replacement (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1466,1466#msg-1466</link>
            <description><![CDATA[ HI<br />
I am doing a project on page replacement algorithms.... Can anyone point out the the source code for page swapping in linux kernel source tree. Which algorithm is used in linux kernel.<br />
I am using 2.6.20 kernel on a 32 bit x86 machine.<br />
<br />
Thanking in advance<br />
apoorv]]></description>
            <dc:creator>devil_</dc:creator>
            <category>Memory Management</category>
            <pubDate>Mon, 26 Apr 2010 15:28:14 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1394,1394#msg-1394</guid>
            <title>Accessing/controlling OneNAND SRAM buffers (2 replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1394,1394#msg-1394</link>
            <description><![CDATA[ Hello!<br />
<br />
I am trying to write some software that will be able to take advantage of the fact that OneNAND supports execute-in-place. What I need to be able to do is to access the SRAM buffers in the OneNAND chip directly, as well as controlling what data is loaded into them. The software is aimed at being used in ARM systems.<br />
<br />
As I have never written software down at the driver level (or kernel level), I dont really know where to start. Will it be possible to use the existing mtd drivers to accomplish what I want, or will I have to write something new? Is it possible to call the mtd driver functions directly from my own software or will I have to write some kind of new module?<br />
<br />
If someone could point me towards a book/website or has some useful tips, I would be very grateful.<br />
<br />
Best regards,<br />
//Leo]]></description>
            <dc:creator>leob</dc:creator>
            <category>Memory Management</category>
            <pubDate>Tue, 09 Mar 2010 16:48:27 -0500</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1250,1250#msg-1250</guid>
            <title>how to get the address of other page descriptors from alloc_pages()? (4 replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1250,1250#msg-1250</link>
            <description><![CDATA[ Hi, <br />
<br />
In Linux kernel, alloc_pages() allocate a congiguous series of pages and return the page descriptor of the first page.<br />
Can anyone tell me how to get the other page descriptors(2nd page descriptor, 3rd page descriptor)? Thank you.<br />
<br />
In the code below, I assumed the page descriptors are also in contiguous memory but it just crashed the kernel with I add the page to page cache lru.<br />
<br />
		firstpage = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO|__GFP_COLD, 4);<br />
		  if(unlikely(firstpage == NULL)) {<br />
                    goto normal_handling;<br />
		}<br />
		<br />
		for(i=0; i&lt;16; i++) {/*add 16 pages to lru list*/<br />
	          error= add_to_page_cache_lru(firstpage+i, mapping, first_index+i,GFP_KERNEL);<br />
-Deng]]></description>
            <dc:creator>luludede</dc:creator>
            <category>Memory Management</category>
            <pubDate>Sun, 07 Feb 2010 02:14:39 -0500</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1229,1229#msg-1229</guid>
            <title>How to map the  physical contiguous pages into a block of logical contiguous address space? (3 replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1229,1229#msg-1229</link>
            <description><![CDATA[ Hello,<br />
<br />
In Linux Kernel, we have alloc_pages(unsigned int gfp_mask, unsigned int order) to allocate 2^order contiguous physical pages, and we have page_address(struct page *page)  to returns the logical address of a single page.<br />
<br />
However, it seems that page_address() doesn't guarantee that the physical contiguous pages be mapped to logical contiguous address space. For example if we apply page_address() to four physical contiguous pages for four times, the returned logical address are not necessarily contiguous.<br />
<br />
My question is : <strong class="bbcode">How to map the  physical contiguous pages into a block of logical contiguous address space?</strong><br />
<br />
Thank you!]]></description>
            <dc:creator>luludede</dc:creator>
            <category>Memory Management</category>
            <pubDate>Sat, 19 Dec 2009 15:10:03 -0500</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1112,1112#msg-1112</guid>
            <title>custom mmap() in a driver (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1112,1112#msg-1112</link>
            <description><![CDATA[ Hi<br />
<br />
I'm looking for a way to implement a mapping of several pages prepared by kernel into caller process's space from within ioctl() call. The ioctl() in question is a sort of &quot;bind to subdevice&quot;, and making some area accessibly read-only by the calling process is semantically part of operation.<br />
<br />
Yes I may implement that by requiring calling process to issue mmap() after my ioctl().<br />
And I may also call do_mmap_pgoff() from my ioctl() and then get control in my device's mmap method.<br />
<br />
But that both will allow for mmap()'s independently of &quot;bind ioctl&quot;, which is somewhat ugly in my case where pages to map are actually prepared by ioctl() so call to mmap() not related to call to ioctl() is incorrect operation and should be protected against.<br />
<br />
Is there a way to implement exactly what I need - that means, map a set of vmalloc()ed pages info current process memory space from particular point in kernel code, and nothing more?]]></description>
            <dc:creator>yoush</dc:creator>
            <category>Memory Management</category>
            <pubDate>Tue, 24 Nov 2009 15:02:30 -0500</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1108,1108#msg-1108</guid>
            <title>Userspace API for sharing memory between unrelated processes (4 replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1108,1108#msg-1108</link>
            <description><![CDATA[ Hi, I was playing with ideas for sending data between processes without copying, and came up with the following idea for a memory page sharing API.   I'm wondering if there are existing facilities that can handle this, whether this API makes sense, and how much potential work it might be to implement (as a kernel patch).<br />
<br />
Suppose I have a range of pages that I have allocated with mmap(MAP_ANONYMOUS|MAP_SHARED) and I want to deliver tham to another process.  I may want to give the other process read access, or actually *give* the pages to that process such that I no longer have them mapped.<br />
<br />
Here's my idea for an API to do this:<br /><pre class="bbcode">
/**
 * Create an offer to the specified process for the given range of address space.
 * The address space must be a whole multiple of pages.
 * The address space must be validly mapped for the current process.
 * Changes specified by this function do not occur until the remote process
 *   accepts the offer.
 * An offer can be cancelled by offering the same address with a size of 0.
 *   If the target process has already accepted the offer, it is too late, and the
 *   call will simply fail as this address is no longer valid for the current process.
 * If all permissions are dropped, then the memory is unmapped from the current
 *   process when the offer is claimed.
 * Flags:
 *    VMO_GRANT_R - grant read access to the remote process
 *    VMO_GRANT_W - grant write access to the remote process
 *    VMO_GRANT_X - grant exec access to the remote process
 *    VMO_DROP_R - release this process' read permission for the pages
 *    VMO_DROP_W - release this process' write permission for the pages
 *    VMO_DROP_X - release this process' exec permission for the pages
 *
 *    VMO_DISOWN - combination of all &quot;drop&quot; flags
 *    VMO_GRANTALL - combination of all &quot;grant&quot; flags
 */
int vm_offer(int dest_pid, void *addr, int len, int flags);

/**
 * Receive an offer of VM pages from another process.
 * The offer must have already been made by the source process.
 * The offer is identified (from other offers made by that process) by specifying the remote virtual address.
 * Flags:
 *   (none, yet)
 */
int vm_claim(int src_pid, void *remote_addr, void **local_addr, int *size, int flags);

/**
 * List sent and received offers.
 * list is a buffer to which an array of offer records will be written
 * count should be initialized to the size (in records) of the list
 * upon successful return, list is populated, and count is the number of entries
 * upon failure, list is unaltered and count is the number of entries needed in order to return successfully
 * Note that offers are dynamic in nature and may change before the entries can be acted on.
 */
int vm_listoffer(vm_offer_t *list, int *count);</pre>
<br />
I'm aware that I can get a similar effect by creating a file in tmpfs, mmaping it into the second process, and unmapping from the first.  However, I don't like the idea of the overhead of tmpfs and having to choose filenames.  If I create a messaging system from this API with lots of tiny 1-page messages it seems that the overhead of creating tmpfs files could be significant.<br />
<br />
Perhaps I should have stated that sooner- I'm looking for a mechanism that can handle lots and lots of action, such that it is more efficient than writing the data to a pipe (and has the added advantage that any 2 processes can use it without any setup work, rather than needing to create pipes or sockets and client/server designs)<br />
<br />
Any advice?  Is something like this out there?  Is it conceivable that an implementation could operate faster than writing 1000 bytes through a UNIX socket?<br />
<br />
Thanks in advance<br />
<br />
P.S. It occurs to me that if this API were implemented, its use could be extended to MANY things, like passing kernel-allocated data buffers to userspace in a more streamlined and simple manner, again without copying anything.]]></description>
            <dc:creator>MConrad</dc:creator>
            <category>Memory Management</category>
            <pubDate>Wed, 18 Nov 2009 16:50:44 -0500</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1086,1086#msg-1086</guid>
            <title>Inactive memory (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1086,1086#msg-1086</link>
            <description><![CDATA[ Hi,<br />
<br />
we've ended in a linux machine (kernel  2.6.16.46-0.12-smp x86_64)  with more &quot;inactive memory&quot; than &quot;cached+buffered&quot;. Is<br />
it possible to get to this situation  or is it a bug ? <br />
Should be consider the inactive memory as free ?<br />
<br />
Example in  a 32 Gb server:<br />
<br />
cat  /proc/meminfo<br />
<br />
..<br />
Buffers:           76500 kB<br />
Cached:        987345 kB<br />
..<br />
Active:         4845821 kB<br />
Inactive:    25189976 kB<br />
<br />
<br />
<br />
Inactive memory of 25 Gb !!!    current free memory according to -/+ buffers/cache, around 1GB  <br />
<br />
I we start a program which allocates 5 Gb of memory, it will take it from the inactive memory !! and once it finishes it will<br />
put it back as free memory. So, actually the inactive memory was like &quot;free&quot; memory....]]></description>
            <dc:creator>Juan Romera</dc:creator>
            <category>Memory Management</category>
            <pubDate>Sat, 31 Jul 2010 18:26:53 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1070,1070#msg-1070</guid>
            <title>where is the register sets of user space stored in kerne stack while after syscall (no replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1070,1070#msg-1070</link>
            <description><![CDATA[ Hi, all. <br />
It's my first question asked here, so please pay some time;)<br />
<br />
I mean how to get the address of struct pt_regs that stores the user space register's in kernel stack. I found a statement said:<br /><blockquote class="bbcode">Quote:<div>
Register set is easy to do, as long as you know where it is.  On Linux, there is a simple connection between the locations of process' task structure and its register set location:<br />
<br />
Assuming struct task_struct *p is a pointer to the task structure, then the corresponding register set location is:<br />
<br />
struct pt_regs *regs = ((struct pt_regs *)(2*PAGE_SIZE + (unsigned long)p)) - 1;</div></blockquote>
<br />
while, this code is written for v2.4 kernel, I don't think it wrok in the linux 2.6 kernel. So could some one to told me some to get the right place? (I know we can use the task pointer to find the kernel stack).<br />
<br />
Thanks!]]></description>
            <dc:creator>Aleaxander</dc:creator>
            <category>Memory Management</category>
            <pubDate>Fri, 16 Oct 2009 06:13:48 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1052,1052#msg-1052</guid>
            <title>how to copy process-heap to kernel-buffer (5 replies)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1052,1052#msg-1052</link>
            <description><![CDATA[ Hi friends,<br />
    My kernel-module wants to copy another process's heap to its(module's) buffer(kmalloced).<br />
    this is performed by &quot; root &quot; user.<br />
    Objective:- <br />
<br />
    I have a very simple process prog1.o which allocates 5 integers using malloc and then waits for user to enter his age from keyboard.<br />
    Now,while the prog1.o is waiting for the user's input from keyboard, during that time, my kernel module kern_module.c tries to copy the heap of prog1.o<br />
    to kernel-memory.<br />
    <br />
    For copying prog1.o 's heap to my module's buffer i use copy_from_user.<br />
    But, somehow <strong class="bbcode">the copy_from_user does not copy a single byte from the specified process-heap</strong>.<br />
    Code is given below :<br />
    ********************************************************<br />
    prog1.c (i.e. prog1.o)  ---- run by &quot; root &quot;<br />
                 <br />
                 int main()<br />
                 {<br />
                    int i,age;<br />
                    int* arr = (int*) malloc(5*sizeof(int));  //allocate 5 integers in heap<br />
                    for(i=0;i&lt;5;i++)    //give some value to dynamic array<br />
                      arr[i]=i;<br />
                    <br />
                    printf(&quot;Enter age:&quot;); //read user-age<br />
                    scanf(&quot;%d&quot;,&amp;age); //at this stage of execution, the module kern_module stops this program and tries to copy this program's heap to krnel-space<br />
                    return 0;               // this will never execute.<br />
                 }<br />
<br />
    ********************************************************<br />
    The kernel-module's code is here:--&gt;<br />
     kern_module.c (i.e. kern_module.ko)  <strong class="bbcode">---- run by &quot; root &quot;</strong><br />
                 -------------<br />
                 int copy_heap_to_kernel_space(int pid) //here pid is the process id of prog1.o<br />
                 {<br />
                    task_struct* p = find_task_by_pid(pid); //obtain task_struct<br />
                    if(!p)<br />
                    {<br />
                        printk(&quot;error.\n&quot;); return -1;<br />
                    }<br />
                    send_sig(SIGSTOP,p,0);  //stop the above prog1.o process<br />
                    <br />
                    unsigned long heap_len = p-&gt;mm-&gt;brk - p-&gt;mm-&gt;start_brk; //length of heap<br />
                    if( !access_ok(VERIFY_READ,p-&gt;mm-&gt;start_brk,heap_len) )<br />
                    {<br />
                        printk(&quot; NOT access_ok.&quot;);  return -1;<br />
                    }<br />
                    void* kernel_buffer = kmalloc(heap_len,GFP_KERNEL);<br />
                    unsigned long bytes_failed =0;<br />
                    if(!kernel_buffer)<br />
                    {<br />
                      printk(&quot;buffer allocatoin failure.\n&quot;); return -1;<br />
                    }<br />
                    // Till this position, the module works properly, but the following line not works as per expectation.<br />
                    <span style="color: #FF99FF">bytes_failed = copy_from_user(kernel_buffer,p-&gt;mm-&gt;start_brk,heap_len);// it fails &amp; does not copy a single byte from heap to kernel_buffer<br />
                    if(bytes_failed!=0)<br />
                    {<br />
                      printk(&quot;Failed to copy %u bytes.\n&quot;,bytes_failed);//always this happens <br />
                      return -1;<br />
                    }</span>                    else<br />
                      printk(&quot;heap successfully copied to kernel space.\n&quot;);<br />
                      <br />
                      <br />
                    return 0;<br />
                 }<br />
<br />
<br />
output        :- Failed to copy 135168 bytes.<br />
<br />
    <br />
******************************************************************************<br />
Plz. suggest me a solution , why this happens.]]></description>
            <dc:creator>rushikesh</dc:creator>
            <category>Memory Management</category>
            <pubDate>Sun, 01 Nov 2009 09:46:08 -0500</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1044,1044#msg-1044</guid>
            <title>non-virtual flat memory configuration (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1044,1044#msg-1044</link>
            <description><![CDATA[ Is there an option to somehow configure the kernel that VMM won't be used so that kernel and user spaces will share memory space?]]></description>
            <dc:creator>chiko</dc:creator>
            <category>Memory Management</category>
            <pubDate>Fri, 09 Oct 2009 00:06:25 -0400</pubDate>
        </item>
        <item>
            <guid>http://forum.kernelnewbies.org/read.php?13,1012,1012#msg-1012</guid>
            <title>memory allocation for page tables (1 reply)</title>
            <link>http://forum.kernelnewbies.org/read.php?13,1012,1012#msg-1012</link>
            <description><![CDATA[ Hi,<br />
Will any one tell me from where is memory allocated to page directories and<br />
page tables?<br />
I mean is there any specific area in the memory from where memory is<br />
allocated to the page directories and page tables of different processes?<br />
<br />
shailesh]]></description>
            <dc:creator>shailesh</dc:creator>
            <category>Memory Management</category>
            <pubDate>Tue, 03 Nov 2009 22:18:20 -0500</pubDate>
        </item>
    </channel>
</rss>
