lkml.org 
[lkml]   [2009]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2009-12-19 18:43    [W:0.048 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site