mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Tridgell <tridge@osdl.org>
To: "Randy.Dunlap" <rddunlap@osdl.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Andreas Gruenbacher <agruen@suse.de>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: memory leak in 2.6.11-rc2
Date: Tue, 25 Jan 2005 15:48:01 +1100	[thread overview]
Message-ID: <16885.53121.883933.986880@samba.org> (raw)
In-Reply-To: <16885.48502.243516.563660@samba.org>

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 2849 bytes --]

 > I'm trying the little leak tracking patch from Alexander Nyberg now.

Here are the results (only backtraces with more than 10k counts
included). The leak was at 1G of memory at the time I ran this, so its
safe to say 10k page allocations ain't enough to explain it :-)

I also attach a hacked version of the pgown sort program that sorts
the output by count, and isn't O(n^2). It took 10 minutes to run the
old version :-)

I'm guessing the leak is in the new xattr code given that is what
dbench and nbench were beating on. Andreas, can you look at the
following and see if you can spot anything?

This was on 2.6.11-rc2 with the pipe leak patch from Linus. The
machine had leaked 1G of ram in 10 minutes, and was idle (only thing
running was sshd).

Cheers, Tridge


175485 times:
Page allocated via order 0
[0xc0132258] generic_file_buffered_write+280
[0xc011b6a9] current_fs_time+77
[0xc0132a1e] __generic_file_aio_write_nolock+642
[0xc0132e70] generic_file_aio_write+100
[0xc017e586] ext3_file_write+38
[0xc014b7f5] do_sync_write+169
[0xc015f6de] fcntl_setlk64+286
[0xc01295a8] autoremove_wake_function+0

141512 times:
Page allocated via order 0
[0xc0132258] generic_file_buffered_write+280
[0xc0132a1e] __generic_file_aio_write_nolock+642
[0xc0132e70] generic_file_aio_write+100
[0xc017e586] ext3_file_write+38
[0xc014b7f5] do_sync_write+169
[0xc015f6de] fcntl_setlk64+286
[0xc01295a8] autoremove_wake_function+0
[0xc014b8d5] vfs_write+157

67641 times:
Page allocated via order 0
[0xc0132258] generic_file_buffered_write+280
[0xc014dc69] __getblk+29
[0xc011b6a9] current_fs_time+77
[0xc0132a1e] __generic_file_aio_write_nolock+642
[0xc018d368] ext3_xattr_user_get+108
[0xc0132e70] generic_file_aio_write+100
[0xc017e586] ext3_file_write+38
[0xc014b7f5] do_sync_write+169

52758 times:
Page allocated via order 0
[0xc0132258] generic_file_buffered_write+280
[0xc014dc69] __getblk+29
[0xc0132a1e] __generic_file_aio_write_nolock+642
[0xc018d368] ext3_xattr_user_get+108
[0xc0132e70] generic_file_aio_write+100
[0xc017e586] ext3_file_write+38
[0xc014b7f5] do_sync_write+169
[0xc0120c0b] kill_proc_info+47

19610 times:
Page allocated via order 0
[0xc0132258] generic_file_buffered_write+280
[0xc011b6a9] current_fs_time+77
[0xc0132a1e] __generic_file_aio_write_nolock+642
[0xc0132c3a] generic_file_aio_write_nolock+54
[0xc0132def] generic_file_write_nolock+151
[0xc011b7cb] __do_softirq+95
[0xc01295a8] autoremove_wake_function+0
[0xc01295a8] autoremove_wake_function+0

16874 times:
Page allocated via order 0
[0xc0132258] generic_file_buffered_write+280
[0xc011b6a9] current_fs_time+77
[0xc0132a1e] __generic_file_aio_write_nolock+642
[0xc0132c3a] generic_file_aio_write_nolock+54
[0xc0132def] generic_file_write_nolock+151
[0xc01295a8] autoremove_wake_function+0
[0xc01295a8] autoremove_wake_function+0
[0xc0152d4a] blkdev_file_write+38


