This is a test repository.
Révision | f702e1107601230eec707739038a89018ea3468d (tree) |
---|---|
l'heure | 2021-12-15 20:13:55 |
Auteur | Tetsuo Handa <penguin-kernel@I-lo...> |
Commiter | Tetsuo Handa |
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 <penguin-kernel@I-love.SAKURA.ne.jp>
@@ -1056,7 +1056,6 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r) | ||
1056 | 1056 | list_for_each_entry_rcu(ptr, &domain->acl_info_list, list, |
1057 | 1057 | srcu_read_lock_held(&tomoyo_ss)) { |
1058 | 1058 | u16 perm; |
1059 | - u8 i; | |
1060 | 1059 | |
1061 | 1060 | if (ptr->is_deleted) |
1062 | 1061 | continue; |
@@ -1067,23 +1066,23 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r) | ||
1067 | 1066 | */ |
1068 | 1067 | switch (ptr->type) { |
1069 | 1068 | 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); | |
1071 | 1070 | break; |
1072 | 1071 | 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); | |
1074 | 1073 | break; |
1075 | 1074 | 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) | |
1077 | 1076 | ->perm); |
1078 | 1077 | break; |
1079 | 1078 | 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); | |
1081 | 1080 | break; |
1082 | 1081 | 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); | |
1084 | 1083 | break; |
1085 | 1084 | 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); | |
1087 | 1086 | break; |
1088 | 1087 | case TOMOYO_TYPE_MANUAL_TASK_ACL: |
1089 | 1088 | perm = 0; |
@@ -1091,9 +1090,7 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r) | ||
1091 | 1090 | default: |
1092 | 1091 | perm = 1; |
1093 | 1092 | } |
1094 | - for (i = 0; i < 16; i++) | |
1095 | - if (perm & (1 << i)) | |
1096 | - count++; | |
1093 | + count += hweight16(perm); | |
1097 | 1094 | } |
1098 | 1095 | if (count < tomoyo_profile(domain->ns, domain->profile)-> |
1099 | 1096 | pref[TOMOYO_PREF_MAX_LEARNING_ENTRY]) |