linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/20] mmu: arch/mm: Port OOM changes to arch page fault handlers.
@ 2012-03-20 13:18 Kautuk Consul
  2012-03-20 13:30 ` richard -rw- weinberger
  2012-03-31 11:58 ` [PATCH 0/19 v2] " Kautuk Consul
  0 siblings, 2 replies; 7+ messages in thread
From: Kautuk Consul @ 2012-03-20 13:18 UTC (permalink / raw)
  To: linux-alpha, linuxppc-dev, linux, linux-am33-list,
	microblaze-uclinux, linux-m68k, linux-m32r-ja, linux-ia64,
	linux-hexagon, linux-cris-kernel, linux-sh, linux-parisc,
	sparclinux
  Cc: linux-mm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 950 bytes --]

Commit d065bd810b6deb67d4897a14bfe21f8eb526ba99
(mm: retry page fault when blocking on disk transfer) and
commit 37b23e0525d393d48a7d59f870b3bc061a30ccdb
(x86,mm: make pagefault killable)

The above commits introduced changes into the x86 pagefault handler
for making the page fault handler retryable as well as killable.

These changes reduce the mmap_sem hold time, which is crucial
during OOM killer invocation.

I was facing hang and livelock problems on my ARM and MIPS boards when
I invoked OOM by running the stress_32k.c test-case attached to this email.

Since both the ARM and MIPS porting chainges were accepted, me and my
co-worker decided to take the initiative to port these changes to all other
MMU based architectures.

Please review and do write back if there is any way I need to
improve/rewrite any
of these patches.

Signed-off-by: Mohd. Faris <mohdfarisq2010@gmail.com>
Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com>
---

