[OpenAFS-devel] lots of vmalloc failures lately...

Neulinger, Nathan nneul@umr.edu
Tue, 27 Apr 2004 08:41:32 -0500


Will definately move to that on my next build. I added a bunch of
asserts in places that I think I've seen previous allocation failures,
and also applied Chas's patch for writethoughdslots. Now just waiting
for the next crash if there is one.

-- Nathan

------------------------------------------------------------
Nathan Neulinger                       EMail:  nneul@umr.edu
University of Missouri - Rolla         Phone: (573) 341-6679
UMR Information Technology             Fax: (573) 341-4216
=20

> -----Original Message-----
> From: Nickolai Zeldovich [mailto:kolya@MIT.EDU]=20
> Sent: Monday, April 26, 2004 4:57 PM
> To: Neulinger, Nathan
> Cc: openafs-devel@openafs.org
> Subject: RE: [OpenAFS-devel] lots of vmalloc failures lately...
>=20
> On Mon, 2004-04-26 at 09:04, Neulinger, Nathan wrote:
> > The biggest problem here is that the alloc failure generates a log
> > message that gives no information about where it was called=20
> from, and it
> > usually doesn't oops till later in the code...=20
>=20
> If you want, you can try the untested patch below, applied to the
> current checkout from CVS (which has an autoconf check to see if the
> compiler supports __FUNCTION__).  This should tell you what=20
> allocations
> are failing where.
>=20
> Apologies if the patch appears to be broken -- I'm still not=20
> quite sure
> of how my new mail agent (Evolution) behaves.  You can also=20
> grab it as=20
> http://mit.edu/kolya/tmp/afs-alloc-debug.
>=20
> -- kolya
>=20
> --- afs/afs_osi.c	21 Apr 2004 02:20:21 -0000	1.44
> +++ afs/afs_osi.c	26 Apr 2004 21:50:30 -0000
> @@ -422,10 +422,10 @@
> =20
> =20
>  void *
> -afs_osi_Alloc(size_t x)
> +afs_osi_Alloc_debug(size_t x, char *func, int line)
>  {
> -    register struct osimem *tm =3D NULL;
> -    register int size;
> +    void *ptr =3D NULL;
> +    int size =3D x;
> =20
>      AFS_STATCNT(osi_Alloc);
>      /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we
> special-case
> @@ -435,20 +435,24 @@
> =20
>      AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
>      AFS_STATS(afs_stats_cmperf.OutStandingMemUsage +=3D x);
> +
>  #ifdef AFS_LINUX20_ENV
> -    return osi_linux_alloc(x, 1);
> +    ptr =3D osi_linux_alloc(x, 1);
>  #elif defined(AFS_FBSD_ENV)
> -    return osi_fbsd_alloc(x, 1);
> +    ptr =3D osi_fbsd_alloc(x, 1);
>  #else
> -    size =3D x;
> -    tm =3D (struct osimem *)AFS_KALLOC(size);
> +    ptr =3D AFS_KALLOC(size);
> +#endif
> +
> +    if (!ptr) {
> +	printf("Unable to allocate %d bytes at %s:%d\n", size,=20
> func, line);
>  #ifdef	AFS_SUN_ENV
> -    if (!tm)
>  	osi_Panic("osi_Alloc: Couldn't allocate %d bytes; out=20
> of memory!\n",
>  		  size);
>  #endif
> -    return (void *)tm;
> -#endif
> +    }
> +
> +    return ptr;
>  }
> =20
>  #if	defined(AFS_SUN_ENV) || defined(AFS_SGI_ENV)
>=20
> --- afs/afs_osi.h	11 Mar 2004 19:14:46 -0000	1.21
> +++ afs/afs_osi.h	26 Apr 2004 21:50:30 -0000
> @@ -114,6 +114,12 @@
>  /*
>   * Alloc declarations.
>   */
> +#ifdef HAVE_FUNCTION_MACRO
> +#define afs_osi_Alloc(size) afs_osi_Alloc_debug((size), __FUNCTION__,
> __LINE__)
> +#else
> +#define afs_osi_Alloc(size) afs_osi_Alloc_debug((size), "unknown", 0)
> +#endif
> +
>  #define afs_osi_Alloc_NoSleep afs_osi_Alloc
> =20
>  /*
>=20
> --- afs/afs_prototypes.h	17 Mar 2004 06:43:34 -0000	1.47
> +++ afs/afs_prototypes.h	26 Apr 2004 21:50:30 -0000
> @@ -464,7 +464,7 @@
>  extern void afs_osi_RxkRegister(void);
>  extern void afs_osi_MaskSignals(void);
>  extern void afs_osi_UnmaskRxkSignals(void);
> -extern void *afs_osi_Alloc(size_t x);
> +extern void *afs_osi_Alloc_debug(size_t x, char *func, int line);
>  #ifndef afs_osi_Alloc_NoSleep
>  extern void *afs_osi_Alloc_NoSleep(size_t x);
>  #endif
>=20
> --- afs/UKERNEL/afs_usrops.c	16 Apr 2004 00:34:38 -0000	1.25
> +++ afs/UKERNEL/afs_usrops.c	26 Apr 2004 21:50:30 -0000
> @@ -926,7 +926,7 @@
>  static char *afs_check_string2 =3D "AFS_OSI_";
> =20
>  void *
> -afs_osi_Alloc(size_t size)
> +afs_osi_Alloc_debug(size_t size, char *func, int line)
>  {
>      return malloc(size);
>  }
>=20
> --- rx/xdr.h	10 Mar 2004 23:01:54 -0000	1.11
> +++ rx/xdr.h	26 Apr 2004 21:50:30 -0000
> @@ -95,7 +95,12 @@
>  #define	osi_free		afs_osi_Free
> =20
>  /* keep here for now, 64 bit issues */
> -extern void *afs_osi_Alloc(size_t x);
> +extern void *afs_osi_Alloc_debug(size_t x, char *func, int line);
> +#ifdef HAVE_FUNCTION_MACRO
> +#define afs_osi_Alloc(size) afs_osi_Alloc_debug((size), __FUNCTION__,
> __LINE__)
> +#else
> +#define afs_osi_Alloc(size) afs_osi_Alloc_debug((size), "unknown", 0)
> +#endif
>  #ifndef afs_osi_Alloc_NoSleep
>  extern void *afs_osi_Alloc_NoSleep(size_t x);
>  #endif
>=20
>=20
>=20
>=20