mips: cacheinfo: report shared CPU map
Subsystems (3)
Sasha Levin
maintainerPATCH 1/26 mips: cacheinfo: report shared CPU map
From: Vladimir Kondratiev <[email protected]>
[ Upstream commit 3b1313eb32c499d46dc4c3e896d19d9564c879c4 ]
Report L1 caches as shared per core; L2 - per cluster.
This fixes "perf" that went crazy if shared_cpu_map attribute not reported on sysfs, in form of
/sys/devices/system/cpu/cpu*/cache/index*/shared_cpu_list /sys/devices/system/cpu/cpu*/cache/index*/shared_cpu_map
--- arch/mips/kernel/cacheinfo.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
arch/mips/kernel/cacheinfo.c +26 -1
@@ -50,6 +50,25 @@ static int __init_cache_level(unsigned int cpu)return 0 ; } +static void fill_cpumask_siblings (int cpu,cpumask_t *cpu_map) +{ +int cpu1; + +for_each_possible_cpu (cpu1) +if (cpus_are_siblings (cpu, cpu1)) +cpumask_set_cpu (cpu1, cpu_map); +} + +static void fill_cpumask_cluster (int cpu,cpumask_t *cpu_map) +{ +int cpu1; +int cluster =cpu_cluster (&cpu_data[cpu]); + +for_each_possible_cpu (cpu1) +if (cpu_cluster (&cpu_data[cpu1]) == cluster) +cpumask_set_cpu (cpu1, cpu_map); +} +static int __populate_cache_leaves (unsigned int cpu) {struct cpuinfo_mips *c = ¤t_cpu_data;
@@ -57,14 +76,20 @@ static int __populate_cache_leaves(unsigned int cpu)struct cacheinfo *this_leaf = this_cpu_ci->info_list;if (c->icache.waysize) { +/* L1 caches are per core */ +fill_cpumask_siblings (cpu, &this_leaf->shared_cpu_map);populate_cache (dcache, this_leaf,1 ,CACHE_TYPE_DATA ); +fill_cpumask_siblings (cpu, &this_leaf->shared_cpu_map);populate_cache (icache, this_leaf,1 ,CACHE_TYPE_INST ); }else {populate_cache (dcache, this_leaf,1 ,CACHE_TYPE_UNIFIED ); } -if (c->scache.waysize) +if (c->scache.waysize) { +/* L2 cache is per cluster */ +fill_cpumask_cluster (cpu, &this_leaf->shared_cpu_map);populate_cache (scache, this_leaf,2 ,CACHE_TYPE_UNIFIED ); + }if (c->tcache.waysize)populate_cache (tcache, this_leaf,3 ,CACHE_TYPE_UNIFIED );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/26 mips: Fix gettimeofday() in the vdso library
From: Vincenzo Frascino <[email protected]>
[ Upstream commit 7d2aa4bb90f5f6f1b8de8848c26042403f2d7bf9 ]
The libc provides a discovery mechanism for vDSO library and its symbols. When a symbol is not exposed by the vDSOs the libc falls back on the system calls.
With the introduction of the unified vDSO library on mips this behavior is not honored anymore by the kernel in the case of gettimeofday().
The issue has been noticed and reported due to a dhclient failure on the CI20 board:
root@letux:~# dhclient ../../../../lib/isc/unix/time.c:200: Operation not permitted root@letux:~#
Restore the original behavior fixing gettimeofday() in the vDSO library.
--- arch/mips/include/asm/vdso/gettimeofday.h | 13 ------------- arch/mips/vdso/vgettimeofday.c | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-)
arch/mips/include/asm/vdso/gettimeofday.h +0 -13
@@ -26,8 +26,6 @@#define __VDSO_USE_SYSCALL ULLONG_MAX -#ifdef CONFIG_MIPS_CLOCK_VSYSCALL -static __always_inline long gettimeofday_fallback (struct __kernel_old_timeval *_tv,struct timezone *_tz)
@@ -48,17 +46,6 @@ static __always_inline long gettimeofday_fallback(return error ? -ret : ret; } -#else - -static __always_inline long gettimeofday_fallback ( -struct __kernel_old_timeval *_tv, -struct timezone *_tz) -{ -return -1 ; -} - -#endif -static __always_inline long clock_gettime_fallback (clockid_t _clkid,struct __kernel_timespec *_ts)
arch/mips/vdso/vgettimeofday.c +20 -0
@@ -17,12 +17,22 @@ int __vdso_clock_gettime(clockid_t clock,return __cvdso_clock_gettime32 (clock, ts); } +#ifdef CONFIG_MIPS_CLOCK_VSYSCALL + +/* +* This is behind the ifdef so that we don't provide the symbol when there's no +* possibility of there being a usable clocksource, because there's nothing we +* can do without it. When libc fails the symbol lookup it should fall back on +* the standard syscall path. +*/ int __vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) {return __cvdso_gettimeofday (tv, tz); } +#endif /* CONFIG_MIPS_CLOCK_VSYSCALL */ +int __vdso_clock_getres (clockid_t clock_id,struct old_timespec32 *res) {
@@ -43,12 +53,22 @@ int __vdso_clock_gettime(clockid_t clock,return __cvdso_clock_gettime (clock, ts); } +#ifdef CONFIG_MIPS_CLOCK_VSYSCALL + +/* +* This is behind the ifdef so that we don't provide the symbol when there's no +* possibility of there being a usable clocksource, because there's nothing we +* can do without it. When libc fails the symbol lookup it should fall back on +* the standard syscall path. +*/ int __vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) {return __cvdso_gettimeofday (tv, tz); } +#endif /* CONFIG_MIPS_CLOCK_VSYSCALL */ +int __vdso_clock_getres (clockid_t clock_id,struct __kernel_timespec *res) {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/26 tomoyo: Suppress RCU warning at list_for_each_entry_rcu().
In reply to Sasha LevinFrom: Tetsuo Handa <[email protected]>
[ Upstream commit 6bd5ce6089b561f5392460bfb654dea89356ab1b ]
John Garry has reported that allmodconfig kernel on arm64 causes flood of "RCU-list traversed in non-reader section!!" warning. I don't know what change caused this warning, but this warning is safe because TOMOYO uses SRCU lock instead. Let's suppress this warning by explicitly telling that the caller is holding SRCU lock.
--- security/tomoyo/common.c | 9 ++++++--- security/tomoyo/domain.c | 15 ++++++++++----- security/tomoyo/group.c | 9 ++++++--- security/tomoyo/util.c | 6 ++++-- 4 files changed, 26 insertions(+), 13 deletions(-)
security/tomoyo/common.c +6 -3
@@ -951,7 +951,8 @@ static bool tomoyo_manager(void) exe =tomoyo_get_exe ();if (!exe)return false; -list_for_each_entry_rcu (ptr, &tomoyo_kernel_namespace.policy_list[TOMOYO_ID_MANAGER ], head.list) { +list_for_each_entry_rcu (ptr, &tomoyo_kernel_namespace.policy_list[TOMOYO_ID_MANAGER ], head.list, +srcu_read_lock_held (&tomoyo_ss)) {if (!ptr->head.is_deleted && (!tomoyo_pathcmp (domainname, ptr->manager) || !strcmp (exe, ptr->manager->name))) {
@@ -1095,7 +1096,8 @@ static int tomoyo_delete_domain(char *domainname)if (mutex_lock_interruptible (&tomoyo_policy_lock))return -EINTR ;/* Is there an active domain? */ -list_for_each_entry_rcu (domain, &tomoyo_domain_list, list) { +list_for_each_entry_rcu (domain, &tomoyo_domain_list, list, +srcu_read_lock_held (&tomoyo_ss)) {/* Never delete tomoyo_kernel_domain */ if (domain == &tomoyo_kernel_domain)continue ;
@@ -2778,7 +2780,8 @@ void tomoyo_check_profile(void) tomoyo_policy_loaded = true;pr_info ("TOMOYO: 2.6.0\n" ); -list_for_each_entry_rcu (domain, &tomoyo_domain_list, list) { +list_for_each_entry_rcu (domain, &tomoyo_domain_list, list, +srcu_read_lock_held (&tomoyo_ss)) {const u8 profile = domain->profile;struct tomoyo_policy_namespace *ns = domain->ns;
security/tomoyo/domain.c +10 -5
@@ -41,7 +41,8 @@ int tomoyo_update_policy(struct tomoyo_acl_head *new_entry, const int size,if (mutex_lock_interruptible (&tomoyo_policy_lock))return -ENOMEM ; -list_for_each_entry_rcu (entry, list, list) { +list_for_each_entry_rcu (entry, list, list, +srcu_read_lock_held (&tomoyo_ss)) {if (entry->is_deleted ==TOMOYO_GC_IN_PROGRESS )continue ;if (!check_duplicate (entry, new_entry))
@@ -119,7 +120,8 @@ int tomoyo_update_domain(struct tomoyo_acl_info *new_entry, const int size, }if (mutex_lock_interruptible (&tomoyo_policy_lock)) goto out; -list_for_each_entry_rcu (entry, list, list) { +list_for_each_entry_rcu (entry, list, list, +srcu_read_lock_held (&tomoyo_ss)) {if (entry->is_deleted ==TOMOYO_GC_IN_PROGRESS )continue ; if (!tomoyo_same_acl_head(entry, new_entry) ||
@@ -166,7 +168,8 @@ void tomoyo_check_acl(struct tomoyo_request_info *r,u16 i =0 ; retry: -list_for_each_entry_rcu (ptr, list, list) { +list_for_each_entry_rcu (ptr, list, list, +srcu_read_lock_held (&tomoyo_ss)) {if (ptr->is_deleted || ptr->type != r->param_type)continue ;if (!check_entry (r, ptr))
@@ -298,7 +301,8 @@ static inline bool tomoyo_scan_transition {const struct tomoyo_transition_control *ptr; -list_for_each_entry_rcu (ptr, list, head.list) { +list_for_each_entry_rcu (ptr, list, head.list, +srcu_read_lock_held (&tomoyo_ss)) {if (ptr->head.is_deleted || ptr->type != type)continue ;if (ptr->domainname) {
@@ -735,7 +739,8 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)/* Check 'aggregator' directive. */ candidate = &exename; -list_for_each_entry_rcu (ptr, list, head.list) { +list_for_each_entry_rcu (ptr, list, head.list, +srcu_read_lock_held (&tomoyo_ss)) {if (ptr->head.is_deleted || !tomoyo_path_matches_pattern (&exename, ptr->original_name))
security/tomoyo/group.c +6 -3
@@ -133,7 +133,8 @@ tomoyo_path_matches_group(const struct tomoyo_path_info *pathname, {struct tomoyo_path_group *member; -list_for_each_entry_rcu (member, &group->member_list, head.list) { +list_for_each_entry_rcu (member, &group->member_list, head.list, +srcu_read_lock_held (&tomoyo_ss)) {if (member->head.is_deleted)continue ;if (!tomoyo_path_matches_pattern (pathname, member->member_name))
@@ -161,7 +162,8 @@ bool tomoyo_number_matches_group(const unsigned long min,struct tomoyo_number_group *member;bool matched = false; -list_for_each_entry_rcu (member, &group->member_list, head.list) { +list_for_each_entry_rcu (member, &group->member_list, head.list, +srcu_read_lock_held (&tomoyo_ss)) {if (member->head.is_deleted)continue ; if (min > member->number.values[1] ||
@@ -191,7 +193,8 @@ bool tomoyo_address_matches_group(const bool is_ipv6, const __be32 *address,bool matched = false;const u8 size = is_ipv6 ?16 :4 ; -list_for_each_entry_rcu (member, &group->member_list, head.list) { +list_for_each_entry_rcu (member, &group->member_list, head.list, +srcu_read_lock_held (&tomoyo_ss)) {if (member->head.is_deleted)continue ;if (member->address.is_ipv6 != is_ipv6)
security/tomoyo/util.c +4 -2
@@ -594,7 +594,8 @@ struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname) name.name = domainname;tomoyo_fill_path_info (&name); -list_for_each_entry_rcu (domain, &tomoyo_domain_list, list) { +list_for_each_entry_rcu (domain, &tomoyo_domain_list, list, +srcu_read_lock_held (&tomoyo_ss)) {if (!domain->is_deleted && !tomoyo_pathcmp (&name, domain->domainname))return domain;
@@ -1028,7 +1029,8 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)return false;if (!domain)return true; -list_for_each_entry_rcu (ptr, &domain->acl_info_list, list) { +list_for_each_entry_rcu (ptr, &domain->acl_info_list, list, +srcu_read_lock_held (&tomoyo_ss)) {u16 perm;u8 i;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/26 MIPS: Prevent link failure with kcov instrumentation
In reply to Sasha LevinFrom: Jouni Hogander <[email protected]>
[ Upstream commit a4a3893114a41e365274d5fab5d9ff5acc235ff0 ]
__sanitizer_cov_trace_pc() is not linked in and causing link failure if KCOV_INSTRUMENT is enabled. Fix this by disabling instrumentation for compressed image.
--- arch/mips/boot/compressed/Makefile | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/boot/compressed/Makefile +3 -0
@@ -29,6 +29,9 @@ KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) +# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. +KCOV_INSTRUMENT := n + # decompressor objects (linked with vmlinuz) vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
Signature · 1 line
2.20.1