Skip to content

Inline some hashtab functions to improve performance

Ondrej Mosnacek selinux 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest2 patches 2 repliesIn review
  2. v33 patches 6 repliesSuperseded
  3. v23 patches 2 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v14 patches7 repliesApplied

Changes in v4 from the cover letter

- drop patch 1 which is now applied
- add ACK from Stephen to the last patch
- use policydb_filenametr_search() in
filename_trans_read_helper_compat()

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2selinux: prepare for inlining of hashtab functionssecurity/selinux/ss/hashtab.c security/selinux/ss/hashtab.h security/selinux/ss/mls.c +4 more+110 -631 reply
2/2selinux: complete the inlining of hashtab functionssecurity/selinux/ss/hashtab.c security/selinux/ss/hashtab.h+63 -591 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchStephen Smalley
1/2A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/2] Inline some hashtab functions to improve performance

Right now, hashtab_search() and hashtab_insert() are defined in hashtab.c and need to call functions indirectly via function pointers. It turns out that defining (the relevent parts of) these functions inline in the header and passing the function pointers as arguments makes them significantly faster.

The first patch modifies the hashtab interface so that callbacks are always passed directly. The second patch finishes the job by moving some of the function definitions to the header.These could be also just one patch, but are kept separate for easier review of changes in the functions that are being moved around.

For more details, please refer to the respective patch descriptions.

Changes in v4:
- drop patch 1 which is now applied
- add ACK from Stephen to the last patch
- use policydb_filenametr_search() in
filename_trans_read_helper_compat()

Changes in v3:
- add perf numbers for two more use cases positively affected: policy load and MCS relabeling
- drop inlining of hashtab_map() (perf-testing that change alone showed zero difference in both policy load and relabeling time)
- reword the commit message of patch 2

I intended to refactor the code to hide the awkward hashtab funcions away, but it turned out the result would be even more messy than the current version, so I left the other code unchanged from v2. I do believe the performance gain is worth making the hashtab interface more low-level.

Changes in v2:
- drop already applied v1 patches 1 and 2
- reword patch descriptions to better explain what is going on and why
- split out some of the symtab changes into a separate patch
- tweak the signature and argument names of symtab_insert()

Ondrej Mosnacek (2):
selinux: prepare for inlining of hashtab functions
selinux: complete the inlining of hashtab functions

 security/selinux/ss/hashtab.c  | 59 +++-----------------------
 security/selinux/ss/hashtab.h  | 77 ++++++++++++++++++++++++++++------
 security/selinux/ss/mls.c      |  2 +-
 security/selinux/ss/policydb.c | 76 +++++++++++++++++++++++----------
 security/selinux/ss/policydb.h |  9 ++++
 security/selinux/ss/services.c |  4 +-
 security/selinux/ss/symtab.c   | 16 ++++---
 7 files changed, 147 insertions(+), 96 deletions(-)
Signature · 1 line
2.26.2