The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Anton Altaparmakov <aia21@cam.ac.uk>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Linus Torvalds <torvalds@osdl.org>,
	linux-kernel@vger.kernel.org,
	linux-ntfs-dev@lists.sourceforge.net
Subject: Re: [PATCH 2/25] NTFS: Allow highmem kmalloc() in ntfs_malloc_nofs() and add _nofail() version.
Date: Fri, 09 Sep 2005 12:02:20 +0100	[thread overview]
Message-ID: <1126263740.24291.16.camel@imp.csi.cam.ac.uk> (raw)
In-Reply-To: <84144f0205090903366454da6@mail.gmail.com>

On Fri, 2005-09-09 at 13:36 +0300, Pekka Enberg wrote:
> On 9/9/05, Anton Altaparmakov <aia21@cam.ac.uk> wrote:
> > -static inline void *ntfs_malloc_nofs(unsigned long size)
> > +static inline void *__ntfs_malloc(unsigned long size,
> > +               unsigned int __nocast gfp_mask)
> >  {
> >         if (likely(size <= PAGE_SIZE)) {
> >                 BUG_ON(!size);
> >                 /* kmalloc() has per-CPU caches so is faster for now. */
> > -               return kmalloc(PAGE_SIZE, GFP_NOFS);
> > -               /* return (void *)__get_free_page(GFP_NOFS | __GFP_HIGHMEM); */
> > +               return kmalloc(PAGE_SIZE, gfp_mask);
> > +               /* return (void *)__get_free_page(gfp_mask); */
> >         }
> >         if (likely(size >> PAGE_SHIFT < num_physpages))
> > -               return __vmalloc(size, GFP_NOFS | __GFP_HIGHMEM, PAGE_KERNEL);
> > +               return __vmalloc(size, gfp_mask, PAGE_KERNEL);
> 
> Unrelated to this patch but why do you have this wrapper instead of
> using kmalloc() where you can and__vmalloc() where you really have to?

Very easy.  Allocations are variable sized.  Without the wrapper I would
have to copy and paste the wrapped code all over the ntfs driver as
there is no way to tell which one I would need in advance.

I used to simply use vmalloc() but that caused loads of people's
machines to run out of vmalloc space in a matter of hours and also
vmalloc is much slower so I added the kmalloc if a page and vmalloc
otherwise.

Note just using kmalloc is no good as it doesn't go high enough in size
(again this problem was being hit by people which is why I had switched
to vmalloc in the first place).

Also kmalloc with size > PAGE_SIZE used to cause machines to run OOM and
give page order > 1 allocation failures, hence why I never use kmalloc
for more than one page any more.

Also note I only use the ntfs_malloc_nofs() wrapper if I have to.  If I
know how much I am allocating or at least know that the maximum is quite
small, I use kmalloc() directly.  It is pretty much only for the runlist
allocations that I use the wrapper as the runlist is typically small but
for fragmented files it can grow huge.  I have seen runlists consuming
over 256kiB of ram, without vmalloc that would be a real problem...

Best regards,

        Anton
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/


  reply	other threads:[~2005-09-09 11:02 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-09  9:18 [2.6-GIT] NTFS: Release 2.1.24 Anton Altaparmakov
2005-09-09  9:19 ` [PATCH 1/25] NTFS: Support more clean journal ($LogFile) states Anton Altaparmakov
2005-09-09  9:19 ` [PATCH 2/25] NTFS: Allow highmem kmalloc() in ntfs_malloc_nofs() and add _nofail() version Anton Altaparmakov
2005-09-09 10:36   ` Pekka Enberg
2005-09-09 11:02     ` Anton Altaparmakov [this message]
2005-09-09 11:15       ` Pekka J Enberg
2005-09-09 11:25         ` Anton Altaparmakov
2005-09-09 11:38           ` Pekka J Enberg
2005-09-09 11:48             ` Anton Altaparmakov
2005-09-09 11:51               ` Anton Altaparmakov
2005-09-09 12:02                 ` Pekka J Enberg
2005-09-09 12:08                   ` Anton Altaparmakov
2005-09-09 19:15                     ` Horst von Brand
2005-09-09 14:51   ` Roland Dreier
2005-09-09 14:53     ` Christoph Hellwig
2005-09-09 14:58       ` Anton Altaparmakov
2005-09-09  9:21 ` [PATCH 3/25] NTFS: Use ntfs_malloc_nofs_nofail() in ntfs_runlists_merge() Anton Altaparmakov
2005-09-09  9:22 ` [PATCH 4/25] NTFS: Fix two nasty runlist merging bugs that had gone unnoticed so far Anton Altaparmakov
2005-09-09  9:22 ` [PATCH 5/25] NTFS: Remove two bogus BUG_ON()s from fs/ntfs/mft.c Anton Altaparmakov
2005-09-09  9:22 ` [PATCH 6/25] NTFS: Fix handling of valid but empty mapping pairs array Anton Altaparmakov
2005-09-09  9:23 ` [PATCH 7/25] NTFS: Report unrepresentable inodes during ntfs_readdir() as KERN_WARNING Anton Altaparmakov
2005-09-09  9:23 ` [PATCH 8/25] NTFS: Change ntfs_rl_truncate_nolock() to throw away the runlist if the new Anton Altaparmakov
2005-09-09  9:24 ` [PATCH 9/25] NTFS: Add ntfs_rl_punch_nolock() which punches a caller specified hole into a runlist Anton Altaparmakov
2005-09-09  9:24 ` [PATCH 10/25] NTFS: Fix a bug in fs/ntfs/index.c::ntfs_index_lookup() Anton Altaparmakov
2005-09-09  9:25 ` [PATCH 11/25] NTFS: Remove bogus setting of PageError in ntfs_read_compressed_block() Anton Altaparmakov
2005-09-09  9:26 ` [PATCH 12/25] NTFS: Add fs/ntfs/attrib.[hc]::ntfs_resident_attr_value_resize() Anton Altaparmakov
2005-09-09  9:26 ` [PATCH 13/25] NTFS: Fix several bugs in fs/ntfs/attrib.c Anton Altaparmakov
2005-09-09  9:27 ` [PATCH 14/25] NTFS: Fix handling of sparse attributes in ntfs_attr_make_non_resident() Anton Altaparmakov
2005-09-09  9:27 ` [PATCH 15/25] NTFS: Fix cluster (de)allocators to work when the runlist is NULL and more Anton Altaparmakov
2005-09-09  9:28 ` [PATCH 16/25] NTFS: Truncate {a,c,m}time to the ntfs supported time granularity when Anton Altaparmakov
2005-09-09  9:28 ` [PATCH 17/25] NTFS: Fixup handling of sparse, compressed, and encrypted attributes in Anton Altaparmakov
2005-09-09  9:28 ` [PATCH 18/25] NTFS: Make ntfs_write_block() not instantiate sparse blocks if they are zero Anton Altaparmakov
2005-09-09  9:29 ` [PATCH 19/25] NTFS: Fixup handling of sparse, compressed, and encrypted attributes in Anton Altaparmakov
2005-09-09  9:29 ` [PATCH 20/25] NTFS: Optimize fs/ntfs/aops.c::ntfs_write_block() by extending the page Anton Altaparmakov
2005-09-09  9:30 ` [PATCH 21/25] NTFS: Fix fs/ntfs/aops.c::ntfs_{read,write}_block() to handle the case Anton Altaparmakov
2005-09-09  9:30 ` [PATCH 22/25] NTFS: Fixup handling of sparse, compressed, and encrypted attributes in Anton Altaparmakov
2005-09-09  9:30 ` [PATCH 23/25] NTFS: Fix page_has_buffers()/page_buffers() handling in fs/ntfs/aops.c Anton Altaparmakov
2005-09-09  9:31 ` [PATCH 24/25] NTFS: Improve scalability by changing the driver global spin lock in Anton Altaparmakov
2005-09-09  9:32 ` [PATCH 25/25] NTFS: 2.1.24 release and some minor final fixes Anton Altaparmakov
2005-09-10 10:05 ` [2.6-GIT] NTFS: Release 2.1.24 Giuseppe Bilotta
2005-09-10 13:28   ` Anton Altaparmakov
2005-09-10 13:38     ` Anton Altaparmakov
2005-09-10 14:53     ` Bernd Eckenfels
2005-09-11 11:30     ` Giuseppe Bilotta
2005-09-12  2:13     ` Horst von Brand
2005-09-12  9:08       ` Anton Altaparmakov
2005-09-10 13:15 ` Alistair John Strachan
2005-09-10 13:23   ` Anton Altaparmakov
2005-09-25 19:12     ` Linux NTFS Vista compatibility (was: Re: [2.6-GIT] NTFS: Release 2.1.24.) Szakacsits Szabolcs
2005-09-25 22:35       ` Alistair John Strachan
2005-09-25 23:39         ` Szakacsits Szabolcs
2005-10-13 15:13         ` Alistair John Strachan
2005-10-13 15:18           ` Anton Altaparmakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1126263740.24291.16.camel@imp.csi.cam.ac.uk \
    --to=aia21@cam.ac.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ntfs-dev@lists.sourceforge.net \
    --cc=penberg@cs.helsinki.fi \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox