Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Dec 2019 12:33:56 +0100
From:      "Ronald Klop" <ronald-lists@klop.ws>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, "Mateusz Guzik" <mjg@freebsd.org>
Subject:   Re: svn commit: r356120 - head/sys/security/mac
Message-ID:  <op.0dgfqujxkndu52@sjakie>
In-Reply-To: <201912271123.xBRBNWow013539@repo.freebsd.org>
References:  <201912271123.xBRBNWow013539@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 27 Dec 2019 12:23:32 +0100, Mateusz Guzik <mjg@freebsd.org> wrote:

> Author: mjg
> Date: Fri Dec 27 11:23:32 2019
> New Revision: 356120
> URL: https://svnweb.freebsd.org/changeset/base/356120
>
> Log:
>   mac: use a sleepable rmlock instead of an sx lock
>  If any non-static modules are loaded (and mac_ntpd tends to be), the  
> lock is
>   taken all the time al over the kernel. On platforms like arm64 this  
> results in
>   an avoidable significant performance degradation. Since write-locking  
> is almost
>   never needed, use a primitive optimized towards read-locking.
>  Sample result of building the kernel on tmpfs 11 times:
>   stock           11142.80s user 6704.44s system 4924% cpu 6:02.42 total
>   patched         11118.95s user 2374.94s system 4547% cpu 4:56.71 total


Wow, this looks like a winner.

Ronald.


>
> Modified:
>   head/sys/security/mac/mac_framework.c
>
> Modified: head/sys/security/mac/mac_framework.c
> ==============================================================================
> --- head/sys/security/mac/mac_framework.c	Fri Dec 27 11:19:57  
> 2019	(r356119)
> +++ head/sys/security/mac/mac_framework.c	Fri Dec 27 11:23:32  
> 2019	(r356120)
> @@ -176,6 +176,7 @@ MALLOC_DEFINE(M_MACTEMP, "mactemp", "MAC temporary  
> lab
>  #ifndef MAC_STATIC
>  static struct rmlock mac_policy_rm;	/* Non-sleeping entry points. */
>  static struct sx mac_policy_sx;		/* Sleeping entry points. */
> +static struct rmslock mac_policy_rms;
>  #endif
> struct mac_policy_list_head mac_policy_list;
> @@ -209,7 +210,7 @@ mac_policy_slock_sleep(void)
>  	if (!mac_late)
>  		return;
> -	sx_slock(&mac_policy_sx);
> +	rms_rlock(&mac_policy_rms);
>  #endif
>  }
> @@ -233,7 +234,7 @@ mac_policy_sunlock_sleep(void)
>  	if (!mac_late)
>  		return;
> -	sx_sunlock(&mac_policy_sx);
> +	rms_runlock(&mac_policy_rms);
>  #endif
>  }
> @@ -249,6 +250,7 @@ mac_policy_xlock(void)
>  		return;
> 	sx_xlock(&mac_policy_sx);
> +	rms_wlock(&mac_policy_rms);
>  	rm_wlock(&mac_policy_rm);
>  #endif
>  }
> @@ -262,6 +264,7 @@ mac_policy_xunlock(void)
>  		return;
> 	rm_wunlock(&mac_policy_rm);
> +	rms_wunlock(&mac_policy_rms);
>  	sx_xunlock(&mac_policy_sx);
>  #endif
>  }
> @@ -294,6 +297,7 @@ mac_init(void)
>  	rm_init_flags(&mac_policy_rm, "mac_policy_rm", RM_NOWITNESS |
>  	    RM_RECURSE);
>  	sx_init_flags(&mac_policy_sx, "mac_policy_sx", SX_NOWITNESS);
> +	rms_init(&mac_policy_rms, "mac_policy_rms");
>  #endif
>  }
> _______________________________________________
> svn-src-all@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?op.0dgfqujxkndu52>