diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-24 19:02:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-24 19:02:08 -0400 |
commit | b5f4035adfffbcc6b478de5b8c44b618b3124aff (patch) | |
tree | e7a5f011d8aaf5c95edf933f98f25dfc8fa46837 /fs/debugfs/file.c | |
parent | ce004178be1bbaa292e9e6497939e2970300095a (diff) | |
parent | 68c2c39a76b094e9b2773e5846424ea674bf2c46 (diff) |
Merge tag 'stable/for-linus-3.5-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
Pull Xen updates from Konrad Rzeszutek Wilk:
"Features:
* Extend the APIC ops implementation and add IRQ_WORKER vector
support so that 'perf' can work properly.
* Fix self-ballooning code, and balloon logic when booting as initial
domain.
* Move array printing code to generic debugfs
* Support XenBus domains.
* Lazily free grants when a domain is dead/non-existent.
* In M2P code use batching calls
Bug-fixes:
* Fix NULL dereference in allocation failure path (hvc_xen)
* Fix unbinding of IRQ_WORKER vector during vCPU hot-unplug
* Fix HVM guest resume - we would leak an PIRQ value instead of
reusing the existing one."
Fix up add-add onflicts in arch/x86/xen/enlighten.c due to addition of
apic ipi interface next to the new apic_id functions.
* tag 'stable/for-linus-3.5-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen:
xen: do not map the same GSI twice in PVHVM guests.
hvc_xen: NULL dereference on allocation failure
xen: Add selfballoning memory reservation tunable.
xenbus: Add support for xenbus backend in stub domain
xen/smp: unbind irqworkX when unplugging vCPUs.
xen: enter/exit lazy_mmu_mode around m2p_override calls
xen/acpi/sleep: Enable ACPI sleep via the __acpi_os_prepare_sleep
xen: implement IRQ_WORK_VECTOR handler
xen: implement apic ipi interface
xen/setup: update VA mapping when releasing memory during setup
xen/setup: Combine the two hypercall functions - since they are quite similar.
xen/setup: Populate freed MFNs from non-RAM E820 entries and gaps to E820 RAM
xen/setup: Only print "Freeing XXX-YYY pfn range: Z pages freed" if Z > 0
xen/gnttab: add deferred freeing logic
debugfs: Add support to print u32 array in debugfs
xen/p2m: An early bootup variant of set_phys_to_machine
xen/p2m: Collapse early_alloc_p2m_middle redundant checks.
xen/p2m: Allow alloc_p2m_middle to call reserve_brk depending on argument
xen/p2m: Move code around to allow for better re-usage.
Diffstat (limited to 'fs/debugfs/file.c')
-rw-r--r-- | fs/debugfs/file.c | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 5dfafdd1dbd3..2340f6978d6e 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/namei.h> | 20 | #include <linux/namei.h> |
21 | #include <linux/debugfs.h> | 21 | #include <linux/debugfs.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/slab.h> | ||
23 | 24 | ||
24 | static ssize_t default_read_file(struct file *file, char __user *buf, | 25 | static ssize_t default_read_file(struct file *file, char __user *buf, |
25 | size_t count, loff_t *ppos) | 26 | size_t count, loff_t *ppos) |
@@ -520,6 +521,133 @@ struct dentry *debugfs_create_blob(const char *name, umode_t mode, | |||
520 | } | 521 | } |
521 | EXPORT_SYMBOL_GPL(debugfs_create_blob); | 522 | EXPORT_SYMBOL_GPL(debugfs_create_blob); |
522 | 523 | ||
524 | struct array_data { | ||
525 | void *array; | ||
526 | u32 elements; | ||
527 | }; | ||
528 | |||
529 | static int u32_array_open(struct inode *inode, struct file *file) | ||
530 | { | ||
531 | file->private_data = NULL; | ||
532 | return nonseekable_open(inode, file); | ||
533 | } | ||
534 | |||
535 | static size_t format_array(char *buf, size_t bufsize, const char *fmt, | ||
536 | u32 *array, u32 array_size) | ||
537 | { | ||
538 | size_t ret = 0; | ||
539 | u32 i; | ||
540 | |||
541 | for (i = 0; i < array_size; i++) { | ||
542 | size_t len; | ||
543 | |||
544 | len = snprintf(buf, bufsize, fmt, array[i]); | ||
545 | len++; /* ' ' or '\n' */ | ||
546 | ret += len; | ||
547 | |||
548 | if (buf) { | ||
549 | buf += len; | ||
550 | bufsize -= len; | ||
551 | buf[-1] = (i == array_size-1) ? '\n' : ' '; | ||
552 | } | ||
553 | } | ||
554 | |||
555 | ret++; /* \0 */ | ||
556 | if (buf) | ||
557 | *buf = '\0'; | ||
558 | |||
559 | return ret; | ||
560 | } | ||
561 | |||
562 | static char *format_array_alloc(const char *fmt, u32 *array, | ||
563 | u32 array_size) | ||
564 | { | ||
565 | size_t len = format_array(NULL, 0, fmt, array, array_size); | ||
566 | char *ret; | ||
567 | |||
568 | ret = kmalloc(len, GFP_KERNEL); | ||
569 | if (ret == NULL) | ||
570 | return NULL; | ||
571 | |||
572 | format_array(ret, len, fmt, array, array_size); | ||
573 | return ret; | ||
574 | } | ||
575 | |||
576 | static ssize_t u32_array_read(struct file *file, char __user *buf, size_t len, | ||
577 | loff_t *ppos) | ||
578 | { | ||
579 | struct inode *inode = file->f_path.dentry->d_inode; | ||
580 | struct array_data *data = inode->i_private; | ||
581 | size_t size; | ||
582 | |||
583 | if (*ppos == 0) { | ||
584 | if (file->private_data) { | ||
585 | kfree(file->private_data); | ||
586 | file->private_data = NULL; | ||
587 | } | ||
588 | |||
589 | file->private_data = format_array_alloc("%u", data->array, | ||
590 | data->elements); | ||
591 | } | ||
592 | |||
593 | size = 0; | ||
594 | if (file->private_data) | ||
595 | size = strlen(file->private_data); | ||
596 | |||
597 | return simple_read_from_buffer(buf, len, ppos, | ||
598 | file->private_data, size); | ||
599 | } | ||
600 | |||
601 | static int u32_array_release(struct inode *inode, struct file *file) | ||
602 | { | ||
603 | kfree(file->private_data); | ||
604 | |||
605 | return 0; | ||
606 | } | ||
607 | |||
608 | static const struct file_operations u32_array_fops = { | ||
609 | .owner = THIS_MODULE, | ||
610 | .open = u32_array_open, | ||
611 | .release = u32_array_release, | ||
612 | .read = u32_array_read, | ||
613 | .llseek = no_llseek, | ||
614 | }; | ||
615 | |||
616 | /** | ||
617 | * debugfs_create_u32_array - create a debugfs file that is used to read u32 | ||
618 | * array. | ||
619 | * @name: a pointer to a string containing the name of the file to create. | ||
620 | * @mode: the permission that the file should have. | ||
621 | * @parent: a pointer to the parent dentry for this file. This should be a | ||
622 | * directory dentry if set. If this parameter is %NULL, then the | ||
623 | * file will be created in the root of the debugfs filesystem. | ||
624 | * @array: u32 array that provides data. | ||
625 | * @elements: total number of elements in the array. | ||
626 | * | ||
627 | * This function creates a file in debugfs with the given name that exports | ||
628 | * @array as data. If the @mode variable is so set it can be read from. | ||
629 | * Writing is not supported. Seek within the file is also not supported. | ||
630 | * Once array is created its size can not be changed. | ||
631 | * | ||
632 | * The function returns a pointer to dentry on success. If debugfs is not | ||
633 | * enabled in the kernel, the value -%ENODEV will be returned. | ||
634 | */ | ||
635 | struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, | ||
636 | struct dentry *parent, | ||
637 | u32 *array, u32 elements) | ||
638 | { | ||
639 | struct array_data *data = kmalloc(sizeof(*data), GFP_KERNEL); | ||
640 | |||
641 | if (data == NULL) | ||
642 | return NULL; | ||
643 | |||
644 | data->array = array; | ||
645 | data->elements = elements; | ||
646 | |||
647 | return debugfs_create_file(name, mode, parent, data, &u32_array_fops); | ||
648 | } | ||
649 | EXPORT_SYMBOL_GPL(debugfs_create_u32_array); | ||
650 | |||
523 | #ifdef CONFIG_HAS_IOMEM | 651 | #ifdef CONFIG_HAS_IOMEM |
524 | 652 | ||
525 | /* | 653 | /* |