Message ID | 20220621102455.13183-3-jack@suse.cz (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block: Fix IO priority mess | expand |
On Tue 21-06-22 12:24:40, Jan Kara wrote: > get_current_ioprio() operates only on current task. We will need the > same functionality for other tasks as well. Generalize > get_current_ioprio() for that and also move the bulk out of the header > file because it is large enough. > > Signed-off-by: Jan Kara <jack@suse.cz> Bah, I've messed up the prototype of the stub function for !CONFIG_BLOCK. One more fixup will be needed here but let me wait if people have more comments... Honza > --- > block/ioprio.c | 26 ++++++++++++++++++++++++++ > include/linux/ioprio.h | 26 ++++++++++---------------- > 2 files changed, 36 insertions(+), 16 deletions(-) > > diff --git a/block/ioprio.c b/block/ioprio.c > index 2a34cbca18ae..c4e3476155a1 100644 > --- a/block/ioprio.c > +++ b/block/ioprio.c > @@ -138,6 +138,32 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) > return ret; > } > > +/* > + * If the task has set an I/O priority, use that. Otherwise, return > + * the default I/O priority. > + * > + * Expected to be called for current task or with task_lock() held to keep > + * io_context stable. > + */ > +int __get_task_ioprio(struct task_struct *p) > +{ > + struct io_context *ioc = p->io_context; > + int prio; > + > + if (p != current) > + lockdep_assert_held(&p->alloc_lock); > + if (ioc) > + prio = ioc->ioprio; > + else > + prio = IOPRIO_DEFAULT; > + > + if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE) > + prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(p), > + task_nice_ioprio(p)); > + return prio; > +} > +EXPORT_SYMBOL_GPL(__get_task_ioprio); > + > static int get_task_ioprio(struct task_struct *p) > { > int ret; > diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h > index 61ed6bb4998e..788a8ff57068 100644 > --- a/include/linux/ioprio.h > +++ b/include/linux/ioprio.h > @@ -46,24 +46,18 @@ static inline int task_nice_ioclass(struct task_struct *task) > return IOPRIO_CLASS_BE; > } > > -/* > - * If the calling process has set an I/O priority, use that. Otherwise, return > - * the default I/O priority. > - */ > -static inline int get_current_ioprio(void) > +#ifdef CONFIG_BLOCK > +int __get_task_ioprio(struct task_struct *p); > +#else > +static inline int __get_task_ioprio(int ioprio) > { > - struct io_context *ioc = current->io_context; > - int prio; > - > - if (ioc) > - prio = ioc->ioprio; > - else > - prio = IOPRIO_DEFAULT; > + return IOPRIO_DEFAULT; > +} > +#endif /* CONFIG_BLOCK */ > > - if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE) > - prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(current), > - task_nice_ioprio(current)); > - return prio; > +static inline int get_current_ioprio(void) > +{ > + return __get_task_ioprio(current); > } > > /* > -- > 2.35.3 >
On 6/21/22 19:24, Jan Kara wrote: > get_current_ioprio() operates only on current task. We will need the > same functionality for other tasks as well. Generalize > get_current_ioprio() for that and also move the bulk out of the header > file because it is large enough. > > Signed-off-by: Jan Kara <jack@suse.cz> Looks OK to me. Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> > --- > block/ioprio.c | 26 ++++++++++++++++++++++++++ > include/linux/ioprio.h | 26 ++++++++++---------------- > 2 files changed, 36 insertions(+), 16 deletions(-) > > diff --git a/block/ioprio.c b/block/ioprio.c > index 2a34cbca18ae..c4e3476155a1 100644 > --- a/block/ioprio.c > +++ b/block/ioprio.c > @@ -138,6 +138,32 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) > return ret; > } > > +/* > + * If the task has set an I/O priority, use that. Otherwise, return > + * the default I/O priority. > + * > + * Expected to be called for current task or with task_lock() held to keep > + * io_context stable. > + */ > +int __get_task_ioprio(struct task_struct *p) > +{ > + struct io_context *ioc = p->io_context; > + int prio; > + > + if (p != current) > + lockdep_assert_held(&p->alloc_lock); > + if (ioc) > + prio = ioc->ioprio; > + else > + prio = IOPRIO_DEFAULT; > + > + if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE) > + prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(p), > + task_nice_ioprio(p)); > + return prio; > +} > +EXPORT_SYMBOL_GPL(__get_task_ioprio); > + > static int get_task_ioprio(struct task_struct *p) > { > int ret; > diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h > index 61ed6bb4998e..788a8ff57068 100644 > --- a/include/linux/ioprio.h > +++ b/include/linux/ioprio.h > @@ -46,24 +46,18 @@ static inline int task_nice_ioclass(struct task_struct *task) > return IOPRIO_CLASS_BE; > } > > -/* > - * If the calling process has set an I/O priority, use that. Otherwise, return > - * the default I/O priority. > - */ > -static inline int get_current_ioprio(void) > +#ifdef CONFIG_BLOCK > +int __get_task_ioprio(struct task_struct *p); > +#else > +static inline int __get_task_ioprio(int ioprio) > { > - struct io_context *ioc = current->io_context; > - int prio; > - > - if (ioc) > - prio = ioc->ioprio; > - else > - prio = IOPRIO_DEFAULT; > + return IOPRIO_DEFAULT; > +} > +#endif /* CONFIG_BLOCK */ > > - if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE) > - prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(current), > - task_nice_ioprio(current)); > - return prio; > +static inline int get_current_ioprio(void) > +{ > + return __get_task_ioprio(current); > } > > /*
On 6/21/22 21:36, Jan Kara wrote: > On Tue 21-06-22 12:24:40, Jan Kara wrote: >> get_current_ioprio() operates only on current task. We will need the >> same functionality for other tasks as well. Generalize >> get_current_ioprio() for that and also move the bulk out of the header >> file because it is large enough. >> >> Signed-off-by: Jan Kara <jack@suse.cz> > > Bah, I've messed up the prototype of the stub function for !CONFIG_BLOCK. > One more fixup will be needed here but let me wait if people have more > comments... Oops. Missed it :) > > Honza > >> --- >> block/ioprio.c | 26 ++++++++++++++++++++++++++ >> include/linux/ioprio.h | 26 ++++++++++---------------- >> 2 files changed, 36 insertions(+), 16 deletions(-) >> >> diff --git a/block/ioprio.c b/block/ioprio.c >> index 2a34cbca18ae..c4e3476155a1 100644 >> --- a/block/ioprio.c >> +++ b/block/ioprio.c >> @@ -138,6 +138,32 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) >> return ret; >> } >> >> +/* >> + * If the task has set an I/O priority, use that. Otherwise, return >> + * the default I/O priority. >> + * >> + * Expected to be called for current task or with task_lock() held to keep >> + * io_context stable. >> + */ >> +int __get_task_ioprio(struct task_struct *p) >> +{ >> + struct io_context *ioc = p->io_context; >> + int prio; >> + >> + if (p != current) >> + lockdep_assert_held(&p->alloc_lock); >> + if (ioc) >> + prio = ioc->ioprio; >> + else >> + prio = IOPRIO_DEFAULT; >> + >> + if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE) >> + prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(p), >> + task_nice_ioprio(p)); >> + return prio; >> +} >> +EXPORT_SYMBOL_GPL(__get_task_ioprio); >> + >> static int get_task_ioprio(struct task_struct *p) >> { >> int ret; >> diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h >> index 61ed6bb4998e..788a8ff57068 100644 >> --- a/include/linux/ioprio.h >> +++ b/include/linux/ioprio.h >> @@ -46,24 +46,18 @@ static inline int task_nice_ioclass(struct task_struct *task) >> return IOPRIO_CLASS_BE; >> } >> >> -/* >> - * If the calling process has set an I/O priority, use that. Otherwise, return >> - * the default I/O priority. >> - */ >> -static inline int get_current_ioprio(void) >> +#ifdef CONFIG_BLOCK >> +int __get_task_ioprio(struct task_struct *p); >> +#else >> +static inline int __get_task_ioprio(int ioprio) >> { >> - struct io_context *ioc = current->io_context; >> - int prio; >> - >> - if (ioc) >> - prio = ioc->ioprio; >> - else >> - prio = IOPRIO_DEFAULT; >> + return IOPRIO_DEFAULT; >> +} >> +#endif /* CONFIG_BLOCK */ >> >> - if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE) >> - prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(current), >> - task_nice_ioprio(current)); >> - return prio; >> +static inline int get_current_ioprio(void) >> +{ >> + return __get_task_ioprio(current); >> } >> >> /* >> -- >> 2.35.3 >>
Hi Jan, I love your patch! Perhaps something to improve: [auto build test WARNING on axboe-block/for-next] [also build test WARNING on linus/master v5.19-rc3 next-20220621] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Jan-Kara/block-Fix-IO-priority-mess/20220621-183235 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next config: hexagon-randconfig-r016-20220622 (https://download.01.org/0day-ci/archive/20220622/202206220716.sxn2tinw-lkp@intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project af6d2a0b6825e71965f3e2701a63c239fa0ad70f) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/8421c851d4fe5f4b9d9d6870ada8ccd0b48a4012 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Jan-Kara/block-Fix-IO-priority-mess/20220621-183235 git checkout 8421c851d4fe5f4b9d9d6870ada8ccd0b48a4012 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon prepare If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): In file included from arch/hexagon/kernel/asm-offsets.c:12: In file included from include/linux/compat.h:17: In file included from include/linux/fs.h:38: >> include/linux/ioprio.h:60:27: warning: incompatible pointer to integer conversion passing 'struct task_struct *' to parameter of type 'int' [-Wint-conversion] return __get_task_ioprio(current); ^~~~~~~ include/asm-generic/current.h:8:17: note: expanded from macro 'current' #define current get_current() ^~~~~~~~~~~~~ include/asm-generic/current.h:7:23: note: expanded from macro 'get_current' #define get_current() (current_thread_info()->task) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/ioprio.h:52:41: note: passing argument to parameter 'ioprio' here static inline int __get_task_ioprio(int ioprio) ^ 1 warning generated. -- In file included from drivers/iio/proximity/isl29501.c:13: In file included from include/linux/i2c.h:19: In file included from include/linux/regulator/consumer.h:35: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:17: In file included from include/linux/fs.h:38: >> include/linux/ioprio.h:60:27: warning: incompatible pointer to integer conversion passing 'struct task_struct *' to parameter of type 'int' [-Wint-conversion] return __get_task_ioprio(current); ^~~~~~~ include/asm-generic/current.h:8:17: note: expanded from macro 'current' #define current get_current() ^~~~~~~~~~~~~ include/asm-generic/current.h:7:23: note: expanded from macro 'get_current' #define get_current() (current_thread_info()->task) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/ioprio.h:52:41: note: passing argument to parameter 'ioprio' here static inline int __get_task_ioprio(int ioprio) ^ drivers/iio/proximity/isl29501.c:1000:34: warning: unused variable 'isl29501_i2c_matches' [-Wunused-const-variable] static const struct of_device_id isl29501_i2c_matches[] = { ^ 2 warnings generated. -- In file included from drivers/iio/proximity/sx9500.c:13: In file included from include/linux/i2c.h:19: In file included from include/linux/regulator/consumer.h:35: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:13: In file included from include/linux/cgroup.h:17: In file included from include/linux/fs.h:38: >> include/linux/ioprio.h:60:27: warning: incompatible pointer to integer conversion passing 'struct task_struct *' to parameter of type 'int' [-Wint-conversion] return __get_task_ioprio(current); ^~~~~~~ include/asm-generic/current.h:8:17: note: expanded from macro 'current' #define current get_current() ^~~~~~~~~~~~~ include/asm-generic/current.h:7:23: note: expanded from macro 'get_current' #define get_current() (current_thread_info()->task) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/ioprio.h:52:41: note: passing argument to parameter 'ioprio' here static inline int __get_task_ioprio(int ioprio) ^ drivers/iio/proximity/sx9500.c:1035:36: warning: unused variable 'sx9500_acpi_match' [-Wunused-const-variable] static const struct acpi_device_id sx9500_acpi_match[] = { ^ 2 warnings generated. -- In file included from arch/hexagon/kernel/asm-offsets.c:12: In file included from include/linux/compat.h:17: In file included from include/linux/fs.h:38: >> include/linux/ioprio.h:60:27: warning: incompatible pointer to integer conversion passing 'struct task_struct *' to parameter of type 'int' [-Wint-conversion] return __get_task_ioprio(current); ^~~~~~~ include/asm-generic/current.h:8:17: note: expanded from macro 'current' #define current get_current() ^~~~~~~~~~~~~ include/asm-generic/current.h:7:23: note: expanded from macro 'get_current' #define get_current() (current_thread_info()->task) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/ioprio.h:52:41: note: passing argument to parameter 'ioprio' here static inline int __get_task_ioprio(int ioprio) ^ 1 warning generated. <stdin>:1517:2: warning: syscall clone3 not implemented [-W#warnings] #warning syscall clone3 not implemented ^ 1 warning generated. vim +60 include/linux/ioprio.h 57 58 static inline int get_current_ioprio(void) 59 { > 60 return __get_task_ioprio(current); 61 } 62
Hi Jan, I love your patch! Perhaps something to improve: [auto build test WARNING on axboe-block/for-next] [also build test WARNING on linus/master v5.19-rc3 next-20220621] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Jan-Kara/block-Fix-IO-priority-mess/20220621-183235 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next config: riscv-nommu_k210_defconfig (https://download.01.org/0day-ci/archive/20220622/202206220810.R6I8vpfk-lkp@intel.com/config) compiler: riscv64-linux-gcc (GCC) 11.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/8421c851d4fe5f4b9d9d6870ada8ccd0b48a4012 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Jan-Kara/block-Fix-IO-priority-mess/20220621-183235 git checkout 8421c851d4fe5f4b9d9d6870ada8ccd0b48a4012 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=riscv prepare If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): In file included from include/linux/thread_info.h:23, from include/asm-generic/preempt.h:5, from ./arch/riscv/include/generated/asm/preempt.h:1, from include/linux/preempt.h:78, from include/linux/spinlock.h:55, from include/linux/mmzone.h:8, from include/linux/gfp.h:6, from include/linux/mm.h:7, from arch/riscv/kernel/asm-offsets.c:10: include/linux/ioprio.h: In function 'get_current_ioprio': >> arch/riscv/include/asm/current.h:34:17: warning: passing argument 1 of '__get_task_ioprio' makes integer from pointer without a cast [-Wint-conversion] 34 | #define current get_current() | ^~~~~~~~~~~~~ | | | struct task_struct * include/linux/ioprio.h:60:34: note: in expansion of macro 'current' 60 | return __get_task_ioprio(current); | ^~~~~~~ In file included from include/linux/fs.h:38, from include/linux/huge_mm.h:8, from include/linux/mm.h:700, from arch/riscv/kernel/asm-offsets.c:10: include/linux/ioprio.h:52:41: note: expected 'int' but argument is of type 'struct task_struct *' 52 | static inline int __get_task_ioprio(int ioprio) | ~~~~^~~~~~ -- In file included from include/linux/thread_info.h:23, from include/asm-generic/preempt.h:5, from ./arch/riscv/include/generated/asm/preempt.h:1, from include/linux/preempt.h:78, from include/linux/smp.h:110, from arch/riscv/include/asm/mmiowb.h:12, from arch/riscv/include/asm/mmio.h:15, from arch/riscv/include/asm/clint.h:10, from arch/riscv/include/asm/timex.h:15, from include/linux/timex.h:67, from include/linux/time32.h:13, from include/linux/time.h:60, from include/linux/stat.h:19, from include/linux/module.h:13, from drivers/clk/clkdev.c:9: include/linux/ioprio.h: In function 'get_current_ioprio': >> arch/riscv/include/asm/current.h:34:17: warning: passing argument 1 of '__get_task_ioprio' makes integer from pointer without a cast [-Wint-conversion] 34 | #define current get_current() | ^~~~~~~~~~~~~ | | | struct task_struct * include/linux/ioprio.h:60:34: note: in expansion of macro 'current' 60 | return __get_task_ioprio(current); | ^~~~~~~ In file included from include/linux/fs.h:38, from include/linux/compat.h:17, from arch/riscv/include/asm/elf.h:12, from include/linux/elf.h:6, from include/linux/module.h:19, from drivers/clk/clkdev.c:9: include/linux/ioprio.h:52:41: note: expected 'int' but argument is of type 'struct task_struct *' 52 | static inline int __get_task_ioprio(int ioprio) | ~~~~^~~~~~ drivers/clk/clkdev.c: In function 'vclkdev_alloc': drivers/clk/clkdev.c:173:17: warning: function 'vclkdev_alloc' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format] 173 | vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap); | ^~~~~~~~~~ -- In file included from include/linux/thread_info.h:23, from include/asm-generic/preempt.h:5, from ./arch/riscv/include/generated/asm/preempt.h:1, from include/linux/preempt.h:78, from include/linux/spinlock.h:55, from include/linux/mmzone.h:8, from include/linux/gfp.h:6, from include/linux/mm.h:7, from arch/riscv/kernel/asm-offsets.c:10: include/linux/ioprio.h: In function 'get_current_ioprio': >> arch/riscv/include/asm/current.h:34:17: warning: passing argument 1 of '__get_task_ioprio' makes integer from pointer without a cast [-Wint-conversion] 34 | #define current get_current() | ^~~~~~~~~~~~~ | | | struct task_struct * include/linux/ioprio.h:60:34: note: in expansion of macro 'current' 60 | return __get_task_ioprio(current); | ^~~~~~~ In file included from include/linux/fs.h:38, from include/linux/huge_mm.h:8, from include/linux/mm.h:700, from arch/riscv/kernel/asm-offsets.c:10: include/linux/ioprio.h:52:41: note: expected 'int' but argument is of type 'struct task_struct *' 52 | static inline int __get_task_ioprio(int ioprio) | ~~~~^~~~~~ vim +/__get_task_ioprio +34 arch/riscv/include/asm/current.h 7db91e57a0acde Palmer Dabbelt 2017-07-10 33 7db91e57a0acde Palmer Dabbelt 2017-07-10 @34 #define current get_current() 7db91e57a0acde Palmer Dabbelt 2017-07-10 35
Hi Jan, I love your patch! Yet something to improve: [auto build test ERROR on axboe-block/for-next] [also build test ERROR on linus/master v5.19-rc3 next-20220621] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Jan-Kara/block-Fix-IO-priority-mess/20220621-183235 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next config: s390-randconfig-r021-20220622 (https://download.01.org/0day-ci/archive/20220622/202206220956.wXt005QG-lkp@intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project af6d2a0b6825e71965f3e2701a63c239fa0ad70f) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install s390 cross compiling tool for clang build # apt-get install binutils-s390x-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/8421c851d4fe5f4b9d9d6870ada8ccd0b48a4012 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Jan-Kara/block-Fix-IO-priority-mess/20220621-183235 git checkout 8421c851d4fe5f4b9d9d6870ada8ccd0b48a4012 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash lib/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): In file included from lib/test_bitops.c:9: In file included from include/linux/module.h:19: In file included from include/linux/elf.h:6: In file included from arch/s390/include/asm/elf.h:160: In file included from include/linux/compat.h:17: In file included from include/linux/fs.h:38: >> include/linux/ioprio.h:60:27: error: incompatible pointer to integer conversion passing 'struct task_struct *' to parameter of type 'int' [-Werror,-Wint-conversion] return __get_task_ioprio(current); ^~~~~~~ arch/s390/include/asm/current.h:17:17: note: expanded from macro 'current' #define current ((struct task_struct *const)S390_lowcore.current_task) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/ioprio.h:52:41: note: passing argument to parameter 'ioprio' here static inline int __get_task_ioprio(int ioprio) ^ 1 error generated. vim +60 include/linux/ioprio.h 57 58 static inline int get_current_ioprio(void) 59 { > 60 return __get_task_ioprio(current); 61 } 62
Hi Jan, I love your patch! Perhaps something to improve: [auto build test WARNING on axboe-block/for-next] [also build test WARNING on linus/master v5.19-rc3 next-20220622] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/intel-lab-lkp/linux/commits/Jan-Kara/block-Fix-IO-priority-mess/20220621-183235 base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next config: x86_64-randconfig-s022 (https://download.01.org/0day-ci/archive/20220622/202206221920.pxBCy0Di-lkp@intel.com/config) compiler: gcc-11 (Debian 11.3.0-3) 11.3.0 reproduce: # apt-get install sparse # sparse version: v0.6.4-31-g4880bd19-dirty # https://github.com/intel-lab-lkp/linux/commit/8421c851d4fe5f4b9d9d6870ada8ccd0b48a4012 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Jan-Kara/block-Fix-IO-priority-mess/20220621-183235 git checkout 8421c851d4fe5f4b9d9d6870ada8ccd0b48a4012 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@intel.com> sparse warnings: (new ones prefixed by >>) fs/read_write.c: note: in included file (through include/linux/fs.h, include/linux/fsnotify_backend.h, include/linux/fsnotify.h): include/linux/ioprio.h:60:34: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected int ioprio @@ got struct task_struct * @@ include/linux/ioprio.h:60:34: sparse: expected int ioprio include/linux/ioprio.h:60:34: sparse: got struct task_struct * fs/read_write.c: note: in included file (through include/linux/thread_info.h, arch/x86/include/asm/preempt.h, include/linux/preempt.h, ...): >> arch/x86/include/asm/current.h:15:16: sparse: sparse: non size-preserving pointer to integer cast fs/read_write.c: note: in included file (through include/linux/fs.h, include/linux/fsnotify_backend.h, include/linux/fsnotify.h): include/linux/ioprio.h:60:34: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected int ioprio @@ got struct task_struct * @@ include/linux/ioprio.h:60:34: sparse: expected int ioprio include/linux/ioprio.h:60:34: sparse: got struct task_struct * fs/read_write.c: note: in included file (through include/linux/thread_info.h, arch/x86/include/asm/preempt.h, include/linux/preempt.h, ...): >> arch/x86/include/asm/current.h:15:16: sparse: sparse: non size-preserving pointer to integer cast fs/read_write.c: note: in included file (through include/linux/fs.h, include/linux/fsnotify_backend.h, include/linux/fsnotify.h): include/linux/ioprio.h:60:34: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected int ioprio @@ got struct task_struct * @@ include/linux/ioprio.h:60:34: sparse: expected int ioprio include/linux/ioprio.h:60:34: sparse: got struct task_struct * fs/read_write.c: note: in included file (through include/linux/thread_info.h, arch/x86/include/asm/preempt.h, include/linux/preempt.h, ...): >> arch/x86/include/asm/current.h:15:16: sparse: sparse: non size-preserving pointer to integer cast fs/read_write.c: note: in included file (through include/linux/fs.h, include/linux/fsnotify_backend.h, include/linux/fsnotify.h): include/linux/ioprio.h:60:34: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected int ioprio @@ got struct task_struct * @@ include/linux/ioprio.h:60:34: sparse: expected int ioprio include/linux/ioprio.h:60:34: sparse: got struct task_struct * fs/read_write.c: note: in included file (through include/linux/thread_info.h, arch/x86/include/asm/preempt.h, include/linux/preempt.h, ...): >> arch/x86/include/asm/current.h:15:16: sparse: sparse: non size-preserving pointer to integer cast fs/read_write.c: note: in included file (through include/linux/fs.h, include/linux/fsnotify_backend.h, include/linux/fsnotify.h): include/linux/ioprio.h:60:34: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected int ioprio @@ got struct task_struct * @@ include/linux/ioprio.h:60:34: sparse: expected int ioprio include/linux/ioprio.h:60:34: sparse: got struct task_struct * fs/read_write.c: note: in included file (through include/linux/thread_info.h, arch/x86/include/asm/preempt.h, include/linux/preempt.h, ...): >> arch/x86/include/asm/current.h:15:16: sparse: sparse: non size-preserving pointer to integer cast -- fs/seq_file.c:938:9: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/seq_file.c:938:9: sparse: struct list_head [noderef] __rcu * fs/seq_file.c:938:9: sparse: struct list_head * fs/seq_file.c:938:9: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/seq_file.c:938:9: sparse: struct list_head [noderef] __rcu * fs/seq_file.c:938:9: sparse: struct list_head * fs/seq_file.c:960:12: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct list_head *lh @@ got struct list_head [noderef] __rcu * @@ fs/seq_file.c:960:12: sparse: expected struct list_head *lh fs/seq_file.c:960:12: sparse: got struct list_head [noderef] __rcu * fs/seq_file.c:1087:24: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/seq_file.c:1087:24: sparse: struct hlist_node [noderef] __rcu * fs/seq_file.c:1087:24: sparse: struct hlist_node * fs/seq_file.c:1089:24: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/seq_file.c:1089:24: sparse: struct hlist_node [noderef] __rcu * fs/seq_file.c:1089:24: sparse: struct hlist_node * fs/seq_file.c: note: in included file (through include/linux/fs.h): include/linux/ioprio.h:60:34: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected int ioprio @@ got struct task_struct * @@ include/linux/ioprio.h:60:34: sparse: expected int ioprio include/linux/ioprio.h:60:34: sparse: got struct task_struct * fs/seq_file.c: note: in included file (through include/linux/thread_info.h, arch/x86/include/asm/preempt.h, include/linux/preempt.h, ...): >> arch/x86/include/asm/current.h:15:16: sparse: sparse: non size-preserving pointer to integer cast -- fs/splice.c: note: in included file (through include/linux/fs.h, include/linux/highmem.h, include/linux/bvec.h): include/linux/ioprio.h:60:34: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected int ioprio @@ got struct task_struct * @@ include/linux/ioprio.h:60:34: sparse: expected int ioprio include/linux/ioprio.h:60:34: sparse: got struct task_struct * fs/splice.c: note: in included file (through include/linux/thread_info.h, arch/x86/include/asm/preempt.h, include/linux/preempt.h, ...): >> arch/x86/include/asm/current.h:15:16: sparse: sparse: non size-preserving pointer to integer cast vim +15 arch/x86/include/asm/current.h f0766440dda7ace include/asm-x86/current.h Christoph Lameter 2008-05-09 12 f0766440dda7ace include/asm-x86/current.h Christoph Lameter 2008-05-09 13 static __always_inline struct task_struct *get_current(void) f0766440dda7ace include/asm-x86/current.h Christoph Lameter 2008-05-09 14 { c6ae41e7d469f00 arch/x86/include/asm/current.h Alex Shi 2012-05-11 @15 return this_cpu_read_stable(current_task); f0766440dda7ace include/asm-x86/current.h Christoph Lameter 2008-05-09 16 } f0766440dda7ace include/asm-x86/current.h Christoph Lameter 2008-05-09 17
diff --git a/block/ioprio.c b/block/ioprio.c index 2a34cbca18ae..c4e3476155a1 100644 --- a/block/ioprio.c +++ b/block/ioprio.c @@ -138,6 +138,32 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) return ret; } +/* + * If the task has set an I/O priority, use that. Otherwise, return + * the default I/O priority. + * + * Expected to be called for current task or with task_lock() held to keep + * io_context stable. + */ +int __get_task_ioprio(struct task_struct *p) +{ + struct io_context *ioc = p->io_context; + int prio; + + if (p != current) + lockdep_assert_held(&p->alloc_lock); + if (ioc) + prio = ioc->ioprio; + else + prio = IOPRIO_DEFAULT; + + if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE) + prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(p), + task_nice_ioprio(p)); + return prio; +} +EXPORT_SYMBOL_GPL(__get_task_ioprio); + static int get_task_ioprio(struct task_struct *p) { int ret; diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index 61ed6bb4998e..788a8ff57068 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h @@ -46,24 +46,18 @@ static inline int task_nice_ioclass(struct task_struct *task) return IOPRIO_CLASS_BE; } -/* - * If the calling process has set an I/O priority, use that. Otherwise, return - * the default I/O priority. - */ -static inline int get_current_ioprio(void) +#ifdef CONFIG_BLOCK +int __get_task_ioprio(struct task_struct *p); +#else +static inline int __get_task_ioprio(int ioprio) { - struct io_context *ioc = current->io_context; - int prio; - - if (ioc) - prio = ioc->ioprio; - else - prio = IOPRIO_DEFAULT; + return IOPRIO_DEFAULT; +} +#endif /* CONFIG_BLOCK */ - if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE) - prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(current), - task_nice_ioprio(current)); - return prio; +static inline int get_current_ioprio(void) +{ + return __get_task_ioprio(current); } /*
get_current_ioprio() operates only on current task. We will need the same functionality for other tasks as well. Generalize get_current_ioprio() for that and also move the bulk out of the header file because it is large enough. Signed-off-by: Jan Kara <jack@suse.cz> --- block/ioprio.c | 26 ++++++++++++++++++++++++++ include/linux/ioprio.h | 26 ++++++++++---------------- 2 files changed, 36 insertions(+), 16 deletions(-)