Re: [PATCH 2/2] fs: proc/stat: use usual seq_file ops rather than single_open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux