linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Abu M. Muttalib" <abum@aftek.com>
To: linux-mm@kvack.org
Subject: Page Allocation Failure, Why?? Bug in kernel??
Date: Thu, 1 Jun 2006 14:25:53 +0530	[thread overview]
Message-ID: <BKEKJNIHLJDCFGDBOHGMEEHMCNAA.abum@aftek.com> (raw)

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

Hi,

I tried to run an application, try-sound.c. In the course of the run of the
application I repeatedly got page allocation failure, despite the fact that
enough pages are free. Why this is so, is it a bug in mm subsystem of Linux
kernel 2.6.13?

Any pointer to help understand this behavior will be highly appreciated.

~Abu.

[-- Attachment #2: Page_Allocation_Failure.tar.bz2 --]
[-- Type: application/octet-stream, Size: 28486 bytes --]

[-- Attachment #3: try-sound.c --]
[-- Type: application/octet-stream, Size: 7611 bytes --]

#include <stdio.h>
#include <malloc.h>
#include <fcntl.h>

// YoKu 20-10-04 for PMU
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
// YoKu


#define PAGES 900
#define SIGPAGE 4096 
#define REFERESH 0
// LCD                          VDIG_1
#define LCD                     2    

// LCD_BACKLIGHT                CURR1
#define LCD_BACKLIGHT           3       
#define I2C_DEV 		"/dev/i2c-0"	// I2C Device File
#define PMU_CHARGER		"/dev/PMU_CHARGER"
#define WAVE_PIPE		"/tmp/WAVE_PIPE"
#define PMU_ADDR                0x41            // PMU Write Address
#define POWER_CONTROL           9
#define ON           1
#define OFF          0
#define LCD_ON_MASK                     0x04            // 0000 0100    POWER_CONTROL
#define LCD_BACKLIGHT_ON_MASK           0x04            // 0000 0100    CURR_CONTROL
#define CURR_CONTROL            40
#define CURR_MODE		41


int fdI2C;
unsigned char gbyLCDBackOn = 1;

fn_SwitchDev(unsigned char byDev, unsigned char byOp)
{
	__s16  byPresent_val;

	 if ( byDev == LCD )
        {
                if( (byPresent_val = i2c_smbus_read_byte_data(fdI2C , POWER_CONTROL)) < 0) 
		{
		       perror("\nfn_SwitchDev: I2C POWER_CONTROL Read Fail") ;
		}
                else
                {
                        if ( byOp == ON )
			{
                                byPresent_val |= LCD_ON_MASK;
#ifdef MAIN_DEBUG
				printf("\nPMU: Switching LCD ON");
#endif
			}
                        else
			{
                                byPresent_val &= ~LCD_ON_MASK;
#ifdef MAIN_DEBUG
				printf("\nPMU: Switching LCD OFF");
#endif
			}
                        if(i2c_smbus_write_byte_data( fdI2C, POWER_CONTROL, byPresent_val ) < 0) 
			{
			         perror("\nfn_SwitchDev: I2C POWER_CONTROL write Fail") ;
			}
                }
        }
	else if ( byDev == LCD_BACKLIGHT )
	{
		if( (byPresent_val = i2c_smbus_read_byte_data( fdI2C , CURR_CONTROL )) < 0)
		{
			perror("\nfn_SwitchDev: I2C CURR_CONTROL Read Fail") ;
		}
		else
		{
			//pthread_mutex_lock(&_mutgbyLCDBackOn);
			if ( byOp == ON )
			{
				byPresent_val |= LCD_BACKLIGHT_ON_MASK;
#ifdef MAIN_DEBUG
				printf("\nPMU: Switching LCD BACKLIGHT ON");
#endif
				if(i2c_smbus_write_byte_data( fdI2C, CURR_CONTROL, byPresent_val ) < 0)
                                	perror("\nfn_SwitchDev: I2C CURR_CONTROL write Fail") ;
				else
					gbyLCDBackOn = 1;
			}
			else
			{
				byPresent_val &= ~LCD_BACKLIGHT_ON_MASK;
#ifdef MAIN_DEBUG
				printf("\nPMU: Switching LCD BACKLIGHT OFF");
#endif
				if(i2c_smbus_write_byte_data( fdI2C, CURR_CONTROL, byPresent_val ) < 0)
                                	perror("\nfn_SwitchDev: I2C CURR_CONTROL write Fail") ;
				else
					gbyLCDBackOn = 0;
			}
			//pthread_mutex_unlock(&_mutgbyLCDBackOn);
		}
	}
}

int main()
{
	int i=-1;
	static unsigned int cntr = 0 ;
	char *poarray,*p2=NULL;

	system("cat /proc/meminfo");
	for (i=0;i<PAGES;i++)
	{
		poarray=(char*)malloc(SIGPAGE);
		memset(poarray, '\0', SIGPAGE);	
		if(poarray==NULL)
		{
			printf("\nError in allocating\n");
			exit(1);
		}
	}

	if( (fdI2C = open(I2C_DEV,O_RDWR)) < 0 )                // Open I2C Device
        {
                perror("\nMAIN: Cannot open I2C device\n") ;
        }
	else
	{
		// Write 'PMU Write addr' to I2C Device
	        if (ioctl(fdI2C,I2C_SLAVE,PMU_ADDR) < 0)
        	{
                	perror("\nMAIN: I2C PMU_ADDR Write Fail");
        	}
       		 printf("\nMAIN: I2C PMU_ADDR Write Success.fdI2c = %d" ,fdI2C );
	}

	fn_SwitchDev(LCD, 1);
	fn_SwitchDev(LCD_BACKLIGHT, 1);


	while(1)
	{
		cntr ++ ;
		fn_SwitchDev(LCD_BACKLIGHT, 0);
		printf("\nREMOVING MODULES Ittr=%d \n" , cntr);
		sleep(REFERESH);
		system("cat /proc/meminfo");
		system("cat /proc/buddyinfo");
		sleep(REFERESH);
		system("rmmod snd-pcm-oss");
		sleep(REFERESH);
		system("cat /proc/meminfo");
		system("cat /proc/buddyinfo");
		sleep(REFERESH);
		system("rmmod snd-mixer-oss");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("rmmod snd-pxa2xx-ac97");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("rmmod snd-pxa2xx-pcm");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("rmmod snd-ac97-codec");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("rmmod snd-pcm");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("rmmod snd-page-alloc");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("rmmod snd-timer");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("rmmod snd");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("rmmod soundcore");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);

		sleep(2);
		fn_SwitchDev(LCD_BACKLIGHT, 1);
        	p2=(char*)malloc(100);
        	if(p2 == NULL)
        	{
        		printf("OOM PROBLEM");
	        }   
 
		system("lsmod");
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");

//		system("echo 150 >/proc/sys/pm/suspend");

		system("cat /proc/meminfo");

		printf("\nInserting Modules\n");
		system("/sbin/insmod /lib/modules/2.6.13/alsa/soundcore.ko");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("/sbin/insmod /lib/modules/2.6.13/alsa/snd.ko");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("/sbin/insmod /lib/modules/2.6.13/alsa/snd-timer.ko");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("/sbin/insmod /lib/modules/2.6.13/alsa/snd-page-alloc.ko");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("/sbin/insmod /lib/modules/2.6.13/alsa/snd-pcm.ko");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("/sbin/insmod /lib/modules/2.6.13/alsa/snd-ac97-codec.ko");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("/sbin/insmod /lib/modules/2.6.13/alsa/snd-pxa2xx-pcm.ko");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("/sbin/insmod /lib/modules/2.6.13/alsa/snd-pxa2xx-ac97.ko");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("/sbin/insmod /lib/modules/2.6.13/alsa/snd-mixer-oss.ko");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");
		sleep(REFERESH);
		system("/sbin/insmod /lib/modules/2.6.13/alsa/snd-pcm-oss.ko");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("rmmod linuxdrv");
		sleep(REFERESH);
		system("cat /proc/buddyinfo");
		system("cat /proc/meminfo");

		system("/sbin/insmod /root/linuxdrv.ko");
		system("cat /proc/meminfo");
		system("lsmod");
		system("cat /proc/buddyinfo");
		sleep(REFERESH);
		free(p2);
		p2 = NULL;
	}
}

                 reply	other threads:[~2006-06-01  8:55 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=BKEKJNIHLJDCFGDBOHGMEEHMCNAA.abum@aftek.com \
    --to=abum@aftek.com \
    --cc=linux-mm@kvack.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