Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile

* git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile:
arch/tile: more /proc and /sys file support

+347 -28
+1
arch/tile/Kconfig
··· 11 11 select GENERIC_IRQ_PROBE 12 12 select GENERIC_PENDING_IRQ if SMP 13 13 select GENERIC_IRQ_SHOW 14 + select SYS_HYPERVISOR 14 15 15 16 # FIXME: investigate whether we need/want these options. 16 17 # select HAVE_IOREMAP_PROT
+12 -3
arch/tile/include/asm/hardwall.h
··· 40 40 #define HARDWALL_DEACTIVATE \ 41 41 _IO(HARDWALL_IOCTL_BASE, _HARDWALL_DEACTIVATE) 42 42 43 + #define _HARDWALL_GET_ID 4 44 + #define HARDWALL_GET_ID \ 45 + _IO(HARDWALL_IOCTL_BASE, _HARDWALL_GET_ID) 46 + 43 47 #ifndef __KERNEL__ 44 48 45 49 /* This is the canonical name expected by userspace. */ ··· 51 47 52 48 #else 53 49 54 - /* Hook for /proc/tile/hardwall. */ 55 - struct seq_file; 56 - int proc_tile_hardwall_show(struct seq_file *sf, void *v); 50 + /* /proc hooks for hardwall. */ 51 + struct proc_dir_entry; 52 + #ifdef CONFIG_HARDWALL 53 + void proc_tile_hardwall_init(struct proc_dir_entry *root); 54 + int proc_pid_hardwall(struct task_struct *task, char *buffer); 55 + #else 56 + static inline void proc_tile_hardwall_init(struct proc_dir_entry *root) {} 57 + #endif 57 58 58 59 #endif 59 60
+1 -1
arch/tile/kernel/Makefile
··· 5 5 extra-y := vmlinux.lds head_$(BITS).o 6 6 obj-y := backtrace.o entry.o init_task.o irq.o messaging.o \ 7 7 pci-dma.o proc.o process.o ptrace.o reboot.o \ 8 - setup.o signal.o single_step.o stack.o sys.o time.o traps.o \ 8 + setup.o signal.o single_step.o stack.o sys.o sysfs.o time.o traps.o \ 9 9 intvec_$(BITS).o regs_$(BITS).o tile-desc_$(BITS).o 10 10 11 11 obj-$(CONFIG_HARDWALL) += hardwall.o
+66 -24
arch/tile/kernel/hardwall.c
··· 40 40 struct hardwall_info { 41 41 struct list_head list; /* "rectangles" list */ 42 42 struct list_head task_head; /* head of tasks in this hardwall */ 43 + struct cpumask cpumask; /* cpus in the rectangle */ 43 44 int ulhc_x; /* upper left hand corner x coord */ 44 45 int ulhc_y; /* upper left hand corner y coord */ 45 46 int width; /* rectangle width */ 46 47 int height; /* rectangle height */ 48 + int id; /* integer id for this hardwall */ 47 49 int teardown_in_progress; /* are we tearing this one down? */ 48 50 }; 49 51 50 52 /* Currently allocated hardwall rectangles */ 51 53 static LIST_HEAD(rectangles); 54 + 55 + /* /proc/tile/hardwall */ 56 + static struct proc_dir_entry *hardwall_proc_dir; 57 + 58 + /* Functions to manage files in /proc/tile/hardwall. */ 59 + static void hardwall_add_proc(struct hardwall_info *rect); 60 + static void hardwall_remove_proc(struct hardwall_info *rect); 52 61 53 62 /* 54 63 * Guard changes to the hardwall data structures. ··· 114 105 r->ulhc_y = cpu_y(ulhc); 115 106 r->width = cpu_x(lrhc) - r->ulhc_x + 1; 116 107 r->height = cpu_y(lrhc) - r->ulhc_y + 1; 108 + cpumask_copy(&r->cpumask, mask); 109 + r->id = ulhc; /* The ulhc cpu id can be the hardwall id. */ 117 110 118 111 /* Width and height must be positive */ 119 112 if (r->width <= 0 || r->height <= 0) ··· 399 388 /* Set up appropriate hardwalling on all affected cpus. */ 400 389 hardwall_setup(rect); 401 390 391 + /* Create a /proc/tile/hardwall entry. */ 392 + hardwall_add_proc(rect); 393 + 402 394 return rect; 403 395 } 404 396 ··· 659 645 /* Restart switch and disable firewall. */ 660 646 on_each_cpu_mask(&mask, restart_udn_switch, NULL, 1); 661 647 648 + /* Remove the /proc/tile/hardwall entry. */ 649 + hardwall_remove_proc(rect); 650 + 662 651 /* Now free the rectangle from the list. */ 663 652 spin_lock_irqsave(&hardwall_lock, flags); 664 653 BUG_ON(!list_empty(&rect->task_head)); ··· 671 654 } 672 655 673 656 674 - /* 675 - * Dump hardwall state via /proc; initialized in arch/tile/sys/proc.c. 676 - */ 677 - int proc_tile_hardwall_show(struct seq_file *sf, void *v) 657 + static int hardwall_proc_show(struct seq_file *sf, void *v) 678 658 { 679 - struct hardwall_info *r; 659 + struct hardwall_info *rect = sf->private; 660 + char buf[256]; 680 661 681 - if (udn_disabled) { 682 - seq_printf(sf, "%dx%d 0,0 pids:\n", smp_width, smp_height); 683 - return 0; 684 - } 685 - 686 - spin_lock_irq(&hardwall_lock); 687 - list_for_each_entry(r, &rectangles, list) { 688 - struct task_struct *p; 689 - seq_printf(sf, "%dx%d %d,%d pids:", 690 - r->width, r->height, r->ulhc_x, r->ulhc_y); 691 - list_for_each_entry(p, &r->task_head, thread.hardwall_list) { 692 - unsigned int cpu = cpumask_first(&p->cpus_allowed); 693 - unsigned int x = cpu % smp_width; 694 - unsigned int y = cpu / smp_width; 695 - seq_printf(sf, " %d@%d,%d", p->pid, x, y); 696 - } 697 - seq_printf(sf, "\n"); 698 - } 699 - spin_unlock_irq(&hardwall_lock); 662 + int rc = cpulist_scnprintf(buf, sizeof(buf), &rect->cpumask); 663 + buf[rc++] = '\n'; 664 + seq_write(sf, buf, rc); 700 665 return 0; 666 + } 667 + 668 + static int hardwall_proc_open(struct inode *inode, 669 + struct file *file) 670 + { 671 + return single_open(file, hardwall_proc_show, PDE(inode)->data); 672 + } 673 + 674 + static const struct file_operations hardwall_proc_fops = { 675 + .open = hardwall_proc_open, 676 + .read = seq_read, 677 + .llseek = seq_lseek, 678 + .release = single_release, 679 + }; 680 + 681 + static void hardwall_add_proc(struct hardwall_info *rect) 682 + { 683 + char buf[64]; 684 + snprintf(buf, sizeof(buf), "%d", rect->id); 685 + proc_create_data(buf, 0444, hardwall_proc_dir, 686 + &hardwall_proc_fops, rect); 687 + } 688 + 689 + static void hardwall_remove_proc(struct hardwall_info *rect) 690 + { 691 + char buf[64]; 692 + snprintf(buf, sizeof(buf), "%d", rect->id); 693 + remove_proc_entry(buf, hardwall_proc_dir); 694 + } 695 + 696 + int proc_pid_hardwall(struct task_struct *task, char *buffer) 697 + { 698 + struct hardwall_info *rect = task->thread.hardwall; 699 + return rect ? sprintf(buffer, "%d\n", rect->id) : 0; 700 + } 701 + 702 + void proc_tile_hardwall_init(struct proc_dir_entry *root) 703 + { 704 + if (!udn_disabled) 705 + hardwall_proc_dir = proc_mkdir("hardwall", root); 701 706 } 702 707 703 708 ··· 754 715 if (current->thread.hardwall != rect) 755 716 return -EINVAL; 756 717 return hardwall_deactivate(current); 718 + 719 + case _HARDWALL_GET_ID: 720 + return rect ? rect->id : -EINVAL; 757 721 758 722 default: 759 723 return -EINVAL;
+73
arch/tile/kernel/proc.c
··· 27 27 #include <asm/processor.h> 28 28 #include <asm/sections.h> 29 29 #include <asm/homecache.h> 30 + #include <asm/hardwall.h> 30 31 #include <arch/chip.h> 31 32 32 33 ··· 89 88 .stop = c_stop, 90 89 .show = show_cpuinfo, 91 90 }; 91 + 92 + /* 93 + * Support /proc/tile directory 94 + */ 95 + 96 + static int __init proc_tile_init(void) 97 + { 98 + struct proc_dir_entry *root = proc_mkdir("tile", NULL); 99 + if (root == NULL) 100 + return 0; 101 + 102 + proc_tile_hardwall_init(root); 103 + 104 + return 0; 105 + } 106 + 107 + arch_initcall(proc_tile_init); 108 + 109 + /* 110 + * Support /proc/sys/tile directory 111 + */ 112 + 113 + #ifndef __tilegx__ /* FIXME: GX: no support for unaligned access yet */ 114 + static ctl_table unaligned_subtable[] = { 115 + { 116 + .procname = "enabled", 117 + .data = &unaligned_fixup, 118 + .maxlen = sizeof(int), 119 + .mode = 0644, 120 + .proc_handler = &proc_dointvec 121 + }, 122 + { 123 + .procname = "printk", 124 + .data = &unaligned_printk, 125 + .maxlen = sizeof(int), 126 + .mode = 0644, 127 + .proc_handler = &proc_dointvec 128 + }, 129 + { 130 + .procname = "count", 131 + .data = &unaligned_fixup_count, 132 + .maxlen = sizeof(int), 133 + .mode = 0644, 134 + .proc_handler = &proc_dointvec 135 + }, 136 + {} 137 + }; 138 + 139 + static ctl_table unaligned_table[] = { 140 + { 141 + .procname = "unaligned_fixup", 142 + .mode = 0555, 143 + .child = unaligned_subtable 144 + }, 145 + {} 146 + }; 147 + #endif 148 + 149 + static struct ctl_path tile_path[] = { 150 + { .procname = "tile" }, 151 + { } 152 + }; 153 + 154 + static int __init proc_sys_tile_init(void) 155 + { 156 + #ifndef __tilegx__ /* FIXME: GX: no support for unaligned access yet */ 157 + register_sysctl_paths(tile_path, unaligned_table); 158 + #endif 159 + return 0; 160 + } 161 + 162 + arch_initcall(proc_sys_tile_init);
+185
arch/tile/kernel/sysfs.c
··· 1 + /* 2 + * Copyright 2011 Tilera Corporation. All Rights Reserved. 3 + * 4 + * This program is free software; you can redistribute it and/or 5 + * modify it under the terms of the GNU General Public License 6 + * as published by the Free Software Foundation, version 2. 7 + * 8 + * This program is distributed in the hope that it will be useful, but 9 + * WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or 11 + * NON INFRINGEMENT. See the GNU General Public License for 12 + * more details. 13 + * 14 + * /sys entry support. 15 + */ 16 + 17 + #include <linux/sysdev.h> 18 + #include <linux/cpu.h> 19 + #include <linux/slab.h> 20 + #include <linux/smp.h> 21 + #include <hv/hypervisor.h> 22 + 23 + /* Return a string queried from the hypervisor, truncated to page size. */ 24 + static ssize_t get_hv_confstr(char *page, int query) 25 + { 26 + ssize_t n = hv_confstr(query, (unsigned long)page, PAGE_SIZE - 1); 27 + n = n < 0 ? 0 : min(n, (ssize_t)PAGE_SIZE - 1) - 1; 28 + if (n) 29 + page[n++] = '\n'; 30 + page[n] = '\0'; 31 + return n; 32 + } 33 + 34 + static ssize_t chip_width_show(struct sysdev_class *dev, 35 + struct sysdev_class_attribute *attr, 36 + char *page) 37 + { 38 + return sprintf(page, "%u\n", smp_width); 39 + } 40 + static SYSDEV_CLASS_ATTR(chip_width, 0444, chip_width_show, NULL); 41 + 42 + static ssize_t chip_height_show(struct sysdev_class *dev, 43 + struct sysdev_class_attribute *attr, 44 + char *page) 45 + { 46 + return sprintf(page, "%u\n", smp_height); 47 + } 48 + static SYSDEV_CLASS_ATTR(chip_height, 0444, chip_height_show, NULL); 49 + 50 + static ssize_t chip_serial_show(struct sysdev_class *dev, 51 + struct sysdev_class_attribute *attr, 52 + char *page) 53 + { 54 + return get_hv_confstr(page, HV_CONFSTR_CHIP_SERIAL_NUM); 55 + } 56 + static SYSDEV_CLASS_ATTR(chip_serial, 0444, chip_serial_show, NULL); 57 + 58 + static ssize_t chip_revision_show(struct sysdev_class *dev, 59 + struct sysdev_class_attribute *attr, 60 + char *page) 61 + { 62 + return get_hv_confstr(page, HV_CONFSTR_CHIP_REV); 63 + } 64 + static SYSDEV_CLASS_ATTR(chip_revision, 0444, chip_revision_show, NULL); 65 + 66 + 67 + static ssize_t type_show(struct sysdev_class *dev, 68 + struct sysdev_class_attribute *attr, 69 + char *page) 70 + { 71 + return sprintf(page, "tilera\n"); 72 + } 73 + static SYSDEV_CLASS_ATTR(type, 0444, type_show, NULL); 74 + 75 + #define HV_CONF_ATTR(name, conf) \ 76 + static ssize_t name ## _show(struct sysdev_class *dev, \ 77 + struct sysdev_class_attribute *attr, \ 78 + char *page) \ 79 + { \ 80 + return get_hv_confstr(page, conf); \ 81 + } \ 82 + static SYSDEV_CLASS_ATTR(name, 0444, name ## _show, NULL); 83 + 84 + HV_CONF_ATTR(version, HV_CONFSTR_HV_SW_VER) 85 + HV_CONF_ATTR(config_version, HV_CONFSTR_HV_CONFIG_VER) 86 + 87 + HV_CONF_ATTR(board_part, HV_CONFSTR_BOARD_PART_NUM) 88 + HV_CONF_ATTR(board_serial, HV_CONFSTR_BOARD_SERIAL_NUM) 89 + HV_CONF_ATTR(board_revision, HV_CONFSTR_BOARD_REV) 90 + HV_CONF_ATTR(board_description, HV_CONFSTR_BOARD_DESC) 91 + HV_CONF_ATTR(mezz_part, HV_CONFSTR_MEZZ_PART_NUM) 92 + HV_CONF_ATTR(mezz_serial, HV_CONFSTR_MEZZ_SERIAL_NUM) 93 + HV_CONF_ATTR(mezz_revision, HV_CONFSTR_MEZZ_REV) 94 + HV_CONF_ATTR(mezz_description, HV_CONFSTR_MEZZ_DESC) 95 + HV_CONF_ATTR(switch_control, HV_CONFSTR_SWITCH_CONTROL) 96 + 97 + static struct attribute *board_attrs[] = { 98 + &attr_board_part.attr, 99 + &attr_board_serial.attr, 100 + &attr_board_revision.attr, 101 + &attr_board_description.attr, 102 + &attr_mezz_part.attr, 103 + &attr_mezz_serial.attr, 104 + &attr_mezz_revision.attr, 105 + &attr_mezz_description.attr, 106 + &attr_switch_control.attr, 107 + NULL 108 + }; 109 + 110 + static struct attribute_group board_attr_group = { 111 + .name = "board", 112 + .attrs = board_attrs, 113 + }; 114 + 115 + 116 + static struct bin_attribute hvconfig_bin; 117 + 118 + static ssize_t 119 + hvconfig_bin_read(struct file *filp, struct kobject *kobj, 120 + struct bin_attribute *bin_attr, 121 + char *buf, loff_t off, size_t count) 122 + { 123 + static size_t size; 124 + 125 + /* Lazily learn the true size (minus the trailing NUL). */ 126 + if (size == 0) 127 + size = hv_confstr(HV_CONFSTR_HV_CONFIG, 0, 0) - 1; 128 + 129 + /* Check and adjust input parameters. */ 130 + if (off > size) 131 + return -EINVAL; 132 + if (count > size - off) 133 + count = size - off; 134 + 135 + if (count) { 136 + /* Get a copy of the hvc and copy out the relevant portion. */ 137 + char *hvc; 138 + 139 + size = off + count; 140 + hvc = kmalloc(size, GFP_KERNEL); 141 + if (hvc == NULL) 142 + return -ENOMEM; 143 + hv_confstr(HV_CONFSTR_HV_CONFIG, (unsigned long)hvc, size); 144 + memcpy(buf, hvc + off, count); 145 + kfree(hvc); 146 + } 147 + 148 + return count; 149 + } 150 + 151 + static int __init create_sysfs_entries(void) 152 + { 153 + struct sysdev_class *cls = &cpu_sysdev_class; 154 + int err = 0; 155 + 156 + #define create_cpu_attr(name) \ 157 + if (!err) \ 158 + err = sysfs_create_file(&cls->kset.kobj, &attr_##name.attr); 159 + create_cpu_attr(chip_width); 160 + create_cpu_attr(chip_height); 161 + create_cpu_attr(chip_serial); 162 + create_cpu_attr(chip_revision); 163 + 164 + #define create_hv_attr(name) \ 165 + if (!err) \ 166 + err = sysfs_create_file(hypervisor_kobj, &attr_##name.attr); 167 + create_hv_attr(type); 168 + create_hv_attr(version); 169 + create_hv_attr(config_version); 170 + 171 + if (!err) 172 + err = sysfs_create_group(hypervisor_kobj, &board_attr_group); 173 + 174 + if (!err) { 175 + sysfs_bin_attr_init(&hvconfig_bin); 176 + hvconfig_bin.attr.name = "hvconfig"; 177 + hvconfig_bin.attr.mode = S_IRUGO; 178 + hvconfig_bin.read = hvconfig_bin_read; 179 + hvconfig_bin.size = PAGE_SIZE; 180 + err = sysfs_create_bin_file(hypervisor_kobj, &hvconfig_bin); 181 + } 182 + 183 + return err; 184 + } 185 + subsys_initcall(create_sysfs_entries);
+9
fs/proc/base.c
··· 83 83 #include <linux/pid_namespace.h> 84 84 #include <linux/fs_struct.h> 85 85 #include <linux/slab.h> 86 + #ifdef CONFIG_HARDWALL 87 + #include <asm/hardwall.h> 88 + #endif 86 89 #include "internal.h" 87 90 88 91 /* NOTE: ··· 2845 2842 #ifdef CONFIG_TASK_IO_ACCOUNTING 2846 2843 INF("io", S_IRUGO, proc_tgid_io_accounting), 2847 2844 #endif 2845 + #ifdef CONFIG_HARDWALL 2846 + INF("hardwall", S_IRUGO, proc_pid_hardwall), 2847 + #endif 2848 2848 }; 2849 2849 2850 2850 static int proc_tgid_base_readdir(struct file * filp, ··· 3186 3180 #endif 3187 3181 #ifdef CONFIG_TASK_IO_ACCOUNTING 3188 3182 INF("io", S_IRUGO, proc_tid_io_accounting), 3183 + #endif 3184 + #ifdef CONFIG_HARDWALL 3185 + INF("hardwall", S_IRUGO, proc_pid_hardwall), 3189 3186 #endif 3190 3187 }; 3191 3188