Re: [PATCH 3/3] vmalloc: Add debugfs modfraginfo

From: Edgecombe, Rick P
Date: Thu Jun 21 2018 - 14:56:28 EST


On Thu, 2018-06-21 at 14:32 +0200, Jann Horn wrote:
> On Thu, Jun 21, 2018 at 12:12 AM Rick Edgecombe
> <rick.p.edgecombe@xxxxxxxxx> wrote:
> >
> > Add debugfs file "modfraginfo" for providing info on module space
> > fragmentation.ÂÂThis can be used for determining if loadable module
> > randomization is causing any problems for extreme module loading
> > situations,
> > like huge numbers of modules or extremely large modules.
> >
> > Sample output when RANDOMIZE_BASE and X86_64 is configured:
> > Largest free space:ÂÂÂÂÂÂÂÂÂÂÂÂÂ847253504
> > External Memory Fragementation: 20%
> > Allocations in backup area:ÂÂÂÂÂ0
> >
> > Sample output otherwise:
> > Largest free space:ÂÂÂÂÂÂÂÂÂÂÂÂÂ847253504
> > External Memory Fragementation: 20%
> [...]
> >
> > +ÂÂÂÂÂÂÂseq_printf(m, "Largest free space:\t\t%lu\n",
> > largest_free);
> > +ÂÂÂÂÂÂÂif (total_free)
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂseq_printf(m, "External Memory
> > Fragementation:\t%lu%%\n",
> "Fragmentation"
>
> >
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ100-(100*largest_free/total_free));
> > +ÂÂÂÂÂÂÂelse
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂseq_puts(m, "External Memory
> > Fragementation:\t0%%\n");
> "Fragmentation"

Oops! Thanks.

> [...]
> >
> > +static const struct file_operations debug_module_frag_operations =
> > {
> > +ÂÂÂÂÂÂÂ.openÂÂÂÂÂÂÂ= proc_module_frag_debug_open,
> > +ÂÂÂÂÂÂÂ.readÂÂÂÂÂÂÂ= seq_read,
> > +ÂÂÂÂÂÂÂ.llseekÂÂÂÂÂ= seq_lseek,
> > +ÂÂÂÂÂÂÂ.releaseÂÂÂÂ= single_release,
> > +};
> >
> > +static void debug_modfrag_init(void)
> > +{
> > +ÂÂÂÂÂÂÂdebugfs_create_file("modfraginfo", 0x0400, NULL, NULL,
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ&debug_module_frag_operations);
> 0x0400 is 02000, which is the setgid bit. I think you meant to type
> 0400?

Yes, thanks.