• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
libtop.c: two questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

libtop.c: two questions


  • Subject: libtop.c: two questions
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Sun, 29 Apr 2012 06:55:02 +0700

Reading <http://www.opensource.apple.com/source/top/top-73/libtop.c> I got two questions:


1.
static void
libtop_p_fw_scan
(task_t task, mach_vm_address_t region_base, mach_vm_size_t region_size) {
[...]
kr = mach_vm_region_recurse(task, &addr, &size, &depth,(vm_region_recurse_info_t)&sinfo, &count);
[...]
switch (sinfo.share_mode) {
	case SM_SHARED:
	case SM_COW:
	case SM_TRUESHARED:
		if (sinfo.max_protection & VM_PROT_EXECUTE) {
			// CODE
			code += sinfo.pages_resident;
			tsamp.fw_count++;
		} else if (sinfo.max_protection & VM_PROT_WRITE) {
			// DATA
			data += sinfo.pages_resident;
		} else {
			// LINKEDIT
			linkedit += sinfo.pages_resident;
		}
		break;
}
[...]

But when I look at the results of mach_vm_region_recurse I find that protection/max_protection of:
__TEXT is r-x/r-x
__DATA, __OBJC have rw-/rwx
__LINKEDIT has r--/rwx

So the above code (which checks max_protection) either does make no sense, or I am misunderstanding something.


2.
In libtop_update_vm_regions (task_t task, libtop_pinfo_t* pinfo)
I see:
mach_vm_region(...)
case SM_PRIVATE:
	rprvt += info.private_pages_resident * pagesize;
	rprvt += info.shared_pages_resident * pagesize;

But looking at the results of mach_vm_region(VM_REGION_TOP_INFO) I see that while private_pages_resident, shared_pages_resident ≤ size, quite often private_pages_resident + shared_pages_resident > size.

Does this code really count rprvt correctly?


Kind regards,

Gerriet.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: libtop.c: two questions
      • From: "email@hidden" <email@hidden>
  • Prev by Date: Re: setting kernel shared memory on 10.7.3
  • Next by Date: Re: libtop.c: two questions
  • Previous by thread: Re: setting kernel shared memory on 10.7.3
  • Next by thread: Re: libtop.c: two questions
  • Index(es):
    • Date
    • Thread