linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nick Piggin <nickpiggin@yahoo.com.au>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andrew Morton <akpm@osdl.org>,
	Christoph Lameter <clameter@sgi.com>,
	linux-mm@kvack.org
Subject: Re: Slab: Remove kmem_cache_t
Date: Wed, 29 Nov 2006 16:51:22 +1100	[thread overview]
Message-ID: <456D1FDA.4040201@yahoo.com.au> (raw)
In-Reply-To: <Pine.LNX.4.64.0611282027431.3395@woody.osdl.org>

Linus Torvalds wrote:
> 
> The _only_ valid reason to use typedefs ever is because it's a type that 
> depends on some configuration option (where "architecture" is obviously 
> the biggest config option of all).

I don't see why pagetable types are conceptually different from slab here.
kmem_cache_t might just be an integer (index into an array, or something).

> If the type has the same name regardless of config options, it should 
> never be a typedef. And "struct kmem_cache" obviously doesn't change names 
> just because of config options (it may change some of the _members_ it 
> contains, but that's a totally different thing, and has no bearing 
> what-so-ever on whether you should use a typedef).

pagetable types can all have the same struct name. Should we do a script
to change them?

> So typedefs are good for
> 
>  - "u8"/"u16"/"u32"/"u64" kind of things, where the underlying types 
>    really are potentially different on different architectures.
> 
>  - "sector_t"-like things which may be 32-bit or 64-bit depending on some 
>    CONFIG_LBD option or other.
> 
>  - as a special case, "sparse" actually makes bitwise typedefs have real 
>    meaning as types, so if you are using sparse to distinguish between a 
>    little-endian 16-bit entity or a big-endian 16-bit entity, the typedef 
>    there is actually important and has real meaning to sparse (without the 
>    typedef, each bitwise type declaration would be strictly a _different_ 
>    type from another bitwise type declaration that otherwise looks the 
>    same).
> 
> But typedefs are NOT good for:
> 
>  - trying to avoid typing a few characters:
> 
> 	"kmem_cache_t" is strictly _worse_ than "struct kmem_cache", not 
> 	just because it causes declaration issues. It also hides the fact 
> 	that the thing really is a structure (and hiding the fact that 
> 	it's a pointer is a shooting offense: things like "voidptr_t" 
> 	should not be allowed at all)

Umm, but it's not a pointer, is it? And I don't see any problem with making
it opaque to callers who don't and shouldn't care. I seem to remember you
making this argument for the pagetable types as well...

I think slab.c should use struct kmem_cache, but I don't see why this script
needs to change over all callers. At least, not in the name of solving
dependency issues?!?

>  - incorrect "portability". 
> 
> 	the POSIX "socklen_t" was not only a really bad way to write
> 	"int", it actually caused a lot of NON-portability, and made some 
> 	people think it should be "size_t" or something equally broken.
> 
> The one excuse for typedefs in the "typing" sense can be complicated 
> function pointer types. Some function pointers are just too easy to screw 
> up, and using a
> 
> 	typedef (*myfn_t)(int, ...);
> 
> can be preferable over forcing people to write that really complex kind of 
> type out every time. But that shouldn't be overused either (but we use it 
> for things like "readdir_t", for example, for exactly this reason).

Sure. I'm not arguing against it because it is too hard to type. I just
don't think it is solving any problem, and it seems to be rather pointless
churn.

If it was presented strictly as a cleanup patch then I would have less to
argue about, I guess: I'm not exactly pro-typedef for these situations, and
I'm definitely anti-typedef when you are accessing struct members.

-- 
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
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:[~2006-11-29  5:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-29  2:49 Christoph Lameter
2006-11-29  3:06 ` Andrew Morton
2006-11-29  4:06 ` Nick Piggin
2006-11-29  3:32   ` Christoph Lameter
2006-11-29  4:42     ` Nick Piggin
2006-11-29  3:48       ` Nick Piggin
2006-11-29  4:06       ` Andrew Morton
2006-11-29  4:38         ` Linus Torvalds
2006-11-29  5:51           ` Nick Piggin [this message]
2006-11-29 15:48             ` Linus Torvalds
2006-11-30  1:40               ` Nick Piggin
2006-11-30  1:59                 ` Linus Torvalds
2006-11-30  2:14                   ` Nick Piggin
2006-11-30  2:37                     ` Linus Torvalds
2006-11-30  2:51                       ` Nick Piggin
2006-11-29  6:21           ` Nick Piggin
2006-11-29 16:11             ` Linus Torvalds
2006-11-29  5:41         ` Nick Piggin
2006-11-29  6:24           ` Andrew Morton
2006-11-29  6:41             ` Nick Piggin
2006-11-29  7:08               ` Andrew Morton
2006-11-29  7:23                 ` Nick Piggin
2006-11-29  7:41                   ` Andrew Morton
2006-11-29  8:04                     ` Nick Piggin
2006-11-29 16:23                       ` Linus Torvalds
2006-11-30  1:44                         ` Nick Piggin
2006-11-29 19:16               ` Christoph Lameter
2006-11-29  8:50 ` Peter Zijlstra
2006-11-29 19:27   ` 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=456D1FDA.4040201@yahoo.com.au \
    --to=nickpiggin@yahoo.com.au \
    --cc=akpm@osdl.org \
    --cc=clameter@sgi.com \
    --cc=linux-mm@kvack.org \
    --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