What does it mean for /proc/kpagecount to be zero












1















for some entries in /proc/kpagecount, all the 64 bit entry is zeros and yet the page is allocated (confirmed from /proc/kpageflags). What does it mean for kpagecount to be zero for certain physical pages? does that mean that a daemon process is using this memory?










share|improve this question



























    1















    for some entries in /proc/kpagecount, all the 64 bit entry is zeros and yet the page is allocated (confirmed from /proc/kpageflags). What does it mean for kpagecount to be zero for certain physical pages? does that mean that a daemon process is using this memory?










    share|improve this question

























      1












      1








      1








      for some entries in /proc/kpagecount, all the 64 bit entry is zeros and yet the page is allocated (confirmed from /proc/kpageflags). What does it mean for kpagecount to be zero for certain physical pages? does that mean that a daemon process is using this memory?










      share|improve this question














      for some entries in /proc/kpagecount, all the 64 bit entry is zeros and yet the page is allocated (confirmed from /proc/kpageflags). What does it mean for kpagecount to be zero for certain physical pages? does that mean that a daemon process is using this memory?







      kernel ram proc






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '14 at 22:16









      KeetoKeeto

      1084




      1084






















          1 Answer
          1






          active

          oldest

          votes


















          0














          proc/kpagecount is a virtual file, when you read it, you get the result of executing function kpagecound_read().



          static ssize_t kpagecount_read(struct file *file, char __user *buf,
          size_t count, loff_t *ppos)
          {
          // ....
          u64 pcount;

          pfn = src / KPMSIZE;
          count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
          if (src & KPMMASK || count & KPMMASK)
          return -EINVAL;

          while (count > 0) {
          if (pfn_valid(pfn))
          ppage = pfn_to_page(pfn);
          else
          ppage = NULL;
          if (!ppage || PageSlab(ppage) || page_has_type(ppage))
          pcount = 0;
          else
          pcount = page_mapcount(ppage);

          if (put_user(pcount, out)) {
          ret = -EFAULT;
          break;
          }

          pfn++;
          out++;
          count -= KPMSIZE;

          cond_resched();
          }
          // ...
          }


          and page_has_type() is.



          static inline int page_has_type(struct page *page)
          {
          return (int)page->page_type < PAGE_MAPCOUNT_RESERVE;
          }


          If the entry for a page is zero in kpagecount and is allocated, it means:




          1. It is used in slabs.


          2. page->page_type < PAGE_MAPCOUNT_RESERVE see patch :return 0 for special pages that are never mapped. This patch is quite new. Consider when this question is asked, I don't think it's the case.


          3. page_mapcount(page) returns zero. some page are allocated but not mapped.
            I'am not sure why. Anyway, you can write kernel module/code that allocate page without create a mapping.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f549383%2fwhat-does-it-mean-for-proc-kpagecount-to-be-zero%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            proc/kpagecount is a virtual file, when you read it, you get the result of executing function kpagecound_read().



            static ssize_t kpagecount_read(struct file *file, char __user *buf,
            size_t count, loff_t *ppos)
            {
            // ....
            u64 pcount;

            pfn = src / KPMSIZE;
            count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
            if (src & KPMMASK || count & KPMMASK)
            return -EINVAL;

            while (count > 0) {
            if (pfn_valid(pfn))
            ppage = pfn_to_page(pfn);
            else
            ppage = NULL;
            if (!ppage || PageSlab(ppage) || page_has_type(ppage))
            pcount = 0;
            else
            pcount = page_mapcount(ppage);

            if (put_user(pcount, out)) {
            ret = -EFAULT;
            break;
            }

            pfn++;
            out++;
            count -= KPMSIZE;

            cond_resched();
            }
            // ...
            }


            and page_has_type() is.



            static inline int page_has_type(struct page *page)
            {
            return (int)page->page_type < PAGE_MAPCOUNT_RESERVE;
            }


            If the entry for a page is zero in kpagecount and is allocated, it means:




            1. It is used in slabs.


            2. page->page_type < PAGE_MAPCOUNT_RESERVE see patch :return 0 for special pages that are never mapped. This patch is quite new. Consider when this question is asked, I don't think it's the case.


            3. page_mapcount(page) returns zero. some page are allocated but not mapped.
              I'am not sure why. Anyway, you can write kernel module/code that allocate page without create a mapping.






            share|improve this answer




























              0














              proc/kpagecount is a virtual file, when you read it, you get the result of executing function kpagecound_read().



              static ssize_t kpagecount_read(struct file *file, char __user *buf,
              size_t count, loff_t *ppos)
              {
              // ....
              u64 pcount;

              pfn = src / KPMSIZE;
              count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
              if (src & KPMMASK || count & KPMMASK)
              return -EINVAL;

              while (count > 0) {
              if (pfn_valid(pfn))
              ppage = pfn_to_page(pfn);
              else
              ppage = NULL;
              if (!ppage || PageSlab(ppage) || page_has_type(ppage))
              pcount = 0;
              else
              pcount = page_mapcount(ppage);

              if (put_user(pcount, out)) {
              ret = -EFAULT;
              break;
              }

              pfn++;
              out++;
              count -= KPMSIZE;

              cond_resched();
              }
              // ...
              }


              and page_has_type() is.



              static inline int page_has_type(struct page *page)
              {
              return (int)page->page_type < PAGE_MAPCOUNT_RESERVE;
              }


              If the entry for a page is zero in kpagecount and is allocated, it means:




              1. It is used in slabs.


              2. page->page_type < PAGE_MAPCOUNT_RESERVE see patch :return 0 for special pages that are never mapped. This patch is quite new. Consider when this question is asked, I don't think it's the case.


              3. page_mapcount(page) returns zero. some page are allocated but not mapped.
                I'am not sure why. Anyway, you can write kernel module/code that allocate page without create a mapping.






              share|improve this answer


























                0












                0








                0







                proc/kpagecount is a virtual file, when you read it, you get the result of executing function kpagecound_read().



                static ssize_t kpagecount_read(struct file *file, char __user *buf,
                size_t count, loff_t *ppos)
                {
                // ....
                u64 pcount;

                pfn = src / KPMSIZE;
                count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
                if (src & KPMMASK || count & KPMMASK)
                return -EINVAL;

                while (count > 0) {
                if (pfn_valid(pfn))
                ppage = pfn_to_page(pfn);
                else
                ppage = NULL;
                if (!ppage || PageSlab(ppage) || page_has_type(ppage))
                pcount = 0;
                else
                pcount = page_mapcount(ppage);

                if (put_user(pcount, out)) {
                ret = -EFAULT;
                break;
                }

                pfn++;
                out++;
                count -= KPMSIZE;

                cond_resched();
                }
                // ...
                }


                and page_has_type() is.



                static inline int page_has_type(struct page *page)
                {
                return (int)page->page_type < PAGE_MAPCOUNT_RESERVE;
                }


                If the entry for a page is zero in kpagecount and is allocated, it means:




                1. It is used in slabs.


                2. page->page_type < PAGE_MAPCOUNT_RESERVE see patch :return 0 for special pages that are never mapped. This patch is quite new. Consider when this question is asked, I don't think it's the case.


                3. page_mapcount(page) returns zero. some page are allocated but not mapped.
                  I'am not sure why. Anyway, you can write kernel module/code that allocate page without create a mapping.






                share|improve this answer













                proc/kpagecount is a virtual file, when you read it, you get the result of executing function kpagecound_read().



                static ssize_t kpagecount_read(struct file *file, char __user *buf,
                size_t count, loff_t *ppos)
                {
                // ....
                u64 pcount;

                pfn = src / KPMSIZE;
                count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
                if (src & KPMMASK || count & KPMMASK)
                return -EINVAL;

                while (count > 0) {
                if (pfn_valid(pfn))
                ppage = pfn_to_page(pfn);
                else
                ppage = NULL;
                if (!ppage || PageSlab(ppage) || page_has_type(ppage))
                pcount = 0;
                else
                pcount = page_mapcount(ppage);

                if (put_user(pcount, out)) {
                ret = -EFAULT;
                break;
                }

                pfn++;
                out++;
                count -= KPMSIZE;

                cond_resched();
                }
                // ...
                }


                and page_has_type() is.



                static inline int page_has_type(struct page *page)
                {
                return (int)page->page_type < PAGE_MAPCOUNT_RESERVE;
                }


                If the entry for a page is zero in kpagecount and is allocated, it means:




                1. It is used in slabs.


                2. page->page_type < PAGE_MAPCOUNT_RESERVE see patch :return 0 for special pages that are never mapped. This patch is quite new. Consider when this question is asked, I don't think it's the case.


                3. page_mapcount(page) returns zero. some page are allocated but not mapped.
                  I'am not sure why. Anyway, you can write kernel module/code that allocate page without create a mapping.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 16 at 5:59









                reverielreveriel

                11




                11






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f549383%2fwhat-does-it-mean-for-proc-kpagecount-to-be-zero%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to send String Array data to Server using php in android

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                    Is anime1.com a legal site for watching anime?