1

landlock: Optimize the number of calls to get_access_mask slightly

This call is now going through a function pointer,
and it is not as obvious any more that it will be inlined.

Signed-off-by: Günther Noack <gnoack@google.com>
Link: https://lore.kernel.org/r/20231208155121.1943775-4-gnoack@google.com
Fixes: 7a11275c37 ("landlock: Refactor layer helpers")
Signed-off-by: Mickaël Salaün <mic@digikod.net>
This commit is contained in:
Günther Noack 2023-12-08 16:51:15 +01:00 committed by Mickaël Salaün
parent b838dd7612
commit 0daaa610c8
No known key found for this signature in database
GPG Key ID: E5E3D0E88C82F6D2

View File

@ -723,11 +723,12 @@ landlock_init_layer_masks(const struct landlock_ruleset *const domain,
/* Saves all handled accesses per layer. */ /* Saves all handled accesses per layer. */
for (layer_level = 0; layer_level < domain->num_layers; layer_level++) { for (layer_level = 0; layer_level < domain->num_layers; layer_level++) {
const unsigned long access_req = access_request; const unsigned long access_req = access_request;
const access_mask_t access_mask =
get_access_mask(domain, layer_level);
unsigned long access_bit; unsigned long access_bit;
for_each_set_bit(access_bit, &access_req, num_access) { for_each_set_bit(access_bit, &access_req, num_access) {
if (BIT_ULL(access_bit) & if (BIT_ULL(access_bit) & access_mask) {
get_access_mask(domain, layer_level)) {
(*layer_masks)[access_bit] |= (*layer_masks)[access_bit] |=
BIT_ULL(layer_level); BIT_ULL(layer_level);
handled_accesses |= BIT_ULL(access_bit); handled_accesses |= BIT_ULL(access_bit);