[-- Attachment #2: stress_32k.c --]
[-- Type: text/x-csrc, Size: 3897 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>

#define ALLOC_BYTE 512*1024
#define COUNT 50

void *alloc_function_one( void *ptr );
void *alloc_function_two( void *ptr );
void *alloc_function_three( void *ptr );
void *alloc_function_four( void *ptr );
void *alloc_function_five( void *ptr );
void *enable_function( void *ptr );


int main(int argc, char *argv[])
{
	pthread_t thread1, thread2, thread3, thread4, thread5;
	char *message1 = "Thread 1";
	char *message2 = "Thread 2";
	char *message3 = "Thread 3";
	char *message4 = "Thread 4";
	char *message5 = "Thread 5";
	int iret1 = -1;
	int iret2 = -1;
	int iret3 = -1;
	int iret4 = -1;
	int iret5 = -1;
	fork();
	iret1 = pthread_create( &thread1, NULL, alloc_function_one, (void*) message1);
	iret2 = pthread_create( &thread2, NULL, alloc_function_two, (void*) message2);
	iret2 = pthread_create( &thread3, NULL, alloc_function_three, (void*) message2);
	iret2 = pthread_create( &thread4, NULL, alloc_function_four, (void*) message2);
	iret2 = pthread_create( &thread5, NULL, alloc_function_five, (void*) message2);

	pthread_join( thread1, NULL);
	pthread_join( thread2, NULL);
	pthread_join( thread3, NULL);
	pthread_join( thread4, NULL);
	pthread_join( thread5, NULL);

	printf("Thread 1 returns: %d\n",iret1);
	printf("Thread 2 returns: %d\n",iret2);
	printf("Thread 3 returns: %d\n",iret3);
	printf("Thread 4 returns: %d\n",iret4);
	printf("Thread 5 returns: %d\n",iret5);
	exit(0);
}

void *alloc_function_two( void *ptr )
{
	char *message;
	message = (char *) ptr;
	void *myblock[COUNT];
	int i= 0,j=0;
	int freed=0;
	printf("message_alloc  \n");
	while(1)
	{
		memset(myblock,0,sizeof(myblock));
		printf("message_alloc %s \n",message);
		for(i=0;i< COUNT ;i++)
		{
			myblock[i] = (void *) malloc(ALLOC_BYTE);
			memset(myblock[i],1, ALLOC_BYTE);
		}
	}
}


void *alloc_function_one( void *ptr )
{
	char *message;
	message = (char *) ptr;
	void *myblock[COUNT];
	int i= 0,j=0;
	int freed=0;
	printf("message_alloc  \n");
	while(1)
	{
		memset(myblock,0,sizeof(myblock));
		printf("message_alloc %s \n",message);
		for(i=0;i< COUNT ;i++)
		{
			myblock[i] = (void *) malloc(ALLOC_BYTE);
			memset(myblock[i],1, ALLOC_BYTE);
		}
	}
}

void *alloc_function_three( void *ptr )
{
       char *message;
        message = (char *) ptr;
        void *myblock[COUNT];
        int i= 0,j=0;
        int freed=0;
        printf("message_alloc  \n");
        while(1)
        {
                memset(myblock,0,sizeof(myblock));
                printf("message_alloc %s \n",message);
                for(i=0;i< COUNT ;i++)
                {
                        myblock[i] = (void *) malloc(ALLOC_BYTE);
                        memset(myblock[i],1, ALLOC_BYTE);
                }
        }
}
void *alloc_function_four( void *ptr )
{
       char *message;
        message = (char *) ptr;
        void *myblock[COUNT];
        int i= 0,j=0;
        int freed=0;
        printf("message_alloc  \n");
        while(1)
        {
                memset(myblock,0,sizeof(myblock));
                printf("message_alloc %s \n",message);
                for(i=0;i< COUNT ;i++)
                {
                        myblock[i] = (void *) malloc(ALLOC_BYTE);
                        memset(myblock[i],1, ALLOC_BYTE);
                }
        }
}
void *alloc_function_five( void *ptr )
{
       char *message;
        message = (char *) ptr;
        void *myblock[COUNT];
        int i= 0,j=0;
        int freed=0;
        printf("message_alloc  \n");
        while(1)
        {
                memset(myblock,0,sizeof(myblock));
                printf("message_alloc %s \n",message);
                for(i=0;i< COUNT ;i++)
                {
                        myblock[i] = (void *) malloc(ALLOC_BYTE);
                        memset(myblock[i],1, ALLOC_BYTE);
                }
        }
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/20] mmu: arch/mm: Port OOM changes to arch page fault handlers.
  2012-03-20 13:18 [PATCH 0/20] mmu: arch/mm: Port OOM changes to arch page fault handlers Kautuk Consul
@ 2012-03-20 13:30 ` richard -rw- weinberger
  2012-03-20 13:34   ` Kautuk Consul
  2012-03-31 11:58 ` [PATCH 0/19 v2] " Kautuk Consul
  1 sibling, 1 reply; 7+ messages in thread
From: richard -rw- weinberger @ 2012-03-20 13:30 UTC (permalink / raw)
  To: Kautuk Consul
  Cc: linux-alpha, linuxppc-dev, linux, linux-am33-list,
	microblaze-uclinux, linux-m68k, linux-m32r-ja, linux-ia64,
	linux-hexagon, linux-cris-kernel, linux-sh, linux-parisc,
	sparclinux, linux-mm, linux-kernel

On Tue, Mar 20, 2012 at 2:18 PM, Kautuk Consul <consul.kautuk@gmail.com> wrote:
> Commit d065bd810b6deb67d4897a14bfe21f8eb526ba99
> (mm: retry page fault when blocking on disk transfer) and
> commit 37b23e0525d393d48a7d59f870b3bc061a30ccdb
> (x86,mm: make pagefault killable)
>
> The above commits introduced changes into the x86 pagefault handler
> for making the page fault handler retryable as well as killable.
>
> These changes reduce the mmap_sem hold time, which is crucial
> during OOM killer invocation.
>
> I was facing hang and livelock problems on my ARM and MIPS boards when
> I invoked OOM by running the stress_32k.c test-case attached to this email.
>
> Since both the ARM and MIPS porting chainges were accepted, me and my
> co-worker decided to take the initiative to port these changes to all other
> MMU based architectures.
>
> Please review and do write back if there is any way I need to
> improve/rewrite any
> of these patches.
>

What about arch/um/?
Does UML not need this change?

-- 
Thanks,
//richard

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/20] mmu: arch/mm: Port OOM changes to arch page fault handlers.
  2012-03-20 13:30 ` richard -rw- weinberger
@ 2012-03-20 13:34   ` Kautuk Consul
  2012-03-20 13:36     ` richard -rw- weinberger
  0 siblings, 1 reply; 7+ messages in thread
From: Kautuk Consul @ 2012-03-20 13:34 UTC (permalink / raw)
  To: richard -rw- weinberger
  Cc: linux-alpha, linuxppc-dev, linux, linux-am33-list,
	microblaze-uclinux, linux-m68k, linux-m32r-ja, linux-ia64,
	linux-hexagon, linux-cris-kernel, linux-sh, linux-parisc,
	sparclinux, linux-mm, linux-kernel

>
> What about arch/um/?
> Does UML not need this change?

Oh yes, extremely sorry I accidentally missed that one out.
Mind if I send it separately ?

>
> --
> Thanks,
> //richard

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/20] mmu: arch/mm: Port OOM changes to arch page fault handlers.
  2012-03-20 13:34   ` Kautuk Consul
@ 2012-03-20 13:36     ` richard -rw- weinberger
  2012-03-20 13:49       ` Kautuk Consul
  0 siblings, 1 reply; 7+ messages in thread
From: richard -rw- weinberger @ 2012-03-20 13:36 UTC (permalink / raw)
  To: Kautuk Consul
  Cc: linux-alpha, linuxppc-dev, linux, linux-am33-list,
	microblaze-uclinux, linux-m68k, linux-m32r-ja, linux-ia64,
	linux-hexagon, linux-cris-kernel, linux-sh, linux-parisc,
	sparclinux, linux-mm, linux-kernel

On Tue, Mar 20, 2012 at 2:34 PM, Kautuk Consul <consul.kautuk@gmail.com> wrote:
>>
>> What about arch/um/?
>> Does UML not need this change?
>
> Oh yes, extremely sorry I accidentally missed that one out.
> Mind if I send it separately ?

No problem.
handle_page_fault() is the function you want to patch. :)

-- 
Thanks,
//richard

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/20] mmu: arch/mm: Port OOM changes to arch page fault handlers.
  2012-03-20 13:36     ` richard -rw- weinberger
@ 2012-03-20 13:49       ` Kautuk Consul
  0 siblings, 0 replies; 7+ messages in thread
From: Kautuk Consul @ 2012-03-20 13:49 UTC (permalink / raw)
  To: richard -rw- weinberger, user-mode-linux-devel, user-mode-linux-user
  Cc: linux-mm, linux-kernel

> No problem.
> handle_page_fault() is the function you want to patch. :)
>

Sent.
Terribly sorry for the miss.

Also, the UML page fault handler has some differences from the other
page fault handlers,
so I apologize if I have made some wrong assumptions or mistakes.


> --
> Thanks,
> //richard

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/19 v2] mmu: arch/mm: Port OOM changes to arch page fault handlers.
  2012-03-20 13:18 [PATCH 0/20] mmu: arch/mm: Port OOM changes to arch page fault handlers Kautuk Consul
  2012-03-20 13:30 ` richard -rw- weinberger
@ 2012-03-31 11:58 ` Kautuk Consul
  2012-03-31 12:15   ` Kautuk Consul
  1 sibling, 1 reply; 7+ messages in thread
From: Kautuk Consul @ 2012-03-31 11:58 UTC (permalink / raw)
  To: linux-alpha, linuxppc-dev, linux, linux-am33-list,
	microblaze-uclinux, linux-m68k, linux-m32r-ja, linux-ia64,
	linux-hexagon, linux-cris-kernel, linux-sh, linux-parisc,
	linux-mm, linux-arch
  Cc: linux-kernel

Commit d065bd810b6deb67d4897a14bfe21f8eb526ba99
(mm: retry page fault when blocking on disk transfer) and
commit 37b23e0525d393d48a7d59f870b3bc061a30ccdb
(x86,mm: make pagefault killable)

The above commits introduced changes into the x86 pagefault handler
for making the page fault handler retryable as well as killable.

These changes reduce the mmap_sem hold time, which is crucial
during OOM killer invocation.

I was facing hang and livelock problems on my ARM and MIPS boards when
I invoked OOM by running the stress_32k.c test-case attached to this email.

Since both the ARM and MIPS porting changes were accepted, me and my
co-worker decided to take the initiative to port these changes to all other
MMU based architectures.

This is v2 of this patch set as there were some problems with the v1 of this
patchset:
- Whitespace issues as reported by David Miller and Joe Perches
- In 2 of the patches, the write(or equivalent) local variable has
been removed from the
  page fault handler because it is not really needed anymore with the
advent of the "flags"
  local variable. Thanks to Geert Uytterhoeven for that.
- The powerpc patch for this has been removed as this has already been
done by someone
  else for powerpc.

At the moment, 8 of these patches have Acked these patches as valid.
I have included their ACKed-By headers for them in their respective
arch patches.

And thanks to Guan Xuetao for actually testing this out on unicore32.

Rest of the arch owners: Please review these patches.

Signed-off-by: Mohd. Faris <mohdfarisq2010@gmail.com>
Signed-off-by: Kautuk Consul <consul.kautuk@gmail.com>
---

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/19 v2] mmu: arch/mm: Port OOM changes to arch page fault handlers.
  2012-03-31 11:58 ` [PATCH 0/19 v2] " Kautuk Consul
@ 2012-03-31 12:15   ` Kautuk Consul
  0 siblings, 0 replies; 7+ messages in thread
