提交 f089a081 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Merge branch 'scale-amd64' of git+ssh://amsterdam.csail.mit.edu/home/am0/6.828/xv6 into scale-amd64

......@@ -65,26 +65,36 @@ namespace std {
return static_cast<typename remove_reference<T>::type&&>(a);
}
class ios_base {};
class ostream : public ios_base {};
struct ostream { int next_width; };
extern ostream cout;
static inline
ostream& operator<<(ostream &s, const char *str) {
if (!str)
str = "(null)";
int len = strlen(str);
cprintf("%s", str);
while (len < s.next_width) {
cprintf(" ");
len++;
}
s.next_width = 0;
return s;
}
static inline
ostream& operator<<(ostream &s, u32 v) {
cprintf("%d", v);
return s;
char buf[32];
snprintf(buf, sizeof(buf), "%d", v);
return s << buf;
}
static inline
ostream& operator<<(ostream &s, u64 v) {
cprintf("%ld", v);
return s;
char buf[32];
snprintf(buf, sizeof(buf), "%ld", v);
return s << buf;
}
static inline
......@@ -94,7 +104,15 @@ namespace std {
static inline ostream& endl(ostream &s) { s << "\n"; return s; }
static inline ostream& left(ostream &s) { return s; }
static inline const char *setw(int n) { return ""; }
struct ssetw { int _n; };
static inline ssetw setw(int n) { return { n }; }
static inline
ostream& operator<<(ostream &s, const ssetw &sw) {
s.next_width = sw._n;
return s;
}
}
/* C++ runtime */
......
......@@ -307,6 +307,7 @@ void initnet(void);
void initsched(void);
void initlockstat(void);
void initwq(void);
void initsperf(void);
// other exported/imported functions
void cmain(u64 mbmagic, u64 mbaddr);
......
差异被折叠。
#pragma once
#include "scopedperf.hh"
extern scopedperf::ctrgroup_chain<scopedperf::tsc_ctr> *perfgroup;
......@@ -34,6 +34,7 @@ OBJS = \
rnd.o \
sampler.o \
sched.o \
sperf.o \
spinlock.o \
swtch.o \
string.o \
......
......@@ -17,6 +17,7 @@
#include <stdarg.h>
#include "fmt.hh"
#include <stddef.h>
#include "sperf.hh"
#define BACKSPACE 0x100
......@@ -285,6 +286,9 @@ consoleintr(int (*getc)(void))
case C('F'): // kmem stats
kmemprint();
break;
case C('Y'): // scopedperf stats
scopedperf::perfsum_base::printall();
break;
default:
if(c != 0 && input.e-input.r < INPUT_BUF){
c = (c == '\r') ? '\n' : c;
......
......@@ -63,6 +63,7 @@ __cxa_atexit(void (*f)(void*), void *p, void *d)
}
void *__dso_handle;
std::ostream std::cout;
namespace std {
......
......@@ -95,6 +95,7 @@ cmain(u64 mbmagic, u64 mbaddr)
initpci();
initnet();
initidle();
initsperf();
if (VERBOSE)
cprintf("ncpu %d %lu MHz\n", ncpu, cpuhz / 1000000);
......
#include "types.h"
#include "kernel.hh"
#include "cpu.hh"
#include "cpputil.hh"
#include "spinlock.h"
#include "sperf.hh"
using namespace scopedperf;
ctrgroup_chain<tsc_ctr> *perfgroup;
void
initsperf()
{
static tsc_ctr tsc;
perfgroup = new ctrgroup_chain<tsc_ctr>(&tsc);
}
......@@ -8,6 +8,7 @@
#include "proc.hh"
#include "cpu.hh"
#include "vm.hh"
#include "sperf.hh"
long
sys_fork(int flags)
......@@ -85,6 +86,8 @@ sys_uptime(void)
long
sys_map(uptr addr, u64 len)
{
ANON_REGION(__func__, perfgroup);
vmnode *vmn = new vmnode(PGROUNDUP(len) / PGSIZE);
if (vmn == 0)
return -1;
......@@ -100,6 +103,8 @@ sys_map(uptr addr, u64 len)
long
sys_unmap(uptr addr, u64 len)
{
ANON_REGION(__func__, perfgroup);
uptr align_addr = PGROUNDDOWN(addr);
uptr align_len = PGROUNDUP(addr + len) - align_addr;
if (myproc()->vmap->remove(align_addr, align_len) < 0)
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论