Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 8 Jan 2002 21:56:02 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 8 Jan 2002 21:55:53 -0500 Received: from mysql.sashanet.com ([209.181.82.108]:16512 "EHLO mysql.sashanet.com") by vger.kernel.org with ESMTP id ; Tue, 8 Jan 2002 21:55:44 -0500 Message-Id: <200201090245.g092jnt02235@mysql.sashanet.com> Content-Type: text/plain; charset="us-ascii" From: Sasha Pachev Organization: MySQL To: linux-kernel@vger.kernel.org Subject: Test case for cache leak in 2.17.2-rc2 Date: Tue, 8 Jan 2002 19:45:49 -0700 X-Mailer: KMail [version 1.3.1] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org The following test program demonstrates incorrect cache shrinking logic in 2.17.2-rc2 with 0 swap. I suspect the same problem will happen if swap is not zero but is filled up. I have not noticed anything relevant in the changelogs between my version and 2.4.18-pre2, so I assume the bug is still there. It would be nice if somebody could verify it. First the code: -------------------start--------------------- #include #include #include #include #define BLOCK_SIZE 1024 int done_hog_cache=0; int done_hog_free=0; int go_pipe[2]; pid_t child_pid=0; void stop_hog_cache() { done_hog_cache=1; } void stop_hog_free() { done_hog_free=1; } void stop_all() { done_hog_free=done_hog_cache=1; if (child_pid>0) kill(child_pid,SIGHUP); } void hog_free(int blocks) { char* buf; char go_buf[2]; signal(SIGHUP,stop_hog_free); signal(SIGTERM,stop_hog_free); printf("Hogging free mem, to stop, do kill -HUP %d in another terminal\n", getpid()); read(go_pipe[0],go_buf,2); if (!(buf=(char*)malloc(blocks*BLOCK_SIZE))) { fprintf(stderr,"malloc() failed\n"); exit(1); } memset(buf,0xff,blocks*BLOCK_SIZE); while (!done_hog_free) { sleep(1); } } void hog_cache(int blocks) { FILE* fp; char buf[BLOCK_SIZE]; const char* hog_file="/tmp/hog-file"; int i; memset(buf,0xff,sizeof(buf)); if (!(fp=fopen(hog_file,"w+"))) { fprintf(stderr,"Could not open crash file\n"); exit(1); } signal(SIGHUP,stop_hog_cache); signal(SIGTERM,stop_hog_free); printf("Hogging disk cache, to stop, do kill -HUP %d in another terminal\n", getpid()); for (i=0;i / /|_/ / // /\ \/ /_/ / /__ MySQL AB, http://www.mysql.com/ /_/ /_/\_, /___/\___\_\___/ Provo, Utah, USA <___/ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/