From: Gioh Kim <gioh.kim@lge.com>
To: linux-kernel@vger.kernel.org, kernel-forum@lge.com
Cc: Sinchul Jung <sinchul.jung@lge.com>
Subject: vzalloc과 kzalloc의 성능 차이
Date: Wed, 03 Dec 2014 11:20:19 +0900 [thread overview]
Message-ID: <547E7363.9060002@lge.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2327 bytes --]
GPU DDK는 특정 구조체의 메모리 할당을 vzalloc으로 하고 있습니다.
그 구조체는 크기가 몇백byte에서 16K까지 다양합니다.
프로파일 결과 vzalloc이 너무 느려서 kzalloc으로 바꿔볼까하는 생각이 들었습니다.
모든 vzalloc을 kzalloc으로 바꾸면 빨라질 수도 있겠지만
너무 큰 크기의 메모리 할당에 kzalloc을 쓰면 메모리 단편화도 커질것이고 low-mem도 없어질 것이고 등등의
문제가 생길것 같았습니다.
그래서 얼마정도 크기까지는 kzalloc을 써도 될까하는 고민을 하다가
그냥 2K부터 2K씩 증가하면서 kmalloc, kzalloc, vzalloc을 실행해봤습니다.
저는 그냥 kzalloc도 kmalloc이니까 vzalloc보다 빠를줄 알았습니다.
그런데 8K ~ 24K 구간에서는 kzalloc = vzalloc 이라는 결과가 나왔습니다.
즉 kzalloc이나 vzalloc이나 선형적으로 실행 시간이 증가하는 구간이 있는데
제 생각에는 memset(0)이 있어서 그런것 같습니다.
어떻게 생각하세요?
어쨌든 제 결론은 1페이지 이하의 할당에는 vzalloc을 kmalloc으로 바꿀 생각입니다.
그래도 1페이지 이하니까 메모리 단편화에는 영향이 없겠지요?
조언부탁드립니다.
ps
실험은 H15보드에서 커널만 부팅되고 webos등은 실행되지 않은
거의 로드가 없는 상황에서 진행되었습니다.
테스트 소스입니다.
#include <linux/device.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/cdev.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <asm/uaccess.h>
#include <linux/export.h>
#include <asm/io.h>
#include <linux/mm_types.h>
#include <linux/list.h>
#include <linux/vmalloc.h>
#include <linux/time.h>
#include <linux/hrtimer.h>
MODULE_LICENSE("GPL");
#define TEST 100
char *ptr[TEST];
static int __init verify_iondev_init(void)
{
int i;
size_t alloc_size;
ktime_t start, end;
printk("start\n");
for (alloc_size = 2048; alloc_size <= 8*4096; alloc_size += 2048) {
start = ktime_get();
for (i = 0; i < TEST; i++) {
ptr[i] = vzalloc(alloc_size);
}
end = ktime_get();
printk("kzalloc(%d) * %d = %llu\n", alloc_size, TEST, end.tv64 - start.tv64);
for (i = 0; i < TEST; i++) {
vfree(ptr[i]);
}
}
return 0;
}
static void __exit verify_iondev_exit(void)
{
int i;
return ;
}
module_init(verify_iondev_init);
module_exit(verify_iondev_exit);
--
Thanks,
Gioh Kim
[-- Attachment #2: kzalloc_vzalloc.png --]
[-- Type: image/png, Size: 18076 bytes --]
reply other threads:[~2014-12-03 2:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=547E7363.9060002@lge.com \
--to=gioh.kim@lge.com \
--cc=kernel-forum@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sinchul.jung@lge.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox