summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-03-08 16:55:54 +0800
committerwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-03-08 16:55:54 +0800
commit8e81df07a3e3ea7abc2159e9ebb5bef6b9caf68a (patch)
treec0e12c11e4aa726ea3ff950b007de9edb4ffd6e0
parentbf85ed1d1979c65a6bb93ae965dd50282e6326a5 (diff)
downloadpttbbs-8e81df07a3e3ea7abc2159e9ebb5bef6b9caf68a.tar
pttbbs-8e81df07a3e3ea7abc2159e9ebb5bef6b9caf68a.tar.gz
pttbbs-8e81df07a3e3ea7abc2159e9ebb5bef6b9caf68a.tar.bz2
pttbbs-8e81df07a3e3ea7abc2159e9ebb5bef6b9caf68a.tar.lz
pttbbs-8e81df07a3e3ea7abc2159e9ebb5bef6b9caf68a.tar.xz
pttbbs-8e81df07a3e3ea7abc2159e9ebb5bef6b9caf68a.tar.zst
pttbbs-8e81df07a3e3ea7abc2159e9ebb5bef6b9caf68a.zip
add support for hugetblpage of Linux 2.6
do not use this if you do not know what this is git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2581 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--include/common.h4
-rw-r--r--mbbsd/cache.c6
-rw-r--r--sample/pttbbs.conf3
-rw-r--r--util/uhash_loader.c12
-rw-r--r--util/userlist.c6
5 files changed, 27 insertions, 4 deletions
diff --git a/include/common.h b/include/common.h
index cff8cbf4..a17e7a15 100644
--- a/include/common.h
+++ b/include/common.h
@@ -213,4 +213,8 @@
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
+#ifndef SHM_HUGETLB
+#define SHM_HUGETLB 04000 /* segment is mapped via hugetlb */
+#endif
+
#endif
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 493b9b91..4933339f 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -48,7 +48,11 @@ attach_shm(int shmkey, int shmsize)
void *shmptr = (void *)NULL;
int shmid;
- shmid = shmget(shmkey, shmsize, 0);
+ shmid = shmget(shmkey, shmsize,
+#ifdef USE_HUGETLB
+ SHM_HUGETLB |
+#endif
+ 0);
if (shmid < 0) {
// SHM should be created by uhash_loader, NOT mbbsd or other utils
attach_err(shmkey, "shmget");
diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf
index 6a1559c6..e847ab96 100644
--- a/sample/pttbbs.conf
+++ b/sample/pttbbs.conf
@@ -124,6 +124,9 @@
/* 使用 rfork()取代 fork() . 目前只在 FreeBSD上有效 */
//#define USE_RFORK
+/* 使用 HUGETLB shared memory . 目前只在 Linux 上有效 */
+//#define USE_HUGETLB
+
/* 若定義, 則在刪除看板文章的時候, 僅會在 .DIR 中標明, 並不會將該資料
從 .DIR 中拿掉. 可以避免多項問題 (尤其是熱門看板一堆推薦及編輯時)
須配合使用 (尚未完成) */
diff --git a/util/uhash_loader.c b/util/uhash_loader.c
index 55301210..6a0bfaf4 100644
--- a/util/uhash_loader.c
+++ b/util/uhash_loader.c
@@ -20,10 +20,18 @@ int main() {
void load_uhash(void) {
int shmid, err;
- shmid = shmget(SHM_KEY, sizeof(SHM_t), IPC_CREAT | IPC_EXCL | 0600);
+ shmid = shmget(SHM_KEY, sizeof(SHM_t),
+#ifdef USE_HUGETLB
+ SHM_HUGETLB |
+#endif
+ IPC_CREAT | IPC_EXCL | 0600);
err = errno;
if( err == EEXIST)
- shmid = shmget(SHM_KEY, sizeof(SHM_t), IPC_CREAT | 0600);
+ shmid = shmget(SHM_KEY, sizeof(SHM_t),
+#ifdef USE_HUGETLB
+ SHM_HUGETLB |
+#endif
+ IPC_CREAT | 0600);
if (shmid < 0)
{
perror("shmget");
diff --git a/util/userlist.c b/util/userlist.c
index aa549a8a..cecc3ee6 100644
--- a/util/userlist.c
+++ b/util/userlist.c
@@ -6,7 +6,11 @@ SHM_t *SHM;
int main(int argc, char **argv) {
int i, shm, counter;
- shm = shmget(SHM_KEY, USHM_SIZE, SHM_R | SHM_W);
+ shm = shmget(SHM_KEY, USHM_SIZE,
+#ifdef USE_HUGETLB
+ SHM_HUGETLB |
+#endif
+ SHM_R | SHM_W);
if(shm == -1) {
perror("shmget");
exit(0);