[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-83-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:13:42 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 082/437] sched/debug: convert to read/write iterators
Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
kernel/sched/debug.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 686a21ea1791..e1e7856727cb 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -120,26 +120,25 @@ static int sched_feat_set(char *cmp)
return 0;
}
-static ssize_t
-sched_feat_write(struct file *filp, const char __user *ubuf,
- size_t cnt, loff_t *ppos)
+static ssize_t sched_feat_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
char buf[64];
char *cmp;
int ret;
struct inode *inode;
+ size_t cnt = iov_iter_count(from);
if (cnt > 63)
cnt = 63;
- if (copy_from_user(&buf, ubuf, cnt))
+ if (!copy_from_iter_full(&buf, cnt, from))
return -EFAULT;
buf[cnt] = 0;
cmp = strstrip(buf);
/* Ensure the static_key remains in a consistent state */
- inode = file_inode(filp);
+ inode = file_inode(iocb->ki_filp);
cpus_read_lock();
inode_lock(inode);
ret = sched_feat_set(cmp);
@@ -148,7 +147,7 @@ sched_feat_write(struct file *filp, const char __user *ubuf,
if (ret < 0)
return ret;
- *ppos += cnt;
+ iocb->ki_pos += cnt;
return cnt;
}
@@ -160,24 +159,25 @@ static int sched_feat_open(struct inode *inode, struct file *filp)
static const struct file_operations sched_feat_fops = {
.open = sched_feat_open,
- .write = sched_feat_write,
- .read = seq_read,
+ .write_iter = sched_feat_write_iter,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek,
.release = single_release,
};
#ifdef CONFIG_SMP
-static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,
- size_t cnt, loff_t *ppos)
+static ssize_t sched_scaling_write_iter(struct kiocb *iocb,
+ struct iov_iter *from)
{
+ size_t cnt = iov_iter_count(from);
char buf[16];
unsigned int scaling;
if (cnt > 15)
cnt = 15;
- if (copy_from_user(&buf, ubuf, cnt))
+ if (!copy_from_iter_full(&buf, cnt, from))
return -EFAULT;
buf[cnt] = '\0';
@@ -191,7 +191,7 @@ static ssize_t sched_scaling_write(struct file *filp, const char __user *ubuf,
if (sched_update_scaling())
return -EINVAL;
- *ppos += cnt;
+ iocb->ki_pos += cnt;
return cnt;
}
@@ -208,8 +208,8 @@ static int sched_scaling_open(struct inode *inode, struct file *filp)
static const struct file_operations sched_scaling_fops = {
.open = sched_scaling_open,
- .write = sched_scaling_write,
- .read = seq_read,
+ .write_iter = sched_scaling_write_iter,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek,
.release = single_release,
};
@@ -218,16 +218,16 @@ static const struct file_operations sched_scaling_fops = {
#ifdef CONFIG_PREEMPT_DYNAMIC
-static ssize_t sched_dynamic_write(struct file *filp, const char __user *ubuf,
- size_t cnt, loff_t *ppos)
+static ssize_t sched_dynamic_write(struct kiocb *iocb, struct iov_iter *from)
{
+ size_t cnt = iov_iter_count(from);
char buf[16];
int mode;
if (cnt > 15)
cnt = 15;
- if (copy_from_user(&buf, ubuf, cnt))
+ if (!copy_from_iter_full(&buf, cnt, from))
return -EFAULT;
buf[cnt] = 0;
@@ -237,7 +237,7 @@ static ssize_t sched_dynamic_write(struct file *filp, const char __user *ubuf,
sched_dynamic_update(mode);
- *ppos += cnt;
+ iocb->ki_pos += cnt;
return cnt;
}
@@ -270,8 +270,8 @@ static int sched_dynamic_open(struct inode *inode, struct file *filp)
static const struct file_operations sched_dynamic_fops = {
.open = sched_dynamic_open,
- .write = sched_dynamic_write,
- .read = seq_read,
+ .write_iter = sched_dynamic_write,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek,
.release = single_release,
};
@@ -327,7 +327,7 @@ static int sched_debug_open(struct inode *inode, struct file *filp)
static const struct file_operations sched_debug_fops = {
.open = sched_debug_open,
- .read = seq_read,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek,
.release = seq_release,
};
@@ -402,7 +402,7 @@ static int sd_flags_open(struct inode *inode, struct file *file)
static const struct file_operations sd_flags_fops = {
.open = sd_flags_open,
- .read = seq_read,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek,
.release = single_release,
};
--
2.43.0
Powered by blists - more mailing lists