kmalloc cache refactor and pre-alloc in HFI1 open()
This commit is contained in:
36
kernel/mem.c
36
kernel/mem.c
@ -2615,6 +2615,27 @@ int ihk_mc_get_mem_user_page(void *arg0, page_table_t pt, pte_t *ptep, void *pga
|
|||||||
/*
|
/*
|
||||||
* Generic lockless kmalloc cache.
|
* Generic lockless kmalloc cache.
|
||||||
*/
|
*/
|
||||||
|
void kmalloc_cache_prealloc(struct kmalloc_cache_header *cache,
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
struct kmalloc_cache_header *first;
|
||||||
|
int i;
|
||||||
|
kprintf("%s: pre-allocating for 0x%lx...\n",
|
||||||
|
__FUNCTION__, cache);
|
||||||
|
|
||||||
|
for (i = 0; i < 128; ++i) {
|
||||||
|
first = (struct kmalloc_cache_header *)
|
||||||
|
kmalloc(size, IHK_MC_AP_NOWAIT);
|
||||||
|
|
||||||
|
if (!first) {
|
||||||
|
kprintf("%s: ERROR: allocating cache element\n", __FUNCTION__);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
kmalloc_cache_free(cache, first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void *kmalloc_cache_alloc(struct kmalloc_cache_header *cache,
|
void *kmalloc_cache_alloc(struct kmalloc_cache_header *cache,
|
||||||
size_t size)
|
size_t size)
|
||||||
{
|
{
|
||||||
@ -2633,20 +2654,7 @@ retry:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int i;
|
kmalloc_cache_prealloc(cache, size);
|
||||||
kprintf("%s: cache empty, allocating ...\n", __FUNCTION__);
|
|
||||||
for (i = 0; i < 100; ++i) {
|
|
||||||
first = (struct kmalloc_cache_header *)
|
|
||||||
kmalloc(size, IHK_MC_AP_NOWAIT);
|
|
||||||
|
|
||||||
if (!first) {
|
|
||||||
kprintf("%s: ERROR: allocating cache element\n", __FUNCTION__);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
kmalloc_cache_free(cache, first);
|
|
||||||
}
|
|
||||||
|
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -483,11 +483,14 @@ long do_syscall(struct syscall_request *req, int cpu, int pid)
|
|||||||
if (req->number == __NR_open && rc > 0) {
|
if (req->number == __NR_open && rc > 0) {
|
||||||
if (res.private_data &&
|
if (res.private_data &&
|
||||||
!strncmp((const char *)req->args[0], "/dev/hfi", 8)) {
|
!strncmp((const char *)req->args[0], "/dev/hfi", 8)) {
|
||||||
|
extern void hfi1_txreq_prealloc(void);
|
||||||
|
|
||||||
thread->proc->fd_priv_table[rc] = res.private_data;
|
thread->proc->fd_priv_table[rc] = res.private_data;
|
||||||
kprintf("%s: PID: %d, open fd: %d, filename: "
|
kprintf("%s: PID: %d, open fd: %d, filename: "
|
||||||
"%s, private_data: 0x%lx\n",
|
"%s, private_data: 0x%lx\n",
|
||||||
__FUNCTION__, thread->proc->pid,
|
__FUNCTION__, thread->proc->pid,
|
||||||
rc, req->args[0], res.private_data);
|
rc, req->args[0], res.private_data);
|
||||||
|
hfi1_txreq_prealloc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1216,6 +1216,12 @@ static inline u32 get_lrh_len(struct hfi1_pkt_header hdr, u32 len)
|
|||||||
|
|
||||||
struct kmalloc_cache_header txreq_cache = {NULL};
|
struct kmalloc_cache_header txreq_cache = {NULL};
|
||||||
|
|
||||||
|
|
||||||
|
void hfi1_txreq_prealloc(void)
|
||||||
|
{
|
||||||
|
kmalloc_cache_prealloc(&txreq_cache, sizeof(struct user_sdma_txreq));
|
||||||
|
}
|
||||||
|
|
||||||
static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
|
static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
|
||||||
{
|
{
|
||||||
int ret = 0, count;
|
int ret = 0, count;
|
||||||
|
|||||||
Reference in New Issue
Block a user