From: Kautuk Consul @ 2012-03-31 12:15 UTC (permalink / raw)
  To: linux-alpha, linuxppc-dev, linux, linux-am33-list,
	microblaze-uclinux, linux-m68k, linux-m32r-ja, linux-ia64,
	linux-hexagon, linux-cris-kernel, linux-sh, linux-parisc,
	linux-mm, linux-arch
  Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 110 bytes --]

Ugh, sorry I forgot to attach the stress_32k.c test-case to this email.

Please find it attached to this one.

[-- Attachment #2: stress_32k.c --]
[-- Type: text/x-csrc, Size: 3897 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>

#define ALLOC_BYTE 512*1024
#define COUNT 50

void *alloc_function_one( void *ptr );
void *alloc_function_two( void *ptr );
void *alloc_function_three( void *ptr );
void *alloc_function_four( void *ptr );
void *alloc_function_five( void *ptr );
void *enable_function( void *ptr );


int main(int argc, char *argv[])
{
	pthread_t thread1, thread2, thread3, thread4, thread5;
	char *message1 = "Thread 1";
	char *message2 = "Thread 2";
	char *message3 = "Thread 3";
	char *message4 = "Thread 4";
	char *message5 = "Thread 5";
	int iret1 = -1;
	int iret2 = -1;
	int iret3 = -1;
	int iret4 = -1;
	int iret5 = -1;
	fork();
	iret1 = pthread_create( &thread1, NULL, alloc_function_one, (void*) message1);
	iret2 = pthread_create( &thread2, NULL, alloc_function_two, (void*) message2);
	iret2 = pthread_create( &thread3, NULL, alloc_function_three, (void*) message2);
	iret2 = pthread_create( &thread4, NULL, alloc_function_four, (void*) message2);
	iret2 = pthread_create( &thread5, NULL, alloc_function_five, (void*) message2);

	pthread_join( thread1, NULL);
	pthread_join( thread2, NULL);
	pthread_join( thread3, NULL);
	pthread_join( thread4, NULL);
	pthread_join( thread5, NULL);

	printf("Thread 1 returns: %d\n",iret1);
	printf("Thread 2 returns: %d\n",iret2);
	printf("Thread 3 returns: %d\n",iret3);
	printf("Thread 4 returns: %d\n",iret4);
	printf("Thread 5 returns: %d\n",iret5);
	exit(0);
}

void *alloc_function_two( void *ptr )
{
	char *message;
	message = (char *) ptr;
	void *myblock[COUNT];
	int i= 0,j=0;
	int freed=0;
	printf("message_alloc  \n");
	while(1)
	{
		memset(myblock,0,sizeof(myblock));
		printf("message_alloc %s \n",message);
		for(i=0;i< COUNT ;i++)
		{
			myblock[i] = (void *) malloc(ALLOC_BYTE);
			memset(myblock[i],1, ALLOC_BYTE);
		}
	}
}


void *alloc_function_one( void *ptr )
{
	char *message;
	message = (char *) ptr;
	void *myblock[COUNT];
	int i= 0,j=0;
	int freed=0;
	printf("message_alloc  \n");
	while(1)
	{
		memset(myblock,0,sizeof(myblock));
		printf("message_alloc %s \n",message);
		for(i=0;i< COUNT ;i++)
		{
			myblock[i] = (void *) malloc(ALLOC_BYTE);
			memset(myblock[i],1, ALLOC_BYTE);
		}
	}
}

void *alloc_function_three( void *ptr )
{
       char *message;
        message = (char *) ptr;
        void *myblock[COUNT];
        int i= 0,j=0;
        int freed=0;
        printf("message_alloc  \n");
        while(1)
        {
                memset(myblock,0,sizeof(myblock));
                printf("message_alloc %s \n",message);
                for(i=0;i< COUNT ;i++)
                {
                        myblock[i] = (void *) malloc(ALLOC_BYTE);
                        memset(myblock[i],1, ALLOC_BYTE);
                }
        }
}
void *alloc_function_four( void *ptr )
{
       char *message;
        message = (char *) ptr;
        void *myblock[COUNT];
        int i= 0,j=0;
        int freed=0;
        printf("message_alloc  \n");
        while(1)
        {
                memset(myblock,0,sizeof(myblock));
                printf("message_alloc %s \n",message);
                for(i=0;i< COUNT ;i++)
                {
                        myblock[i] = (void *) malloc(ALLOC_BYTE);
                        memset(myblock[i],1, ALLOC_BYTE);
                }
        }
}
void *alloc_function_five( void *ptr )
{
       char *message;
        message = (char *) ptr;
        void *myblock[COUNT];
        int i= 0,j=0;
        int freed=0;
        printf("message_alloc  \n");
        while(1)
        {
                memset(myblock,0,sizeof(myblock));
                printf("message_alloc %s \n",message);
                for(i=0;i< COUNT ;i++)
                {
                        myblock[i] = (void *) malloc(ALLOC_BYTE);
                        memset(myblock[i],1, ALLOC_BYTE);
                }
        }
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-03-31 12:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-20 13:18 [PATCH 0/20] mmu: arch/mm: Port OOM changes to arch page fault handlers Kautuk Consul
2012-03-20 13:30 ` richard -rw- weinberger
2012-03-20 13:34   ` Kautuk Consul
2012-03-20 13:36     ` richard -rw- weinberger
2012-03-20 13:49       ` Kautuk Consul
2012-03-31 11:58 ` [PATCH 0/19 v2] " Kautuk Consul
2012-03-31 12:15   ` Kautuk Consul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox