Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
78a6728c
Commit
78a6728c
authored
Jun 01, 2002
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify uidhash table allocation - no need to make it dynamic,
as it isn't even all that big.
parent
c32ed714
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
21 deletions
+5
-21
kernel/user.c
kernel/user.c
+5
-21
No files found.
kernel/user.c
View file @
78a6728c
...
@@ -20,13 +20,11 @@
...
@@ -20,13 +20,11 @@
#define UIDHASH_BITS 8
#define UIDHASH_BITS 8
#define UIDHASH_SZ (1 << UIDHASH_BITS)
#define UIDHASH_SZ (1 << UIDHASH_BITS)
#define UIDHASH_MASK (UIDHASH_SZ - 1)
#define UIDHASH_MASK (UIDHASH_SZ - 1)
#define __uidhashfn(uid) (((uid >> UIDHASH_BITS)
^
uid) & UIDHASH_MASK)
#define __uidhashfn(uid) (((uid >> UIDHASH_BITS)
+
uid) & UIDHASH_MASK)
#define uidhashentry(uid) (uidhash_table + __uidhashfn(
uid
))
#define uidhashentry(uid) (uidhash_table + __uidhashfn(
(uid)
))
static
kmem_cache_t
*
uid_cachep
;
static
kmem_cache_t
*
uid_cachep
;
static
struct
list_head
*
uidhash_table
;
static
struct
list_head
uidhash_table
[
UIDHASH_SZ
];
static
unsigned
uidhash_size
;
static
unsigned
uidhash_bits
;
static
spinlock_t
uidhash_lock
=
SPIN_LOCK_UNLOCKED
;
static
spinlock_t
uidhash_lock
=
SPIN_LOCK_UNLOCKED
;
struct
user_struct
root_user
=
{
struct
user_struct
root_user
=
{
...
@@ -116,7 +114,7 @@ struct user_struct * alloc_uid(uid_t uid)
...
@@ -116,7 +114,7 @@ struct user_struct * alloc_uid(uid_t uid)
static
int
__init
uid_cache_init
(
void
)
static
int
__init
uid_cache_init
(
void
)
{
{
int
size
,
n
;
int
n
;
uid_cachep
=
kmem_cache_create
(
"uid_cache"
,
sizeof
(
struct
user_struct
),
uid_cachep
=
kmem_cache_create
(
"uid_cache"
,
sizeof
(
struct
user_struct
),
0
,
0
,
...
@@ -124,21 +122,7 @@ static int __init uid_cache_init(void)
...
@@ -124,21 +122,7 @@ static int __init uid_cache_init(void)
if
(
!
uid_cachep
)
if
(
!
uid_cachep
)
panic
(
"Cannot create uid taskcount SLAB cache
\n
"
);
panic
(
"Cannot create uid taskcount SLAB cache
\n
"
);
size
=
UIDHASH_SZ
*
sizeof
(
struct
list_head
);
for
(
n
=
0
;
n
<
UIDHASH_SZ
;
++
n
)
do
{
uidhash_table
=
(
struct
list_head
*
)
kmalloc
(
size
,
GFP_ATOMIC
);
if
(
!
uidhash_table
)
size
>>=
1
;
}
while
(
!
uidhash_table
&&
size
>=
sizeof
(
struct
list_head
));
if
(
!
uidhash_table
)
panic
(
"Failed to allocate uid hash table!
\n
"
);
uidhash_size
=
size
/
sizeof
(
struct
list_head
);
uidhash_bits
=
ffz
(
uidhash_size
);
for
(
n
=
0
;
n
<
uidhash_size
;
++
n
)
INIT_LIST_HEAD
(
uidhash_table
+
n
);
INIT_LIST_HEAD
(
uidhash_table
+
n
);
/* Insert the root user immediately - init already runs with this */
/* Insert the root user immediately - init already runs with this */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment