diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2008-10-30 03:23:32 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-10-30 06:38:35 -0400 |
commit | 34f3a814eef8069a24e5b3ebcf27aba9dabac2ea (patch) | |
tree | a25f326c8192b4f7942201e9b7da9b8fd5ad101b /kernel | |
parent | eab172294d5e24464f332dd8e94a57a9819c81c4 (diff) |
sched: switch sched_features to seqfile
Impact: cleanup
So handling of sched_features read is simplified.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched.c | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 7dd6c860773b..5419df9cc5c4 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -703,45 +703,18 @@ static __read_mostly char *sched_feat_names[] = { | |||
703 | 703 | ||
704 | #undef SCHED_FEAT | 704 | #undef SCHED_FEAT |
705 | 705 | ||
706 | static int sched_feat_open(struct inode *inode, struct file *filp) | 706 | static int sched_feat_show(struct seq_file *m, void *v) |
707 | { | 707 | { |
708 | filp->private_data = inode->i_private; | ||
709 | return 0; | ||
710 | } | ||
711 | |||
712 | static ssize_t | ||
713 | sched_feat_read(struct file *filp, char __user *ubuf, | ||
714 | size_t cnt, loff_t *ppos) | ||
715 | { | ||
716 | char *buf; | ||
717 | int r = 0; | ||
718 | int len = 0; | ||
719 | int i; | 708 | int i; |
720 | 709 | ||
721 | for (i = 0; sched_feat_names[i]; i++) { | 710 | for (i = 0; sched_feat_names[i]; i++) { |
722 | len += strlen(sched_feat_names[i]); | 711 | if (!(sysctl_sched_features & (1UL << i))) |
723 | len += 4; | 712 | seq_puts(m, "NO_"); |
713 | seq_printf(m, "%s ", sched_feat_names[i]); | ||
724 | } | 714 | } |
715 | seq_puts(m, "\n"); | ||
725 | 716 | ||
726 | buf = kmalloc(len + 2, GFP_KERNEL); | 717 | return 0; |
727 | if (!buf) | ||
728 | return -ENOMEM; | ||
729 | |||
730 | for (i = 0; sched_feat_names[i]; i++) { | ||
731 | if (sysctl_sched_features & (1UL << i)) | ||
732 | r += sprintf(buf + r, "%s ", sched_feat_names[i]); | ||
733 | else | ||
734 | r += sprintf(buf + r, "NO_%s ", sched_feat_names[i]); | ||
735 | } | ||
736 | |||
737 | r += sprintf(buf + r, "\n"); | ||
738 | WARN_ON(r >= len + 2); | ||
739 | |||
740 | r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r); | ||
741 | |||
742 | kfree(buf); | ||
743 | |||
744 | return r; | ||
745 | } | 718 | } |
746 | 719 | ||
747 | static ssize_t | 720 | static ssize_t |
@@ -786,10 +759,17 @@ sched_feat_write(struct file *filp, const char __user *ubuf, | |||
786 | return cnt; | 759 | return cnt; |
787 | } | 760 | } |
788 | 761 | ||
762 | static int sched_feat_open(struct inode *inode, struct file *filp) | ||
763 | { | ||
764 | return single_open(filp, sched_feat_show, NULL); | ||
765 | } | ||
766 | |||
789 | static struct file_operations sched_feat_fops = { | 767 | static struct file_operations sched_feat_fops = { |
790 | .open = sched_feat_open, | 768 | .open = sched_feat_open, |
791 | .read = sched_feat_read, | 769 | .write = sched_feat_write, |
792 | .write = sched_feat_write, | 770 | .read = seq_read, |
771 | .llseek = seq_lseek, | ||
772 | .release = single_release, | ||
793 | }; | 773 | }; |
794 | 774 | ||
795 | static __init int sched_init_debug(void) | 775 | static __init int sched_init_debug(void) |