kernel/vm.c
void
kfreewalk(pagetable_t kpt)
{
  for (int i = 0; i < 512; i++) {
    pte_t pte = kpt[i];
    if ((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0) {
      kfreewalk((pagetable_t) PTE2PA(pte));
      kpt[i] = 0;
    } else if (pte & PTE_V) {
      break;
    }
  }
  kfree((void *) kpt);
}
// only free page table, not physical pages
only free page table, not physical pages
only free page table not physical pages
void
kfreewalk(pagetable_t kpt)
{
  for (int i = 0; i < 512; i++) {
    pte_t pte = kpt[i];
    if ((pte & PTE_V) && (pte & (PTE_R|PTE_W|PTE_X)) == 0) {
      kfreewalk((pagetable_t) PTE2PA(pte));
      kpt[i] = 0;
    } else if (pte & PTE_V) {
      break;
    }
  }
  kfree((void *) kpt);
}
void kfreewalk ( pagetable_t kpt ) { for ( int i = 0 ; i < 512 ; i ++ ) { pte_t pte = kpt [ i ] ; if ( ( pte & PTE_V ) && ( pte & ( PTE_R | PTE_W | PTE_X ) ) == 0 ) { kfreewalk ( ( pagetable_t ) PTE2PA ( pte ) ) ; kpt [ i ] = 0 ; } else if ( pte & PTE_V ) { break ; } } kfree ( ( void * ) kpt ) ; }
only free page table, not physical pages
only free page table not physical pages