[-- Attachment #2: pgown-fast.c --]
[-- Type: application/octet-stream, Size: 2427 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

struct block_list {
	char *txt;
	int len;
	int num;
};


static struct block_list *list;
static int list_size;
static int max_size;

struct block_list *block_head;

int read_block(char *buf, FILE *fin)
{
	int ret = 0;
	int hit = 0;
	char *curr = buf;
	
	for (;;) {
		*curr = getc(fin);
		if (*curr == EOF) return -1;
		
		ret++;
		if (*curr == '\n' && hit == 1)
			return ret - 1;
		else if (*curr == '\n')
			hit = 1;
		else
			hit = 0;
		curr++;
	}
}

static int compare_txt(struct block_list *l1, struct block_list *l2)
{
	return strcmp(l1->txt, l2->txt);
}

static int compare_num(struct block_list *l1, struct block_list *l2)
{
	return l2->num - l1->num;
}

static void add_list(char *buf, int len)
{
	if (list_size != 0 &&
	    len == list[list_size-1].len &&
	    memcmp(buf, list[list_size-1].txt, len) == 0) {
		list[list_size-1].num++;
		return;
	}
	if (list_size == max_size) {
		printf("max_size too small??\n");
		exit(1);
	}
	list[list_size].txt = malloc(len+1);
	list[list_size].len = len;
	list[list_size].num = 1;
	memcpy(list[list_size].txt, buf, len);
	list[list_size].txt[len] = 0;
	list_size++;
	if (list_size % 1000 == 0) {
		printf("loaded %d\r", list_size);
		fflush(stdout);
	}
}

int main(int argc, char **argv)
{
	FILE *fin, *fout;
	char buf[1024];
	int ret, i, count;
	struct block_list *list2;
	struct stat st;
	
	fin = fopen(argv[1], "r");
	fout = fopen(argv[2], "w");
	if (!fin || !fout) {
		printf("Usage: ./program <input> <output>\n");
		perror("open: ");
		exit(2);
	}

	fstat(fileno(fin), &st);
	max_size = st.st_size / 100; /* hack ... */

	list = malloc(max_size * sizeof(*list));
	
	for(;;) {
		ret = read_block(buf, fin);
		if (ret < 0)
			break;
		
		buf[ret] = '\0';
		add_list(buf, ret);
	}

	printf("loaded %d\n", list_size);

	printf("sorting ....\n");

	qsort(list, list_size, sizeof(list[0]), compare_txt);

	list2 = malloc(sizeof(*list) * list_size);

	printf("culling\n");

	for (i=count=0;i<list_size;i++) {
		if (count == 0 || 
		    strcmp(list2[count-1].txt, list[i].txt) != 0) {
			list2[count++] = list[i];
		} else {
			list2[count-1].num += list[i].num;
		}
	}
	
	qsort(list2, count, sizeof(list[0]), compare_num);
	
	for (i=0;i<count;i++) {
		fprintf(fout, "%d times:\n%s\n", list2[i].num, list2[i].txt);
	}
	return 0;
}





  reply	other threads:[~2005-01-25  4:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-20  2:01 [ea-in-inode 0/5] Further fixes Andreas Gruenbacher
2005-01-20  2:01 ` [patch 5/5] Disallow in-inode attributes for reserved inodes Andreas Gruenbacher
2005-01-20 12:16   ` Andreas Dilger
2005-01-20 13:29     ` Andreas Gruenbacher
2005-01-20 23:05       ` Andreas Dilger
2005-01-21  0:36         ` Andreas Gruenbacher
2005-01-20  2:01 ` [patch 1/5] No lock needed when freeing inode Andreas Gruenbacher
2005-01-20  2:01 ` [patch 3/5] Documentation fix Andreas Gruenbacher
2005-01-20  2:01 ` [patch 2/5] Set the EXT3_FEATURE_COMPAT_EXT_ATTR for in-inode xattrs Andreas Gruenbacher
2005-01-20  2:01 ` [patch 4/5] Fix i_extra_isize check Andreas Gruenbacher
2005-01-21 22:58 ` [ea-in-inode 0/5] Further fixes Stephen C. Tweedie
2005-01-21 23:46   ` Andreas Gruenbacher
2005-01-23 13:22     ` Andrew Tridgell
2005-01-23 22:09     ` Andrew Tridgell
2005-01-23 22:58       ` Andreas Gruenbacher
2005-01-23 23:32         ` Andreas Gruenbacher
2005-01-24 11:24           ` Andrew Tridgell
2005-01-24 11:42             ` Christoph Hellwig
2005-01-24 14:11             ` Andreas Gruenbacher
2005-01-25  3:19             ` memory leak in 2.6.11-rc2 Andrew Tridgell
2005-01-25  3:20               ` Randy.Dunlap
2005-01-25  3:31                 ` Andrew Tridgell
2005-01-25  4:48                   ` Andrew Tridgell [this message]
2005-01-25  6:06                     ` Andrew Morton
2005-01-25 11:35                       ` Andrew Tridgell
2005-01-25 12:11                         ` Nick Piggin
2005-01-25  3:45               ` Dave Jones
2005-01-25 12:51                 ` Andrea Arcangeli
2005-01-25 13:31                   ` Andreas Gruenbacher
2005-01-25 13:55                     ` Andrea Arcangeli

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=16885.53121.883933.986880@samba.org \
    --to=tridge@osdl.org \
    --cc=agruen@suse.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rddunlap@osdl.org \
    /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

Powered by JetHome