lkml.org 
[lkml]   [2014]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] fs: proc/stat: use usual seq_file ops rather than single_open
From
Date
On Wed, 2014-06-11 at 23:52 -0700, David Rientjes wrote:
> On Thu, 12 Jun 2014, Ian Kent wrote:
>
> > > > diff --git a/fs/seq_file.c b/fs/seq_file.c
> > > > index 1d641bb108d2..fca78a04c0d1 100644
> > > > --- a/fs/seq_file.c
> > > > +++ b/fs/seq_file.c
> > > > @@ -8,8 +8,10 @@
> > > > #include <linux/fs.h>
> > > > #include <linux/export.h>
> > > > #include <linux/seq_file.h>
> > > > +#include <linux/vmalloc.h>
> > > > #include <linux/slab.h>
> > > > #include <linux/cred.h>
> > > > +#include <linux/mm.h>
> > > >
> > > > #include <asm/uaccess.h>
> > > > #include <asm/page.h>
> > > > @@ -82,6 +84,31 @@ int seq_open(struct file *file, const struct seq_operations *op)
> > > > }
> > > > EXPORT_SYMBOL(seq_open);
> > > >
> > > > +static void seq_alloc(struct seq_file *m)
> > > > +{
> > > > + m->size = PAGE_SIZE;
> > > > + m->buf = kmalloc(m->size, GFP_KERNEL | __GFP_NOWARN);
> > > > + if (!m->buf)
> > > > + m->buf = vmalloc(m->size);
> > > > +}
> > > > +
> > >
> > > If m->size is unconditionally PAGE_SIZE, then how is vmalloc() going to
> > > allocate this if kmalloc() fails?
> >
> > This is just the initial allocation.
> > If it runs out of room the allocation size doubles.
> >
> > I think 2*PAGE_SIZE is probably better here since that's closer to what
> > the original heuristic allocation requested and is likely to avoid
> > reallocations in most cases.
> >
> > The issue of kmalloc() failing for larger allocations on low speced
> > hardware with fragmented memory might succeed when vmalloc() is used
> > since it doesn't require contiguous memory chunks. But I guess the added
> > pressure on the page table might still be a problem, nevertheless it's
> > probably worth trying before bailing out.
> >
>
> I'm not quarreling about using vmalloc() for allocations that are
> high-order, I'm referring to the rather obvious fact that m->size is set
> to PAGE_SIZE unconditionally above and thus vmalloc() isn't going to help
> in the slightest.

LOL, yeah, if kmalloc() can't allocate a single page then we're in much
bigger trouble!

Ian




\
 
 \ /
  Last update: 2014-06-12 13:41    [W:0.075 / U:13.788 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site