[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.0912190929180.3712@localhost.localdomain>
Date: Sat, 19 Dec 2009 09:40:56 -0800 (PST)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Andi Kleen <andi@...stfloor.org>
cc: Andrew Morton <akpm@...ux-foundation.org>, ebiederm@...ssion.com,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] [1/2] SYSCTL: Make bin_table not const
On Sat, 19 Dec 2009, Andi Kleen wrote:
>
> Turn all the bin_tables from const to non-const. This is needed for the next
> patch. Unfortunately there were a lot of them, so the patch is rather
> large, but it is completely mechanic.
Ouch. I hate this.
I'd much rather have a constant sysctl bin_table.
If the _only_ thing you want to do is to do a "warn-on-once" logic, I
would seriously suggest you use a small hash-table instead of turning
bin_table non-const.
IOW, d something like this:
#define WARN_ONCE_HASH_BITS (10)
#define WARN_ONCE_HASH_SIZE (1<<WARN_ONCE_HASH_BITS)
static DECLARE_BITMAP(warn_once_bitmap, WARN_ONCE_HASH_SIZE);
/*
* NOTE! We don't use the SMP-safe bit tests. We simply
* don't care enough.
*/
static void warn_on_bintable(const int *name, int nlen)
{
unsigned int hash = full_name_hash(name, nlen);
hash = hash_32(hash, WARN_ONCE_HASH_BITS);
if (__test_and_set_bit(warn_once_bitmap, hash))
return;
deprecated_sysctl_warning(name, nlen);
}
which should do the right thing in all practical circumstances.
(The above is obviously totally untested, I wrote it in the mail reader,
but it's obvious enough what the intent is).
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists