sysinfo: support basic entries
Change-Id: I27f3e55058cc29f895831a1dddfafbc8585746a5 refs: #1389
This commit is contained in:
@@ -56,6 +56,24 @@ rusage_total_memory_add(unsigned long size)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
rusage_get_total_memory()
|
||||
{
|
||||
return rusage.total_memory;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
rusage_get_free_memory()
|
||||
{
|
||||
return rusage.total_memory - rusage.total_memory_usage;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
rusage_get_usage_memory()
|
||||
{
|
||||
return rusage.total_memory_usage;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rusage_rss_add(unsigned long size)
|
||||
{
|
||||
@@ -399,6 +417,24 @@ rusage_rss_add(unsigned long size)
|
||||
{
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
rusage_get_total_memory()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
rusage_get_free_memory()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
rusage_get_usage_memory()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rusage_rss_sub(unsigned long size)
|
||||
{
|
||||
|
||||
@@ -443,6 +443,22 @@ struct rusage {
|
||||
long ru_nivcsw;
|
||||
};
|
||||
|
||||
struct sysinfo {
|
||||
long uptime; /* Seconds since boot */
|
||||
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
unsigned long totalram; /* Total usable main memory size */
|
||||
unsigned long freeram; /* Available memory size */
|
||||
unsigned long sharedram; /* Amount of shared memory */
|
||||
unsigned long bufferram; /* Memory used by buffers */
|
||||
unsigned long totalswap; /* Total swap space size */
|
||||
unsigned long freeswap; /* swap space still available */
|
||||
unsigned short procs; /* Number of current processes */
|
||||
unsigned long totalhigh; /* Total high memory size */
|
||||
unsigned long freehigh; /* Available high memory size */
|
||||
unsigned int mem_unit; /* Memory unit size in bytes */
|
||||
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding for libc5 */
|
||||
};
|
||||
|
||||
extern void terminate(int, int);
|
||||
|
||||
struct tod_data_s {
|
||||
|
||||
@@ -6708,6 +6708,27 @@ SYSCALL_DECLARE(getrusage)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYSCALL_DECLARE(sysinfo)
|
||||
{
|
||||
struct sysinfo *sysinfo = (struct sysinfo *)ihk_mc_syscall_arg0(ctx);
|
||||
struct sysinfo __sysinfo;
|
||||
int ret = 0;
|
||||
|
||||
memset(&__sysinfo, '\0', sizeof(struct sysinfo));
|
||||
|
||||
__sysinfo.totalram = rusage_get_total_memory();
|
||||
__sysinfo.freeram = rusage_get_free_memory();
|
||||
__sysinfo.mem_unit = 1; // always one unit for McKernel
|
||||
|
||||
if (copy_to_user(sysinfo, &__sysinfo, sizeof(struct sysinfo))) {
|
||||
ret = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern int ptrace_traceme(void);
|
||||
extern void set_single_step(struct thread *thread);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user