Conform L3 Cache Index Disable to Linux standards
PATCH 1/1 Conform L3 Cache Index Disable to Linux standards
The L3 Cache Index Disable feature to arch/x86/kernel/cpu/intel_cacheinfo.c accepted in 2.6.28 was inadvertently a preliminary version of the patch that should not have been accepted. It did not include ABI documentation and did not meet the usage standards of a /sys file.
This patch changes that code to use a proposed patch that had the maintainer's approval but was accidentally not accepted.
It also corrects prevents the patch from being used on AMD processors that do not currently support L3 Cache Index Disable.
-Mark Langsdorf
Operating System Research Center
AMD
Documentation/ABI/testing/sysfs-devices-cache_disable new file +18 -0
@@ -0,0 +1,18 @@ +What: /sys/devices/system/cpu/cpu*/cache/index*/cache_disable_X +Date: August 2008 +KernelVersion: 2.6.27 +Contact: [email protected] +Description: These files exist in every cpu's cache index directories. + There are currently 2 cache_disable_# files in each + directory. Reading from these files on a supported + processor will return that cache disable index value + for that processor and node. Writing to one of these + files will cause the specificed cache index to be disabled. + + Currently, only AMD Family 10h Processors support cache index + disable, and only for their L3 caches. See the BIOS and + Kernel Developer's Guide at + http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_do... + for formatting information and other details on the + cache index disable. +Users: [email protected]
arch/x86/kernel/cpu/intel_cacheinfo.c +75 -100
217 lines not on this page · raw message
Quoted 21 lines · On Wed, 18 Feb 2009 16:04:26 -0600 Mark Langsdorf <[email protected]>…
The L3 Cache Index Disable feature to
arch/x86/kernel/cpu/intel_cacheinfo.caccepted in 2.6.28 was inadvertently a preliminary version of the patch that should not have been accepted. It did not include ABI documentation and did not meet the usage standards of a /sys file.This patch changes that code to use a proposed patch that had the maintainer's approval but was accidentally not accepted.
It also corrects prevents the patch from being used on AMD processors that do not currently support L3 Cache Index Disable.
...
arch/x86/kernel/cpu/intel_cacheinfo.c +8
-0+show_cache_disable_##index(struct _cpuid4_info *this_leaf, char *buf) \ +{ \ + return show_cache_disable(this_leaf, buf, index); \ +} + +static ssize_t +store_cache_disable (struct _cpuid4_info *this_leaf,const char *buf, +size_t count,unsigned int index)
arch/x86/kernel/cpu/intel_cacheinfo.c static ssize_t show_##file_name \ · line 653
Quoted 10 lines
arch/x86/kernel/cpu/intel_cacheinfo.c +10
-0+{ +int node =cpu_to_node (first_cpu (this_leaf->shared_cpu_map)); +struct pci_dev *dev = k8_northbridges[node]; +ssize_t ret =0 ; +unsigned int val; + +if (!this_leaf->can_disable) +return -EINVAL ; + + ret =sscanf (buf,"%x" , &val);
We permit used input suzh as `42foo'?
strict_strtoul() would fix that.
arch/x86/kernel/cpu/intel_cacheinfo.c static ssize_t show_##file_name \ · line 658
Quoted 5 lines
arch/x86/kernel/cpu/intel_cacheinfo.c +5
-0+if (ret !=1 ) +return -EINVAL ; + +if (!capable (CAP_SYS_ADMIN )) +return -EPERM ;
It would make sense to do this earlier in the function.
Do we need to do it at all? File permissions do not suffice?
Quoted 7 lines
arch/x86/kernel/cpu/intel_cacheinfo.c +7
-0+ val |=0xc0000000 ; +pci_write_config_dword (dev,0x1BC + index *4 , val & ~0x40000000 ); +wbinvd (); +pci_write_config_dword (dev,0x1BC + index *4 , val); +return count; +} +