From: Paul Moore <paul@paul-moore.com>
To: Hongru Zhang <zhanghongru06@gmail.com>,
stephen.smalley.work@gmail.com, omosnace@redhat.com
Cc: linux-kernel@vger.kernel.org, selinux@vger.kernel.org,
zhanghongru@xiaomi.com
Subject: Re: [PATCH v3 2/2] selinux: improve bucket distribution uniformity of avc_hash()
Date: Thu, 16 Oct 2025 17:18:59 -0400 [thread overview]
Message-ID: <c77eac51a26a0248980027e9f3b3b564@paul-moore.com> (raw)
In-Reply-To: <000bce8f11d06684f70a29705dfd417747475b1a.1758859391.git.zhanghongru@xiaomi.com>
On Sep 26, 2025 Hongru Zhang <zhanghongru06@gmail.com> wrote:
>
> Under heavy stress testing (on an 8-core system sustaining over 50,000
> authentication events per second), sample once per second and take the
> mean of 1800 samples:
>
> 1. Bucket utilization rate and length of longest chain
> +--------------------------+-----------------------------------------+
> | | bucket utilization rate / longest chain |
> | +--------------------+--------------------+
> | | no-patch | with-patch |
> +--------------------------+--------------------+--------------------+
> | 512 nodes, 512 buckets | 52.5%/7.5 | 58.2%/6.2 |
> +--------------------------+--------------------+--------------------+
> | 1024 nodes, 512 buckets | 68.9%/12.1 | 82.4%/8.9 |
> +--------------------------+--------------------+--------------------+
> | 2048 nodes, 512 buckets | 83.7%/19.4 | 94.8%/15.2 |
> +--------------------------+--------------------+--------------------+
> | 8192 nodes, 8192 buckets | 49.5%/11.4 | 61.9%/6.6 |
> +--------------------------+--------------------+--------------------+
>
> 2. avc_search_node latency (total latency of hash operation and table
> lookup)
> +--------------------------+-----------------------------------------+
> | | latency of function avc_search_node |
> | +--------------------+--------------------+
> | | no-patch | with-patch |
> +--------------------------+--------------------+--------------------+
> | 512 nodes, 512 buckets | 87ns | 79ns |
> +--------------------------+--------------------+--------------------+
> | 1024 nodes, 512 buckets | 97ns | 91ns |
> +--------------------------+--------------------+--------------------+
> | 2048 nodes, 512 buckets | 118ns | 110ns |
> +--------------------------+--------------------+--------------------+
> | 8192 nodes, 8192 buckets | 106ns | 94ns |
> +--------------------------+--------------------+--------------------+
>
> Although the multiplication in the new hash algorithm has higher overhead
> than the bitwise operations in the original algorithm, the data shows
> that the new algorithm achieves better distribution, reducing average
> lookup time. Consequently, the total latency of hashing and table lookup
> is lower than before.
>
> Signed-off-by: Hongru Zhang <zhanghongru@xiaomi.com>
> Reviewed-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> ---
> security/selinux/avc.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
My understanding from previous iterations of this patch is that this new
hash function was AI generated and hasn't really gone through the any
rigorus analysis beyond the performance measurements above, is that
correct? I'm not opposed to using AI to assist in patch development or
algorithm creation, especially if there is some acknowledgement in the
commit description, but I do hold the patches to the same standard as
any other proposed change. For this reason, I would expect some third
party review of the hash function by someone with enough experience to
provide a reasonable analysis of the hash function in comparison to
other existing options.
... and yes, I do recognize that the existing AVC hash function likely
did not have to go through the same level of scrutiny, but it has the
significant advantage of being a known quantity, problems and all.
If you want to change the AVC hash to something else with better
performance, I suggest sticking with a well known hash algorithm,
ideally one already present in the kernel; that is going to be the
quickest path towards acceptance.
--
paul-moore.com
next prev parent reply other threads:[~2025-10-16 21:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 6:23 [PATCH v3 0/2] selinux: speed up avc_search_node() with large number of avc nodes Hongru Zhang
2025-09-26 6:23 ` [PATCH v3 1/2] selinux: Make avc cache slot size configurable during boot Hongru Zhang
2025-09-26 12:19 ` Stephen Smalley
2025-10-16 21:18 ` Paul Moore
2025-10-17 8:10 ` Hongru Zhang
2025-10-20 19:12 ` Paul Moore
2025-10-21 12:38 ` Hongru Zhang
2025-10-21 15:44 ` Paul Moore
2025-10-22 2:49 ` Hongru Zhang
2025-10-17 11:59 ` Stephen Smalley
2025-10-20 19:22 ` Paul Moore
2025-09-26 6:23 ` [PATCH v3 2/2] selinux: improve bucket distribution uniformity of avc_hash() Hongru Zhang
2025-09-26 12:26 ` Stephen Smalley
2025-10-16 21:18 ` Paul Moore [this message]
2025-10-17 9:53 ` Hongru Zhang
2025-10-20 19:44 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c77eac51a26a0248980027e9f3b3b564@paul-moore.com \
--to=paul@paul-moore.com \
--cc=linux-kernel@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=selinux@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
--cc=zhanghongru06@gmail.com \
--cc=zhanghongru@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®