From owner-svn-src-head@freebsd.org Fri Dec 27 11:35:16 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F31151EAF85; Fri, 27 Dec 2019 11:35:15 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smarthost1.greenhost.nl (smarthost1.greenhost.nl [195.190.28.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47kl9t5LB3z41gq; Fri, 27 Dec 2019 11:35:14 +0000 (UTC) (envelope-from ronald-lists@klop.ws) Received: from smtp.greenhost.nl ([213.108.110.112]) by smarthost1.greenhost.nl with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ikntg-00035u-E4; Fri, 27 Dec 2019 12:35:12 +0100 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, "Mateusz Guzik" Subject: Re: svn commit: r356120 - head/sys/security/mac References: <201912271123.xBRBNWow013539@repo.freebsd.org> Date: Fri, 27 Dec 2019 12:33:56 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Ronald Klop" Message-ID: In-Reply-To: <201912271123.xBRBNWow013539@repo.freebsd.org> User-Agent: Opera Mail/12.16 (FreeBSD) X-Authenticated-As-Hash: 398f5522cb258ce43cb679602f8cfe8b62a256d1 X-Virus-Scanned: by clamav at smarthost1.samage.net X-Spam-Level: / X-Spam-Score: -0.2 X-Spam-Status: No, score=-0.2 required=5.0 tests=ALL_TRUSTED, BAYES_50 autolearn=disabled version=3.4.2 X-Scan-Signature: d3d6c6694e059b137bd8e4e2c0542d46 X-Rspamd-Queue-Id: 47kl9t5LB3z41gq X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of ronald-lists@klop.ws designates 195.190.28.88 as permitted sender) smtp.mailfrom=ronald-lists@klop.ws X-Spamd-Result: default: False [-2.53 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip4:195.190.28.64/27]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[klop.ws]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_DN_SOME(0.00)[]; IP_SCORE(-0.73)[ip: (-0.76), ipnet: 195.190.28.0/24(-0.29), asn: 47172(-2.60), country: NL(0.03)]; RCVD_IN_DNSWL_NONE(0.00)[88.28.190.195.list.dnswl.org : 127.0.10.0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MID_RHS_NOT_FQDN(0.50)[]; ASN(0.00)[asn:47172, ipnet:195.190.28.0/24, country:NL]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Dec 2019 11:35:16 -0000 On Fri, 27 Dec 2019 12:23:32 +0100, Mateusz Guzik 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"