mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 19:34:43 +01:00
vm_phys: Add a sysctl to dump registered fictitious memory ranges
I've wanted this a couple of times in the past. Save the memattr in the fictitious memory segment structure so that we can report it from the sysctl handler, and add conversion routines for each platform. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D58283
This commit is contained in:
1 parent
cbd442efe8
commit
a7e483ee14
7 files changed
+171
-2
No files matched your search
@@ -43,4 +43,27 @@
|
||||
#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
|
||||
#define VM_MEMATTR_DEVICE VM_MEMATTR_UNCACHEABLE
|
||||
|
||||
#ifdef _KERNEL
|
||||
static inline const char *
|
||||
vm_memattr_name(vm_memattr_t memattr)
|
||||
{
|
||||
switch (memattr) {
|
||||
case VM_MEMATTR_UNCACHEABLE:
|
||||
return ("uncacheable");
|
||||
case VM_MEMATTR_WRITE_COMBINING:
|
||||
return ("write-combining");
|
||||
case VM_MEMATTR_WRITE_THROUGH:
|
||||
return ("write-through");
|
||||
case VM_MEMATTR_WRITE_PROTECTED:
|
||||
return ("write-protected");
|
||||
case VM_MEMATTR_WRITE_BACK:
|
||||
return ("write-back");
|
||||
case VM_MEMATTR_WEAK_UNCACHEABLE:
|
||||
return ("weak-uncacheable");
|
||||
default:
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_MACHINE_VM_H_ */
|
||||
@@ -41,6 +41,25 @@
|
||||
/* Don't export aliased VM_MEMATTR to userland */
|
||||
#define VM_MEMATTR_WRITE_COMBINING VM_MEMATTR_WRITE_THROUGH /* for DRM */
|
||||
#define VM_MEMATTR_WRITE_BACK VM_MEMATTR_WB_WA /* for DRM */
|
||||
|
||||
static inline const char *
|
||||
vm_memattr_name(vm_memattr_t memattr)
|
||||
{
|
||||
switch (memattr) {
|
||||
case VM_MEMATTR_WB_WA:
|
||||
return ("write-back, write-allocate");
|
||||
case VM_MEMATTR_NOCACHE:
|
||||
return ("uncacheable");
|
||||
case VM_MEMATTR_DEVICE:
|
||||
return ("device");
|
||||
case VM_MEMATTR_SO:
|
||||
return ("strongly-ordered");
|
||||
case VM_MEMATTR_WRITE_THROUGH:
|
||||
return ("write-through");
|
||||
default:
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_MACHINE_VM_H_ */
|
||||
+23
-2
@@ -39,11 +39,32 @@
|
||||
#define VM_MEMATTR_DEVICE VM_MEMATTR_DEVICE_nGnRE
|
||||
#define VM_MEMATTR_DEVICE_NP VM_MEMATTR_DEVICE_nGnRnE
|
||||
|
||||
#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
|
||||
|
||||
#ifdef _KERNEL
|
||||
/* If defined vmstat will try to use both of these in a switch statement */
|
||||
#define VM_MEMATTR_WRITE_COMBINING VM_MEMATTR_WRITE_THROUGH
|
||||
|
||||
static inline const char *
|
||||
vm_memattr_name(vm_memattr_t memattr)
|
||||
{
|
||||
switch (memattr) {
|
||||
case VM_MEMATTR_DEVICE_nGnRnE:
|
||||
return ("device-nGnRnE");
|
||||
case VM_MEMATTR_UNCACHEABLE:
|
||||
return ("uncacheable");
|
||||
case VM_MEMATTR_WRITE_BACK:
|
||||
return ("write-back");
|
||||
case VM_MEMATTR_WRITE_THROUGH:
|
||||
return ("write-through");
|
||||
case VM_MEMATTR_DEVICE_nGnRE:
|
||||
return ("device-nGnRE");
|
||||
case VM_MEMATTR_TAGGED:
|
||||
return ("tagged");
|
||||
default:
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
|
||||
|
||||
#endif /* !_MACHINE_VM_H_ */
|
||||
@@ -43,4 +43,27 @@
|
||||
#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
|
||||
#define VM_MEMATTR_DEVICE VM_MEMATTR_UNCACHEABLE
|
||||
|
||||
#ifdef _KERNEL
|
||||
static inline const char *
|
||||
vm_memattr_name(vm_memattr_t memattr)
|
||||
{
|
||||
switch (memattr) {
|
||||
case VM_MEMATTR_UNCACHEABLE:
|
||||
return ("uncacheable");
|
||||
case VM_MEMATTR_WRITE_COMBINING:
|
||||
return ("write-combining");
|
||||
case VM_MEMATTR_WRITE_THROUGH:
|
||||
return ("write-through");
|
||||
case VM_MEMATTR_WRITE_PROTECTED:
|
||||
return ("write-protected");
|
||||
case VM_MEMATTR_WRITE_BACK:
|
||||
return ("write-back");
|
||||
case VM_MEMATTR_WEAK_UNCACHEABLE:
|
||||
return ("weak-uncacheable");
|
||||
default:
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_MACHINE_VM_H_ */
|
||||
@@ -42,4 +42,29 @@
|
||||
|
||||
#define VM_MEMATTR_DEVICE VM_MEMATTR_DEFAULT
|
||||
|
||||
#ifdef _KERNEL
|
||||
static inline const char *
|
||||
vm_memattr_name(vm_memattr_t memattr)
|
||||
{
|
||||
switch (memattr) {
|
||||
case VM_MEMATTR_DEFAULT:
|
||||
return ("default");
|
||||
case VM_MEMATTR_UNCACHEABLE:
|
||||
return ("uncacheable");
|
||||
case VM_MEMATTR_CACHEABLE:
|
||||
return ("cacheable");
|
||||
case VM_MEMATTR_WRITE_COMBINING:
|
||||
return ("write-combining");
|
||||
case VM_MEMATTR_WRITE_BACK:
|
||||
return ("write-back");
|
||||
case VM_MEMATTR_WRITE_THROUGH:
|
||||
return ("write-through");
|
||||
case VM_MEMATTR_PREFETCHABLE:
|
||||
return ("prefetchable");
|
||||
default:
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_MACHINE_VM_H_ */
|
||||
@@ -38,4 +38,21 @@
|
||||
#define VM_MEMATTR_LAST VM_MEMATTR_DEVICE
|
||||
#define VM_MEMATTR_TOTAL (VM_MEMATTR_LAST + 1)
|
||||
|
||||
#ifdef _KERNEL
|
||||
static inline const char *
|
||||
vm_memattr_name(vm_memattr_t memattr)
|
||||
{
|
||||
switch (memattr) {
|
||||
case VM_MEMATTR_PMA:
|
||||
return ("write-back");
|
||||
case VM_MEMATTR_UNCACHEABLE:
|
||||
return ("uncacheable");
|
||||
case VM_MEMATTR_DEVICE:
|
||||
return ("device");
|
||||
default:
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_MACHINE_VM_H_ */
|
||||
@@ -108,6 +108,7 @@ struct vm_phys_fictitious_seg {
|
||||
vm_paddr_t start;
|
||||
vm_paddr_t end;
|
||||
vm_page_t first_page;
|
||||
vm_memattr_t memattr;
|
||||
};
|
||||
|
||||
RB_GENERATE_STATIC(fict_tree, vm_phys_fictitious_seg, node,
|
||||
@@ -172,6 +173,12 @@ SYSCTL_OID(_vm, OID_AUTO, phys_segs,
|
||||
sysctl_vm_phys_segs, "A",
|
||||
"Phys Seg Info");
|
||||
|
||||
static int sysctl_vm_phys_fictitious_segs(SYSCTL_HANDLER_ARGS);
|
||||
SYSCTL_OID(_vm, OID_AUTO, phys_fictitious_segs,
|
||||
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
|
||||
sysctl_vm_phys_fictitious_segs, "A",
|
||||
"Fictitious Phys Seg Info");
|
||||
|
||||
#ifdef NUMA
|
||||
static int sysctl_vm_phys_locality(SYSCTL_HANDLER_ARGS);
|
||||
SYSCTL_OID(_vm, OID_AUTO, phys_locality,
|
||||
@@ -341,6 +348,39 @@ sysctl_vm_phys_segs(SYSCTL_HANDLER_ARGS)
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
sysctl_vm_phys_fictitious_segs(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct sbuf sbuf;
|
||||
struct vm_phys_fictitious_seg *seg;
|
||||
int error;
|
||||
|
||||
error = sysctl_wire_old_buffer(req, 0);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
sbuf_new_for_sysctl(&sbuf, NULL, 128, req);
|
||||
rw_rlock(&vm_phys_fictitious_reg_lock);
|
||||
RB_FOREACH(seg, fict_tree, &vm_phys_fictitious_tree) {
|
||||
const char *name;
|
||||
char buf[8];
|
||||
|
||||
sbuf_printf(&sbuf, "\nstart: %#jx\n",
|
||||
(uintmax_t)seg->start);
|
||||
sbuf_printf(&sbuf, "end: %#jx\n",
|
||||
(uintmax_t)seg->end);
|
||||
name = vm_memattr_name(seg->memattr);
|
||||
if (name == NULL) {
|
||||
(void)snprintf(buf, sizeof(buf), "0x%02x", seg->memattr);
|
||||
name = buf;
|
||||
}
|
||||
sbuf_printf(&sbuf, "attr: %s\n", name);
|
||||
}
|
||||
rw_runlock(&vm_phys_fictitious_reg_lock);
|
||||
error = sbuf_finish(&sbuf);
|
||||
sbuf_delete(&sbuf);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return affinity, or -1 if there's no affinity information.
|
||||
*/
|
||||
@@ -1155,6 +1195,7 @@ alloc:
|
||||
seg->start = start;
|
||||
seg->end = end;
|
||||
seg->first_page = fp;
|
||||
seg->memattr = memattr;
|
||||
|
||||
rw_wlock(&vm_phys_fictitious_reg_lock);
|
||||
RB_INSERT(fict_tree, &vm_phys_fictitious_tree, seg);
|
||||
|
||||
Reference in new issue
Block a user