linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
	"Larry H." <research@subreption.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH] Use kzfree in tty buffer management to enforce data sanitization
Date: Sun, 31 May 2009 10:05:36 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0905311002010.3435@localhost.localdomain> (raw)
In-Reply-To: <20090531112630.2c7f4f1d@lxorguk.ukuu.org.uk>



On Sun, 31 May 2009, Alan Cox wrote:

> > >        memset(buf->data, 0, N_TTY_BUF_SIZE);
> > >        if (PAGE_SIZE != N_TTY_BUF_SIZE)
> > >                kfree(...)
> > >        else
> > >                free_page(...)
> > >
> > >
> > > but quite frankly, I'm not convinced about these patches at all.
> > 
> > I wonder why the tty code has that N_TTY_BUF_SIZE special casing in
> > the first place? I think we can probably just get rid of it and thus
> > we can use kzfree() here if we want to.
> 
> Some platforms with very large page sizes override the use of page based
> allocators (eg older ARM would go around allocating 32K). The normal path
> is 4K or 8K page sized buffers.

I think Pekka meant the other way around - why don't we always just use 
kmalloc(N_TTY_BUF_SIZE)/kfree(), and drop the whole conditional "use page 
allocator" entirely?

I suspect the "use page allocator" is historical - ie the tty layer 
originally always did that, and then when people wanted to suppotr smaller 
areas than one page, they added the special case. I have this dim memory 
of the _original_ kmalloc not handling page-sized allocations well (due to 
embedded size/pointer overheads), but I think all current allocators are 
perfectly happy to allocate PAGE_SIZE buffers without slop.

If I'm right, then we could just use kmalloc/kfree unconditionally. Pekka?

			Linus

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2009-05-31 17:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-31  1:55 Larry H.
2009-05-31  2:04 ` Linus Torvalds
2009-05-31  2:35   ` Larry H.
2009-05-31  6:27     ` Pekka Enberg
2009-05-31  6:24   ` Pekka Enberg
2009-05-31 10:26     ` Alan Cox
2009-05-31 17:05       ` Linus Torvalds [this message]
2009-05-31 17:10         ` Alan Cox
2009-05-31 17:17         ` Pekka Enberg
2009-06-02 15:05         ` Christoph Lameter

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=alpine.LFD.2.01.0905311002010.3435@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=research@subreption.com \
    --cc=riel@redhat.com \
    /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