Skip to content

Commit

Permalink
Implemented the x86_64 machdep->is_page_ptr() plugin function. If
Browse files Browse the repository at this point in the history
the kernel is configured with CONFIG_SPARSEMEM_VMEMMAP, the plugin
function optimizes the mem_section search, reducing the computation
effort and time consumed by commands that repeatedly call the
is_page_ptr() function on large-memory systems.
([email protected])
  • Loading branch information
Dave Anderson committed Mar 6, 2018
1 parent d586679 commit 4141373
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5133,6 +5133,7 @@ int vaddr_type(ulong, struct task_context *);
char *format_stack_entry(struct bt_info *bt, char *, ulong, ulong);
int in_user_stack(ulong, ulong);
int dump_inode_page(ulong);
ulong valid_section_nr(ulong);


/*
Expand Down
23 changes: 23 additions & 0 deletions x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static void x86_64_calc_phys_base(void);
static int x86_64_is_module_addr(ulong);
static int x86_64_is_kvaddr(ulong);
static int x86_64_is_uvaddr(ulong, struct task_context *);
static int x86_64_is_page_ptr(ulong, physaddr_t *);
static ulong *x86_64_kpgd_offset(ulong, int, int);
static ulong x86_64_upgd_offset(struct task_context *, ulong, int, int);
static ulong x86_64_upgd_offset_legacy(struct task_context *, ulong, int, int);
Expand Down Expand Up @@ -156,6 +157,7 @@ x86_64_init(int when)
{
case SETUP_ENV:
machdep->process_elf_notes = x86_process_elf_notes;
machdep->is_page_ptr = x86_64_is_page_ptr;
break;
case PRE_SYMTAB:
machdep->verify_symbol = x86_64_verify_symbol;
Expand Down Expand Up @@ -802,6 +804,7 @@ x86_64_dump_machdep_table(ulong arg)
fprintf(fp, " get_smp_cpus: x86_64_get_smp_cpus()\n");
fprintf(fp, " is_kvaddr: x86_64_is_kvaddr()\n");
fprintf(fp, " is_uvaddr: x86_64_is_uvaddr()\n");
fprintf(fp, " is_page_ptr: x86_64_is_page_ptr()\n");
fprintf(fp, " verify_paddr: x86_64_verify_paddr()\n");
fprintf(fp, " get_kvaddr_ranges: x86_64_get_kvaddr_ranges()\n");
fprintf(fp, " init_kernel_pgd: x86_64_init_kernel_pgd()\n");
Expand Down Expand Up @@ -1594,6 +1597,26 @@ x86_64_is_uvaddr(ulong addr, struct task_context *tc)
return (addr < USERSPACE_TOP);
}

static int
x86_64_is_page_ptr(ulong addr, physaddr_t *phys)
{
ulong pfn, nr;

if (IS_SPARSEMEM() && (machdep->flags & VMEMMAP) &&
(addr >= VMEMMAP_VADDR && addr <= VMEMMAP_END) &&
!((addr - VMEMMAP_VADDR) % SIZE(page))) {

pfn = (addr - VMEMMAP_VADDR) / SIZE(page);
nr = pfn_to_section_nr(pfn);
if (valid_section_nr(nr)) {
if (phys)
*phys = PTOB(pfn);
return TRUE;
}
}
return FALSE;
}

/*
* Find the kernel pgd entry..
* pgd = pgd_offset_k(addr);
Expand Down

0 comments on commit 4141373

Please sign in to comment.