SlideShare a Scribd company logo
1 of 25
Download to read offline
Why mincore()
returns different
 value of stat ?
mapped file
Interior of a process
User-land                                    Kernel-land
            virtual mem                             physical mem

            mapped area




                            mmap() 1MB

                              mapped file
                               page 1
                                                       used by
                               page 2
                               page 3
                                        FS              others
                               page 4
                               page 5
                               page 6
                               page 7



                               page 256
User-land                               Kernel-land
            virtual mem                        physical mem

            mapped area
             page 1
             page 2
             page 3
             page 4
             page 5
             page 6
             page 7



             page 256

                          mapped file
                          page 1
                                                  used by
                          page 2
                          page 3
                                   FS              others
                          page 4
                          page 5
                          page 6
                          page 7



                          page 256
Major page fault
  User-land                                       Kernel-land
              virtual mem                                physical mem

              mapped area
touch          page 1
               page 2
               page 3
               page 4
               page 5
               page 6
               page 7



               page 256

                                    mapped file
                                    page 1
                                                            used by
                                    page 2
                                    page 3
                                             FS              others
                                    page 4
                                    page 5
                                    page 6
                                    page 7



                                    page 256
Major page fault
  User-land                                                  Kernel-land
              virtual mem                                               physical mem

              mapped area
touch          page 1                                                    page 2
               page 2
               page 3
                                                  Read page from disk
               page 4
               page 5
               page 6
               page 7



               page 256

                                    mapped file
                                    page 1
                                                                          used by
                                    page 2
                                    page 3
                                             FS                            others
                                    page 4
                                    page 5
                                    page 6
                                    page 7



                                    page 256
Major page fault
  User-land                                               Kernel-land
              virtual mem                                          physical mem

              mapped area              Associate physical memory
                                       with virtual memory
touch          page 1                                               page 2
               page 2
               page 3
               page 4
               page 5
               page 6
               page 7



               page 256

                                    mapped file
                                    page 1
                                                                     used by
                                    page 2
                                    page 3
                                             FS                       others
                                    page 4
                                    page 5
                                    page 6
                                    page 7



                                    page 256
User-land                               Kernel-land
              virtual mem                        physical mem

              mapped area
               page 1                              page 2
touch          page 2                              page 3
               page 3
               page 4
               page 5
               page 6
               page 7



               page 256

                            mapped file
                            page 1
                                                    used by
                            page 2
                            page 3
                                     FS              others
                            page 4
                            page 5
                            page 6
                            page 7



                            page 256
User-land                               Kernel-land
            virtual mem                        physical mem

            mapped area
             page 1                              page 2
             page 2                              page 3
             page 3                              page 6
             page 4                              page 7
             page 5                              page 1
             page 6                              page 4
             page 7



             page 256

                          mapped file
                          page 1
                                                  used by
                          page 2
                          page 3
                                   FS              others
                          page 4
                          page 5
                          page 6
                          page 7



                          page 256
swap out   (Just image , not actual)
User-land                               Kernel-land
              virtual mem                        physical mem

              mapped area
               page 1                              page 2
               page 2                              page 3
               page 3                              page 6
touch          page 4                              page 7
               page 5                              page 1
               page 6                              page 4
               page 7



               page 256

                            mapped file
                            page 1
                                                    used by
                            page 2
                            page 3
                                     FS              others
                            page 4
                            page 5
                            page 6
                            page 7



                            page 256
User-land                               Kernel-land
              virtual mem                        physical mem

              mapped area
               page 1                              page 2
               page 2                              page 3
               page 3                              page 6
touch          page 4                              page 7
               page 5                              page 1
               page 6                              page 4
               page 7



               page 256

                            mapped file
                            page 1
                                                    used by
                            page 2
                            page 3
                                     FS              others
                            page 4
                            page 5
                            page 6
                            page 7



                            page 256
User-land                               Kernel-land
              virtual mem                        physical mem

              mapped area
               page 1
               page 2                              page 3
               page 3                              page 6
touch          page 4                              page 7
               page 5                              page 1
               page 6                              page 4
               page 7



               page 256

                            mapped file
                            page 1
                                                    used by
                            page 2
                            page 3
                                     FS              others
                            page 4
                            page 5
                            page 6
                            page 7



                            page 256
User-land                               Kernel-land
              virtual mem                        physical mem

              mapped area
               page 1                              page 5
               page 2                              page 3
               page 3                              page 6
touch          page 4                              page 7
               page 5                              page 1
               page 6                              page 4
               page 7



               page 256

                            mapped file
                            page 1
                                                    used by
                            page 2
                            page 3
                                     FS              others
                            page 4
                            page 5
                            page 6
                            page 7



                            page 256
restart the process
Old process
User-land                                     Kernel-land
            virtual mem                              physical mem

            mapped area
             page 1                                    page 5
             page 2                                    page 3
             page 3                                    page 6
             page 4                                    page 7
             page 5                                    page 1
             page 6                                    page 4
             page 7



             page 256

                               mapped file
                                page 1
                                                        used by
                                page 2
                                page 3
                                         FS              others
                                page 4
                                page 5
                                page 6
                                page 7



                                page 256
Kill process
Nothing                       Kernel-land

                                     physical mem


                                       page 5
                                       page 3
                                       page 6
                                       page 7
                                       page 1
                                       page 4




                mapped file
                page 1
                                        used by
                page 2
                page 3
                         FS              others
                page 4
                page 5
                page 6
                page 7



                page 256
New process
User-land                                     Kernel-land

            virtual mem                              physical mem


                                                       page 5
                                                       page 3
                                                       page 6
                                                       page 7
                                                       page 1
                                                       page 4




                               mapped file
                                page 1
                                                        used by
                                page 2
                                page 3
                                         FS              others
                                page 4
                                page 5
                                page 6
                                page 7



                                page 256
User-land                                 Kernel-land
            virtual mem                          physical mem

            mapped area
             page 1                                page 5
             page 2                                page 3
             page 3                                page 6
             page 4                                page 7
             page 5                                page 1
             page 6                                page 4
             page 7
                          mmap() 1MB
             page 256

                           mapped file
                            page 1
                                                    used by
                            page 2
                            page 3
                                     FS              others
                            page 4
                            page 5
                            page 6
                            page 7



                            page 256
User-land                                            Kernel-land
            virtual mem                                     physical mem

            mapped area
             page 1
                          Actually, some pages are            page 5
                                                              page 3
             page 2
             page 3       on memory                           page 6
             page 4                                           page 7
             page 5                                           page 1
             page 6                                           page 4
             page 7



             page 256

                                  mapped file
                                  page 1
                                                               used by
                                  page 2
                                  page 3
                                           FS                   others
                                  page 4
                                  page 5
                                  page 6
                                  page 7



                                  page 256
Minor page fault
  User-land                                             Kernel-land
              virtual mem                                      physical mem

              mapped area
                                  ONLY associate physical
               page 1             memory with virtual memory     page 5
               page 2                                            page 3
               page 3                                            page 6
touch          page 4                                            page 7
               page 5                                            page 1
               page 6                                            page 4
               page 7



               page 256

                                  mapped file
                                  page 1
                                                                  used by
                                  page 2
                                  page 3
                                           FS                      others
                                  page 4
                                  page 5
                                  page 6
                                  page 7



                                  page 256
names & seeing
User-land                               Kernel-land
                    virtual mem                        physical mem
top
                    mapped area
/proc/<pid>/smaps
/proc/<pid>/statm    page 1            PTE VMA           page 5
 :                   page 2                              page 3
                     page 3                              page 6
                     page 4                              page 7
                     page 5                              page 1
                     page 6                              page 4
                     page 7
VIRT(virtual)
                     page 256

RES(resident)                     mapped file
                                  page 1
                                                          used by
