From: Ankur Arora <ankur.a.arora@oracle.com>
To: Paul Moore <paul@paul-moore.com>
Cc: Haakon Bugge <haakon.bugge@oracle.com>,
Eric Paris <eparis@redhat.com>,
"audit@vger.kernel.org" <audit@vger.kernel.org>,
Ankur Arora <ankur.a.arora@oracle.com>
Subject: Re: [PATCH 1/2] audit: Vary struct audit_entry alignment
Date: Tue, 19 Dec 2023 13:07:30 -0800 [thread overview]
Message-ID: <874jgdkijx.fsf@oracle.com> (raw)
In-Reply-To: <CAHC9VhSZ6cZ32f5z_aLkpSbSnpeFe53+NHNXfjyJzpOZ3x7mFw@mail.gmail.com>
Paul Moore <paul@paul-moore.com> writes:
> On Sat, Dec 16, 2023 at 11:25 AM Haakon Bugge <haakon.bugge@oracle.com> wrote:
>> > On 14 Dec 2023, at 00:54, Paul Moore <paul@paul-moore.com> wrote:
>> >
>> > Two things:
>> >
>> > 1. If we are going to create a kmem_cache pool we shouldn't create it
>> > here, it should be in its own audit_filter_init() function which is
>> > called from audit_init().
>>
>> Understood. Will fix.
>>
>> > 2. I'm not sure it makes a lot of sense to create a kmem_cache pool
>> > for audit filter entries, especially given the modest performance
>> > gains. Is there not some way to request cacheline alignment with
>> > kmalloc() or similar?
>>
>> The problem with today's kzmalloc() is lack of entropy on the lower order address bits, because the audit filter entries are aligned on a 512B boundary. IOW, they are too much aligned. The increased entropy is exactly what we get from using a kmem_cache which yields more L1D cache sets to be used.
>>
>> Although the performance gain is modest, the reduction in L1D cache misses is substantial and that will improve performance on most archs that employ a virtually indexed L1D cache. And, this commit acts as a prerequisite to avoid high variability in performance gain from the second commit in this series.
>
> My hesitation of using a kmem_cache object here remains, given the
> relatively limited and static filter rule configuration I would rather
> use a k*malloc() based approach.
AFAICT, kmalloc() etc only allows fixed alignment. From
Documentation/core-api/memory-allocation.rst:
The address of a chunk allocated with `kmalloc` is aligned to at least
ARCH_KMALLOC_MINALIGN bytes. For sizes which are a power of two, the
alignment is also guaranteed to be at least the respective size.
I had sent out a patch a while ago reducing the cost of the same
alignment issue. For me the most pernicious part was the fact that
syscall latency was good or poor based on how boot time factors
affected audit allocations.
So while I do agree with your hesitation on kmem_cache not being quite
the right interface for what are static allocations, I think it might
be worth it given the cost.
Thanks
--
ankur
next prev parent reply other threads:[~2023-12-19 21:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 10:28 [PATCH 0/2] audit: Further reduce syscall latency Håkon Bugge
2023-12-12 10:28 ` [PATCH 1/2] audit: Vary struct audit_entry alignment Håkon Bugge
2023-12-13 23:54 ` Paul Moore
2023-12-16 16:25 ` Haakon Bugge
2023-12-18 22:07 ` Paul Moore
2023-12-19 21:07 ` Ankur Arora [this message]
2023-12-19 21:27 ` Paul Moore
2023-12-12 10:28 ` [PATCH 2/2] audit: Apply codegen optimizations Håkon Bugge
2023-12-13 23:45 ` Paul Moore
2023-12-16 16:28 ` Haakon Bugge
2023-12-18 22:09 ` Paul Moore
2023-12-21 19:05 ` Haakon Bugge
2023-12-22 4:31 ` Paul Moore
2023-12-12 10:28 ` [PATCH 2/2] audit: Apply special optimizations Håkon Bugge
2023-12-12 10:39 ` Haakon Bugge
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=874jgdkijx.fsf@oracle.com \
--to=ankur.a.arora@oracle.com \
--cc=audit@vger.kernel.org \
--cc=eparis@redhat.com \
--cc=haakon.bugge@oracle.com \
--cc=paul@paul-moore.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