svn commit: r325264 - head/sys/kern
Mateusz Guzik
mjg at FreeBSD.org
Wed Nov 1 06:12:16 UTC 2017
Author: mjg
Date: Wed Nov 1 06:12:14 2017
New Revision: 325264
URL: https://svnweb.freebsd.org/changeset/base/325264
Log:
Save on loginclass list locking by checking if caller already uses the struct
Modified:
head/sys/kern/init_main.c
head/sys/kern/kern_loginclass.c
Modified: head/sys/kern/init_main.c
==============================================================================
--- head/sys/kern/init_main.c Wed Nov 1 05:51:20 2017 (r325263)
+++ head/sys/kern/init_main.c Wed Nov 1 06:12:14 2017 (r325264)
@@ -421,6 +421,9 @@ proc0_init(void *dummy __unused)
struct thread *td;
struct ucred *newcred;
struct uidinfo tmpuinfo;
+ struct loginclass tmplc = {
+ .lc_name = "",
+ };
vm_paddr_t pageablemem;
int i;
@@ -509,10 +512,11 @@ proc0_init(void *dummy __unused)
newcred->cr_uidinfo = newcred->cr_ruidinfo = &tmpuinfo;
newcred->cr_uidinfo = uifind(0);
newcred->cr_ruidinfo = uifind(0);
+ newcred->cr_loginclass = &tmplc;
+ newcred->cr_loginclass = loginclass_find("default");
/* End hack. creds get properly set later with thread_cow_get_proc */
curthread->td_ucred = NULL;
newcred->cr_prison = &prison0;
- newcred->cr_loginclass = loginclass_find("default");
proc_set_cred_init(p, newcred);
#ifdef AUDIT
audit_cred_kproc0(newcred);
Modified: head/sys/kern/kern_loginclass.c
==============================================================================
--- head/sys/kern/kern_loginclass.c Wed Nov 1 05:51:20 2017 (r325263)
+++ head/sys/kern/kern_loginclass.c Wed Nov 1 06:12:14 2017 (r325264)
@@ -131,9 +131,16 @@ struct loginclass *
loginclass_find(const char *name)
{
struct loginclass *lc, *new_lc;
+ struct ucred *cred;
if (name[0] == '\0' || strlen(name) >= MAXLOGNAME)
return (NULL);
+
+ lc = cred->cr_loginclass;
+ if (strcmp(name, lc->lc_name) == 0) {
+ loginclass_hold(lc);
+ return (lc);
+ }
rw_rlock(&loginclasses_lock);
lc = loginclass_lookup(name);
More information about the svn-src-head
mailing list