Skip to content

Commit

Permalink
ihk_os_getrusage(): Compile LWK-specific results in mcctrl
Browse files Browse the repository at this point in the history
1. User asks mcctrl for the result via ihk_os_getrusage() with passing void *
2. mcctrl compiles the results and passes them to the user
3. User interprets it by using the type defined in the LWK-specific header
  • Loading branch information
masamichitakagi committed Sep 14, 2017
1 parent 07b918c commit 443c6e6
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 155 deletions.
3 changes: 3 additions & 0 deletions cokernel/smp/x86/bootparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ struct smp_boot_param {
unsigned long monitor;
unsigned long monitor_size;

unsigned long rusage;
unsigned long rusage_size;

unsigned long nmi_mode_addr;

unsigned long dma_address;
Expand Down
8 changes: 8 additions & 0 deletions cokernel/smp/x86/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ int ihk_set_monitor(unsigned long addr, unsigned long size)
return 0;
}

int ihk_set_rusage(unsigned long addr, unsigned long size)
{
boot_param->rusage = addr;
boot_param->rusage_size = size;

return 0;
}

int ihk_set_nmi_mode_addr(unsigned long addr)
{
boot_param->nmi_mode_addr = addr;
Expand Down
48 changes: 43 additions & 5 deletions linux/core/host_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,39 @@ setup_monitor(struct ihk_host_linux_os_data *data)
data->monitor_len = size;
}

static void
setup_rusage(struct ihk_host_linux_os_data *data)
{
unsigned long rpa;
unsigned long pa;
unsigned long size;
unsigned long psize;

if (data->rusage)
return;

if (__ihk_os_get_special_addr(data, IHK_SPADDR_RUSAGE, &rpa, &size)) {
dprintf("get_special_addr: failed.\n");
return;
}

psize = ((size + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE;
pa = __ihk_os_map_memory(data, rpa, psize);

#ifdef CONFIG_MIC
if ((long)pa <= 0) {
return;
}

data->rusage = ioremap_nocache(pa, psize);
#else
data->rusage = ihk_device_map_virtual(data->dev_data, pa, psize,
NULL, 0);
#endif
data->rusage_pa = pa;
data->rusage_len = size;
}

static int __ihk_os_status(struct ihk_host_linux_os_data *data,
char __user *buf)
{
Expand Down Expand Up @@ -763,8 +796,7 @@ static int __ihk_os_thaw(struct ihk_host_linux_os_data *data)
return error;
}

static int
__ihk_os_get_usage(struct ihk_host_linux_os_data *data, unsigned long arg)
static int __ihk_os_get_usage(struct ihk_host_linux_os_data *data, unsigned long arg)
{
struct ihk_os_monitor *__user buf;

Expand All @@ -781,8 +813,7 @@ __ihk_os_get_usage(struct ihk_host_linux_os_data *data, unsigned long arg)
return 0;
}

static int
__ihk_os_get_cpu_usage(struct ihk_host_linux_os_data *data, unsigned long arg)
static int __ihk_os_get_cpu_usage(struct ihk_host_linux_os_data *data, unsigned long arg)
{
struct ihk_os_cpu_monitor *__user buf;
int size;
Expand Down Expand Up @@ -1006,7 +1037,6 @@ static long ihk_host_os_ioctl(struct file *file, unsigned int request,
dkprintf("__ihk_os_get_cpu_usage (ret=%d)\n",ret);
break;


default:
if (request >= IHK_OS_DEBUG_START &&
request <= IHK_OS_DEBUG_END) {
Expand Down Expand Up @@ -1975,6 +2005,13 @@ struct ihk_cpu_info *ihk_os_get_cpu_info(ihk_os_t os)
return __ihk_os_get_cpu_info(os);
}

void *ihk_os_get_rusage(ihk_os_t ihk_os)
{
struct ihk_host_linux_os_data *os = ihk_os;
setup_rusage(os);
return os->rusage;
}

ihk_device_t ihk_os_to_dev(ihk_os_t os)
{
return ((struct ihk_host_linux_os_data *)os)->dev_data;
Expand Down Expand Up @@ -2329,3 +2366,4 @@ EXPORT_SYMBOL(ihk_device_linux_cpu_to_hw_id);
EXPORT_SYMBOL(ihk_host_register_os_notifier);
EXPORT_SYMBOL(ihk_host_deregister_os_notifier);
EXPORT_SYMBOL(ihk_os_eventfd);
EXPORT_SYMBOL(ihk_os_get_rusage);
6 changes: 6 additions & 0 deletions linux/core/host_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ struct ihk_host_linux_os_data {
/** \brief Host physical address to monitor */
unsigned long monitor_pa;

void *rusage;
/** \brief Size of the rusage */
unsigned long rusage_len;
/** \brief Host physical address to rusage */
unsigned long rusage_pa;

/** \brief Flag whether the IKC is already initialized or not */
int ikc_initialized;
/** \brief Lock for the channel list */
Expand Down
7 changes: 7 additions & 0 deletions linux/driver/smp/smp-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,13 @@ static int smp_ihk_os_get_special_addr(ihk_os_t ihk_os, void *priv,
return 0;
}
break;
case IHK_SPADDR_RUSAGE:
if (os->param->rusage) {
*addr = os->param->rusage;
*size = os->param->rusage_size;
return 0;
}
break;
case IHK_SPADDR_NMI_MODE:
if (os->param->nmi_mode_addr) {
*addr = os->param->nmi_mode_addr;
Expand Down
8 changes: 4 additions & 4 deletions linux/include/ihk/kmsg.h → linux/include/ihk/ihk_debug.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* \file ihk_OS_KMSG.h
* \file ihk_debug.h
* \brief
* IHK-Master: OS status
* \author Taku Shimosawa <[email protected]> \par
* Copyright (C) 2011-2012 Taku Shimosawa <[email protected]>
*/
#ifndef IHK_OS_KMSG_H_INCLUDED
#define IHK_OS_KMSG_H_INCLUDED
#ifndef IHK_DEBUG_H_INCLUDED
#define IHK_DEBUG_H_INCLUDED

#define IHK_KMSG_SIZE (8*1024)

#endif /* !defined(IHK_OS_KMSG_H_INCLUDED) */
#endif /* !defined(IHK_DEBUG_H_INCLUDED) */
9 changes: 6 additions & 3 deletions linux/include/ihk/ihk_host_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

#include <ihk/archdefs.h>
#include <ihk/status.h>
#include <ihk/monitor.h>
#include <ihk/kmsg.h>
#include <ihk/ihk_monitor.h>
#include <ihk/ihk_debug.h>

/** \brief Status of a manycore device */
enum ihk_cpu_status {
Expand All @@ -29,7 +29,8 @@ enum ihk_special_addr_type {
IHK_SPADDR_MIKC_QUEUE_RECV = 2,
IHK_SPADDR_MIKC_QUEUE_SEND = 3,
IHK_SPADDR_MONITOR = 4,
IHK_SPADDR_NMI_MODE = 5,
IHK_SPADDR_RUSAGE = 5,
IHK_SPADDR_NMI_MODE = 6,
};

/** \brief Type of an IHK device */
Expand Down Expand Up @@ -649,6 +650,8 @@ struct ihk_cpu_info {
struct ihk_mem_info *ihk_os_get_memory_info(ihk_os_t os);
/** \brief Get information of CPU cores which the OS kernel uses */
struct ihk_cpu_info *ihk_os_get_cpu_info(ihk_os_t os);
/** \brief Get address of memory area to which OS-global rerouce usage is recorded */
void *ihk_os_get_rusage(ihk_os_t os);

/** \brief Denote to allocate all the available cpus */
#define IHK_RESOURCE_CPU_ALL -1
Expand Down
5 changes: 3 additions & 2 deletions linux/include/ihk/ihk_host_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#define __HEADER_IHK_HOST_USER_H

#include <ihk/status.h>
#include <ihk/monitor.h>
#include <ihk/kmsg.h>
#include <ihk/ihk_monitor.h>
#include <ihk/ihk_debug.h>

#define IHK_DEVICE_CREATE_OS 0x112900
#define IHK_DEVICE_DESTROY_OS 0x112901
Expand Down Expand Up @@ -69,6 +69,7 @@
#define IHK_OS_AUX_PERF_ENABLE 0x11290103
#define IHK_OS_AUX_PERF_DISABLE 0x11290104
#define IHK_OS_AUX_PERF_DESTROY 0x11290105
#define IHK_OS_GETRUSAGE 0x11290106

#define FLAG_IHK_OS_SHUTDOWN_FORCE 0x40000000

Expand Down
34 changes: 34 additions & 0 deletions linux/include/ihk/ihk_monitor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* \file ihk_monitor.h
* \brief
* IHK-Master: OS status
* \author Tomoki Shirasawa <[email protected]> \par
* Copyright (C) 2017 Tomoki Shirasawa <[email protected]>
*/
#ifndef IHK_MONITOR_H_INCLUDED
#define IHK_MONITOR_H_INCLUDED

/** \brief IHK-Monitor */
struct ihk_os_cpu_monitor {
int status;
#define IHK_OS_MONITOR_NOT_BOOT 0
#define IHK_OS_MONITOR_IDLE 1
#define IHK_OS_MONITOR_USER 2
#define IHK_OS_MONITOR_KERNEL 3
#define IHK_OS_MONITOR_KERNEL_HEAVY 4
#define IHK_OS_MONITOR_KERNEL_OFFLOAD 5
#define IHK_OS_MONITOR_KERNEL_FREEZING 8
#define IHK_OS_MONITOR_KERNEL_FROZEN 9
#define IHK_OS_MONITOR_KERNEL_THAW 10
#define IHK_OS_MONITOR_PANIC 99
int status_bak;
unsigned long counter;
unsigned long ocounter;
};

struct ihk_os_monitor {
unsigned long num_processors;
unsigned long reserve[128];
struct ihk_os_cpu_monitor cpu[0]; /* clv[i].monitor = &cpu[i] */
};
#endif /* !defined(IHK_MONITOR_H_INCLUDED) */
9 changes: 9 additions & 0 deletions linux/include/ihk/ihklib_private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef IHKLIB_PRIVATE_H_INCLUDED
#define IHKLIB_PRIVATE_H_INCLUDED

struct getrusage_desc {
void* rusage;
size_t size_rusage;
};

#endif /* !defined(IHKLIB_PRIVATE_H_INCLUDED) */
55 changes: 0 additions & 55 deletions linux/include/ihk/monitor.h

This file was deleted.

Loading

0 comments on commit 443c6e6

Please sign in to comment.