[PATCH] sched: switch sched_features to seqfile - Kernel

This is a discussion on [PATCH] sched: switch sched_features to seqfile - Kernel ; So handling of sched_features read is simplified. Signed-off-by: Li Zefan --- kernel/sched.c | 52 ++++++++++++++++------------------------------------ 1 files changed, 16 insertions(+), 36 deletions(-) diff --git a/kernel/sched.c b/kernel/sched.c index 7dd6c86..5419df9 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -703,45 +703,18 @@ static __read_mostly char ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [PATCH] sched: switch sched_features to seqfile

  1. [PATCH] sched: switch sched_features to seqfile

    So handling of sched_features read is simplified.

    Signed-off-by: Li Zefan
    ---
    kernel/sched.c | 52 ++++++++++++++++------------------------------------
    1 files changed, 16 insertions(+), 36 deletions(-)

    diff --git a/kernel/sched.c b/kernel/sched.c
    index 7dd6c86..5419df9 100644
    --- a/kernel/sched.c
    +++ b/kernel/sched.c
    @@ -703,45 +703,18 @@ static __read_mostly char *sched_feat_names[] = {

    #undef SCHED_FEAT

    -static int sched_feat_open(struct inode *inode, struct file *filp)
    +static int sched_feat_show(struct seq_file *m, void *v)
    {
    - filp->private_data = inode->i_private;
    - return 0;
    -}
    -
    -static ssize_t
    -sched_feat_read(struct file *filp, char __user *ubuf,
    - size_t cnt, loff_t *ppos)
    -{
    - char *buf;
    - int r = 0;
    - int len = 0;
    int i;

    for (i = 0; sched_feat_names[i]; i++) {
    - len += strlen(sched_feat_names[i]);
    - len += 4;
    + if (!(sysctl_sched_features & (1UL << i)))
    + seq_puts(m, "NO_");
    + seq_printf(m, "%s ", sched_feat_names[i]);
    }
    + seq_puts(m, "\n");

    - buf = kmalloc(len + 2, GFP_KERNEL);
    - if (!buf)
    - return -ENOMEM;
    -
    - for (i = 0; sched_feat_names[i]; i++) {
    - if (sysctl_sched_features & (1UL << i))
    - r += sprintf(buf + r, "%s ", sched_feat_names[i]);
    - else
    - r += sprintf(buf + r, "NO_%s ", sched_feat_names[i]);
    - }
    -
    - r += sprintf(buf + r, "\n");
    - WARN_ON(r >= len + 2);
    -
    - r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
    -
    - kfree(buf);
    -
    - return r;
    + return 0;
    }

    static ssize_t
    @@ -786,10 +759,17 @@ sched_feat_write(struct file *filp, const char __user *ubuf,
    return cnt;
    }

    +static int sched_feat_open(struct inode *inode, struct file *filp)
    +{
    + return single_open(filp, sched_feat_show, NULL);
    +}
    +
    static struct file_operations sched_feat_fops = {
    - .open = sched_feat_open,
    - .read = sched_feat_read,
    - .write = sched_feat_write,
    + .open = sched_feat_open,
    + .write = sched_feat_write,
    + .read = seq_read,
    + .llseek = seq_lseek,
    + .release = single_release,
    };

    static __init int sched_init_debug(void)
    --
    1.5.4.rc3

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. Re: [PATCH] sched: switch sched_features to seqfile


    * Li Zefan wrote:

    > So handling of sched_features read is simplified.
    >
    > Signed-off-by: Li Zefan
    > ---
    > kernel/sched.c | 52 ++++++++++++++++------------------------------------
    > 1 files changed, 16 insertions(+), 36 deletions(-)


    nice cleanup! Applied to tip/sched/core, thanks,

    Ingo
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread