SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler 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;
    :
    :

Mais conteúdo relacionado

Destaque

презентация элективного курса по черчению
презентация элективного курса по черчениюпрезентация элективного курса по черчению
презентация элективного курса по черчению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
 

Destaque (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
 

Mais de 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
 

Mais de 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
 

Último

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 

Último (20)

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 

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; : :