SHR                               page 2
                                           FS              others
                                  page 3
                                  page 4
                                  page 5
mincore()                         page 6
                                  page 7



                                  page 256
Kernel code
fs/proc/task_mmu.c#L447                                                   mm/mincore.c#L108
static void smaps_pte_entry(pte_t ptent, unsigned long addr,   static void mincore_pte_range(struct vm_area_struct *vma,
                   unsigned long ptent_size, struct mm_walk    pmd_t *pmd,
*walk)                                                                     unsigned long addr, unsigned long end,
{                                                                          unsigned char *vec)
  struct mem_size_stats *mss = walk->private;                  {
  struct vm_area_struct *vma = mss->vma;                         unsigned long next;
  pgoff_t pgoff = linear_page_index(vma, addr);                  spinlock_t *ptl;
  struct page *page = NULL;                                      pte_t *ptep;
  int mapcount;
                                                                ptep = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
 if (pte_present(ptent)) {                                      do {
   page = vm_normal_page(vma, addr, ptent);                      pte_t pte = *ptep;
 } else if (is_swap_pte(ptent)) {                                pgoff_t pgoff;
   swp_entry_t swpent = pte_to_swp_entry(ptent);
                                                                 next = addr + PAGE_SIZE;
  if (!non_swap_entry(swpent))                                   if (pte_none(pte))
    mss->swap += ptent_size;                                       mincore_unmapped_range(vma, addr, next, vec);
  else if (is_migration_entry(swpent))                           else if (pte_present(pte))
    page = migration_entry_to_page(swpent);                        *vec = 1;
  } else if (pte_file(ptent)) {                                  else if (pte_file(pte)) {
    if (pte_to_pgoff(ptent) != pgoff)                              pgoff = pte_to_pgoff(pte);
      mss->nonlinear += ptent_size;                                *vec = mincore_page(vma->vm_file->f_mapping, pgoff);
  }                                                              } else { /* pte is a swap entry */
                                                                 swp_entry_t entry = pte_to_swp_entry(pte);
  if (!page)                                                           :
    return;                                                            :

  if (PageAnon(page))
    mss->anonymous += ptent_size;

  if (page->index != pgoff)
    mss->nonlinear += ptent_size;

  mss->resident += ptent_size;
    :
    :

More Related Content

Viewers also liked

презентация элективного курса по черчению
презентация элективного курса по черчениюпрезентация элективного курса по черчению
презентация элективного курса по черчениюloksal
 
Copyright crash course g salas
Copyright crash course g salasCopyright crash course g salas
Copyright crash course g salasgsalas10
 
El primer condicional
El primer condicionalEl primer condicional
El primer condicionalteacherhector
 
David classic 2tone silver bentley slideshow911
David classic 2tone silver bentley slideshow911David classic 2tone silver bentley slideshow911
David classic 2tone silver bentley slideshow911vivreed
 
Copyright crash course part 4
Copyright crash course part 4Copyright crash course part 4
Copyright crash course part 4gsalas10
 
My Favorite Movie
My Favorite MovieMy Favorite Movie
My Favorite Moviececil52
 
Crash course observation lab
Crash course observation labCrash course observation lab
Crash course observation labAugusto Ovelar
 
Optimal Management on Startup Village
Optimal Management on Startup VillageOptimal Management on Startup Village
Optimal Management on Startup VillageAndrey Sukhobokov
 
Copyright crash course part 5
Copyright crash course part 5Copyright crash course part 5
Copyright crash course part 5gsalas10
 
การติดตั้ง appserv และ การติดตั้ง wordpress บน appserv
การติดตั้ง appserv และ การติดตั้ง wordpress บน appservการติดตั้ง appserv และ การติดตั้ง wordpress บน appserv
การติดตั้ง appserv และ การติดตั้ง wordpress บน appservChahoemsid Hutacharoen
 
Musafir hun yaaron prelimswith answers
Musafir hun yaaron prelimswith answersMusafir hun yaaron prelimswith answers
Musafir hun yaaron prelimswith answersyati_raj
 
Hist 141 panama & los angeles
Hist 141   panama & los angelesHist 141   panama & los angeles
Hist 141 panama & los angelesflip7rider
 
Prohibitions of Riba in Qura'n and Ahadith
Prohibitions of Riba in Qura'n and AhadithProhibitions of Riba in Qura'n and Ahadith
Prohibitions of Riba in Qura'n and AhadithMasoud A. Dar
 
Present continuous 2n ESO
Present continuous 2n ESOPresent continuous 2n ESO
Present continuous 2n ESOteacherhector
 
элективный курс по химии
элективный курс по химииэлективный курс по химии
элективный курс по химииloksal
 
WordBench ISHIKAWA
WordBench ISHIKAWAWordBench ISHIKAWA
WordBench ISHIKAWAMasayuki Abe
 

Viewers also liked (18)

презентация элективного курса по черчению
презентация элективного курса по черчениюпрезентация элективного курса по черчению
презентация элективного курса по черчению
 
Copyright crash course g salas
Copyright crash course g salasCopyright crash course g salas
Copyright crash course g salas
 
El primer condicional
El primer condicionalEl primer condicional
El primer condicional
 
David classic 2tone silver bentley slideshow911
David classic 2tone silver bentley slideshow911David classic 2tone silver bentley slideshow911
David classic 2tone silver bentley slideshow911
 
Copyright crash course part 4
Copyright crash course part 4Copyright crash course part 4
Copyright crash course part 4
 
My Favorite Movie
My Favorite MovieMy Favorite Movie
My Favorite Movie
 
Crash course observation lab
Crash course observation labCrash course observation lab
Crash course observation lab
 
Optimal Management on Startup Village
Optimal Management on Startup VillageOptimal Management on Startup Village
Optimal Management on Startup Village
 
Copyright crash course part 5
Copyright crash course part 5Copyright crash course part 5
Copyright crash course part 5
 
Education Focus Area
Education Focus AreaEducation Focus Area
Education Focus Area
 
การติดตั้ง appserv และ การติดตั้ง wordpress บน appserv
การติดตั้ง appserv และ การติดตั้ง wordpress บน appservการติดตั้ง appserv และ การติดตั้ง wordpress บน appserv
การติดตั้ง appserv และ การติดตั้ง wordpress บน appserv
 
Musafir hun yaaron prelimswith answers
Musafir hun yaaron prelimswith answersMusafir hun yaaron prelimswith answers
Musafir hun yaaron prelimswith answers
 
Hist 141 panama & los angeles
Hist 141   panama & los angelesHist 141   panama & los angeles
Hist 141 panama & los angeles
 
Prohibitions of Riba in Qura'n and Ahadith
Prohibitions of Riba in Qura'n and AhadithProhibitions of Riba in Qura'n and Ahadith
Prohibitions of Riba in Qura'n and Ahadith
 
Present continuous 2n ESO
Present continuous 2n ESOPresent continuous 2n ESO
Present continuous 2n ESO
 
элективный курс по химии
элективный курс по химииэлективный курс по химии
элективный курс по химии
 
WordBench ISHIKAWA
WordBench ISHIKAWAWordBench ISHIKAWA
WordBench ISHIKAWA
 
Present simple
Present simplePresent simple
Present simple
 

More from Hiroaki Kubota

Db tech showcase2015 how to replicate between clusters
Db tech showcase2015 how to replicate between clustersDb tech showcase2015 how to replicate between clusters
Db tech showcase2015 how to replicate between clustersHiroaki Kubota
 
DB tech showcase: 噂のMongoDBその用途は?
DB tech showcase: 噂のMongoDBその用途は?DB tech showcase: 噂のMongoDBその用途は?
DB tech showcase: 噂のMongoDBその用途は?Hiroaki Kubota
 
MongoDBで自然言語処理
MongoDBで自然言語処理MongoDBで自然言語処理
MongoDBで自然言語処理Hiroaki Kubota
 
MongoDBJP 納涼もんご祭り
MongoDBJP 納涼もんご祭りMongoDBJP 納涼もんご祭り
MongoDBJP 納涼もんご祭りHiroaki Kubota
 
Mongo ghostsync and slaveDelay (Japanease)
Mongo ghostsync and slaveDelay (Japanease)Mongo ghostsync and slaveDelay (Japanease)
Mongo ghostsync and slaveDelay (Japanease)Hiroaki Kubota
 
Mongo ghostsync and slaveDelay
Mongo ghostsync and slaveDelayMongo ghostsync and slaveDelay
Mongo ghostsync and slaveDelayHiroaki Kubota
 
C10K on Mongo's sharding
C10K on Mongo's shardingC10K on Mongo's sharding
C10K on Mongo's shardingHiroaki Kubota
 

More from Hiroaki Kubota (9)

Db tech showcase2015 how to replicate between clusters
Db tech showcase2015 how to replicate between clustersDb tech showcase2015 how to replicate between clusters
Db tech showcase2015 how to replicate between clusters
 
DB tech showcase: 噂のMongoDBその用途は?
DB tech showcase: 噂のMongoDBその用途は?DB tech showcase: 噂のMongoDBその用途は?
DB tech showcase: 噂のMongoDBその用途は?
 
MongoDBで自然言語処理
MongoDBで自然言語処理MongoDBで自然言語処理
MongoDBで自然言語処理
 
MongoDBJP 納涼もんご祭り
MongoDBJP 納涼もんご祭りMongoDBJP 納涼もんご祭り
MongoDBJP 納涼もんご祭り
 
Mongo ghostsync and slaveDelay (Japanease)
Mongo ghostsync and slaveDelay (Japanease)Mongo ghostsync and slaveDelay (Japanease)
Mongo ghostsync and slaveDelay (Japanease)
 
Mongo ghostsync and slaveDelay
Mongo ghostsync and slaveDelayMongo ghostsync and slaveDelay
Mongo ghostsync and slaveDelay
 
C10K on Mongo's sharding
C10K on Mongo's shardingC10K on Mongo's sharding
C10K on Mongo's sharding
 
MongoTokyo
MongoTokyoMongoTokyo
MongoTokyo
 
Albatross
AlbatrossAlbatross
Albatross
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Why mincore() returns different value of stat ?

  • 3. Interior of a process User-land Kernel-land virtual mem physical mem mapped area mmap() 1MB mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 4. User-land Kernel-land virtual mem physical mem mapped area page 1 page 2 page 3 page 4 page 5 page 6 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 5. Major page fault User-land Kernel-land virtual mem physical mem mapped area touch page 1 page 2 page 3 page 4 page 5 page 6 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 6. Major page fault User-land Kernel-land virtual mem physical mem mapped area touch page 1 page 2 page 2 page 3 Read page from disk page 4 page 5 page 6 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 7. Major page fault User-land Kernel-land virtual mem physical mem mapped area Associate physical memory with virtual memory touch page 1 page 2 page 2 page 3 page 4 page 5 page 6 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 8. User-land Kernel-land virtual mem physical mem mapped area page 1 page 2 touch page 2 page 3 page 3 page 4 page 5 page 6 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 9. User-land Kernel-land virtual mem physical mem mapped area page 1 page 2 page 2 page 3 page 3 page 6 page 4 page 7 page 5 page 1 page 6 page 4 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 10. swap out (Just image , not actual)
  • 11. User-land Kernel-land virtual mem physical mem mapped area page 1 page 2 page 2 page 3 page 3 page 6 touch page 4 page 7 page 5 page 1 page 6 page 4 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 12. User-land Kernel-land virtual mem physical mem mapped area page 1 page 2 page 2 page 3 page 3 page 6 touch page 4 page 7 page 5 page 1 page 6 page 4 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 13. User-land Kernel-land virtual mem physical mem mapped area page 1 page 2 page 3 page 3 page 6 touch page 4 page 7 page 5 page 1 page 6 page 4 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 14. User-land Kernel-land virtual mem physical mem mapped area page 1 page 5 page 2 page 3 page 3 page 6 touch page 4 page 7 page 5 page 1 page 6 page 4 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 16. Old process User-land Kernel-land virtual mem physical mem mapped area page 1 page 5 page 2 page 3 page 3 page 6 page 4 page 7 page 5 page 1 page 6 page 4 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 17. Kill process Nothing Kernel-land physical mem page 5 page 3 page 6 page 7 page 1 page 4 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 18. New process User-land Kernel-land virtual mem physical mem page 5 page 3 page 6 page 7 page 1 page 4 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 19. User-land Kernel-land virtual mem physical mem mapped area page 1 page 5 page 2 page 3 page 3 page 6 page 4 page 7 page 5 page 1 page 6 page 4 page 7 mmap() 1MB page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 20. User-land Kernel-land virtual mem physical mem mapped area page 1 Actually, some pages are page 5 page 3 page 2 page 3 on memory page 6 page 4 page 7 page 5 page 1 page 6 page 4 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 21. Minor page fault User-land Kernel-land virtual mem physical mem mapped area ONLY associate physical page 1 memory with virtual memory page 5 page 2 page 3 page 3 page 6 touch page 4 page 7 page 5 page 1 page 6 page 4 page 7 page 256 mapped file page 1 used by page 2 page 3 FS others page 4 page 5 page 6 page 7 page 256
  • 23. User-land Kernel-land virtual mem physical mem top mapped area /proc/<pid>/smaps /proc/<pid>/statm page 1 PTE VMA page 5 : page 2 page 3 page 3 page 6 page 4 page 7 page 5 page 1 page 6 page 4 page 7 VIRT(virtual) page 256 RES(resident) mapped file page 1 used by SHR page 2 FS others page 3 page 4 page 5 mincore() page 6 page 7 page 256
  • 25. fs/proc/task_mmu.c#L447 mm/mincore.c#L108 static void smaps_pte_entry(pte_t ptent, unsigned long addr, static void mincore_pte_range(struct vm_area_struct *vma, unsigned long ptent_size, struct mm_walk pmd_t *pmd, *walk) unsigned long addr, unsigned long end, { unsigned char *vec) struct mem_size_stats *mss = walk->private; { struct vm_area_struct *vma = mss->vma; unsigned long next; pgoff_t pgoff = linear_page_index(vma, addr); spinlock_t *ptl; struct page *page = NULL; pte_t *ptep; int mapcount; ptep = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); if (pte_present(ptent)) { do { page = vm_normal_page(vma, addr, ptent); pte_t pte = *ptep; } else if (is_swap_pte(ptent)) { pgoff_t pgoff; swp_entry_t swpent = pte_to_swp_entry(ptent); next = addr + PAGE_SIZE; if (!non_swap_entry(swpent)) if (pte_none(pte)) mss->swap += ptent_size; mincore_unmapped_range(vma, addr, next, vec); else if (is_migration_entry(swpent)) else if (pte_present(pte)) page = migration_entry_to_page(swpent); *vec = 1; } else if (pte_file(ptent)) { else if (pte_file(pte)) { if (pte_to_pgoff(ptent) != pgoff) pgoff = pte_to_pgoff(pte); mss->nonlinear += ptent_size; *vec = mincore_page(vma->vm_file->f_mapping, pgoff); } } else { /* pte is a swap entry */ swp_entry_t entry = pte_to_swp_entry(pte); if (!page) : return; : if (PageAnon(page)) mss->anonymous += ptent_size; if (page->index != pgoff) mss->nonlinear += ptent_size; mss->resident += ptent_size; : :