Skip to content

Commit f702e11

Browse files
Tetsuo HandaTetsuo Handa
authored andcommitted
tomoyo: use hwight16() in tomoyo_domain_quota_is_ok()
hwight16() is much faster. While we are at it, no need to include "perm =" part into data_race() macro, for perm is a local variable that cannot be accessed by other threads. Signed-off-by: Tetsuo Handa <[email protected]>
1 parent 04e57a2 commit f702e11

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

security/tomoyo/util.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,6 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)
10561056
list_for_each_entry_rcu(ptr, &domain->acl_info_list, list,
10571057
srcu_read_lock_held(&tomoyo_ss)) {
10581058
u16 perm;
1059-
u8 i;
10601059

10611060
if (ptr->is_deleted)
10621061
continue;
@@ -1067,33 +1066,31 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)
10671066
*/
10681067
switch (ptr->type) {
10691068
case TOMOYO_TYPE_PATH_ACL:
1070-
data_race(perm = container_of(ptr, struct tomoyo_path_acl, head)->perm);
1069+
perm = data_race(container_of(ptr, struct tomoyo_path_acl, head)->perm);
10711070
break;
10721071
case TOMOYO_TYPE_PATH2_ACL:
1073-
data_race(perm = container_of(ptr, struct tomoyo_path2_acl, head)->perm);
1072+
perm = data_race(container_of(ptr, struct tomoyo_path2_acl, head)->perm);
10741073
break;
10751074
case TOMOYO_TYPE_PATH_NUMBER_ACL:
1076-
data_race(perm = container_of(ptr, struct tomoyo_path_number_acl, head)
1075+
perm = data_race(container_of(ptr, struct tomoyo_path_number_acl, head)
10771076
->perm);
10781077
break;
10791078
case TOMOYO_TYPE_MKDEV_ACL:
1080-
data_race(perm = container_of(ptr, struct tomoyo_mkdev_acl, head)->perm);
1079+
perm = data_race(container_of(ptr, struct tomoyo_mkdev_acl, head)->perm);
10811080
break;
10821081
case TOMOYO_TYPE_INET_ACL:
1083-
data_race(perm = container_of(ptr, struct tomoyo_inet_acl, head)->perm);
1082+
perm = data_race(container_of(ptr, struct tomoyo_inet_acl, head)->perm);
10841083
break;
10851084
case TOMOYO_TYPE_UNIX_ACL:
1086-
data_race(perm = container_of(ptr, struct tomoyo_unix_acl, head)->perm);
1085+
perm = data_race(container_of(ptr, struct tomoyo_unix_acl, head)->perm);
10871086
break;
10881087
case TOMOYO_TYPE_MANUAL_TASK_ACL:
10891088
perm = 0;
10901089
break;
10911090
default:
10921091
perm = 1;
10931092
}
1094-
for (i = 0; i < 16; i++)
1095-
if (perm & (1 << i))
1096-
count++;
1093+
count += hweight16(perm);
10971094
}
10981095
if (count < tomoyo_profile(domain->ns, domain->profile)->
10991096
pref[TOMOYO_PREF_MAX_LEARNING_ENTRY])

0 commit comments

Comments
 (0)