From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755227AbaFLGwg (ORCPT ); Thu, 12 Jun 2014 02:52:36 -0400 Received: from mail-ie0-f178.google.com ([209.85.223.178]:46845 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752334AbaFLGwe (ORCPT ); Thu, 12 Jun 2014 02:52:34 -0400 Date: Wed, 11 Jun 2014 23:52:31 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Ian Kent cc: Heiko Carstens , Andrew Morton , Christoph Hellwig , KAMEZAWA Hiroyuki , Andrea Righi , Eric Dumazet , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Hendrik Brueckner , Thorsten Diehl , "Elliott, Robert (Server Storage)" , Al Viro Subject: Re: [PATCH 2/2] fs: proc/stat: use usual seq_file ops rather than single_open In-Reply-To: <1402554262.2642.16.camel@perseus.fritz.box> Message-ID: References: <20140521122521.GB7471@osiris> <20140521143229.GA32011@infradead.org> <20140528085841.GA4219@osiris> <20140528090153.GC4219@osiris> <20140528153704.b2a3f46dc39ebf8f681d528a@linux-foundation.org> <1402301519.2775.47.camel@perseus.fritz.box> <20140611124301.GC4296@osiris> <1402554262.2642.16.camel@perseus.fritz.box> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > > #include > > > #include > > > +#include > > > #include > > > #include > > > +#include > > > > > > #include > > > #include > > > @@ -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.