]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arch: setup PF_IO_WORKER threads like PF_KTHREAD
authorJens Axboe <axboe@kernel.dk>
Wed, 17 Feb 2021 15:48:00 +0000 (08:48 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jan 2023 10:39:22 +0000 (11:39 +0100)
[ Upstream commit 4727dc20e0422211a0e0c72b1ace4ed6096df8a6 ]

PF_IO_WORKER are kernel threads too, but they aren't PF_KTHREAD in the
sense that we don't assign ->set_child_tid with our own structure. Just
ensure that every arch sets up the PF_IO_WORKER threads like kthreads
in the arch implementation of copy_thread().

Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 files changed:
arch/alpha/kernel/process.c
arch/arc/kernel/process.c
arch/arm/kernel/process.c
arch/arm64/kernel/process.c
arch/csky/kernel/process.c
arch/h8300/kernel/process.c
arch/hexagon/kernel/process.c
arch/ia64/kernel/process.c
arch/m68k/kernel/process.c
arch/microblaze/kernel/process.c
arch/mips/kernel/process.c
arch/nds32/kernel/process.c
arch/nios2/kernel/process.c
arch/openrisc/kernel/process.c
arch/riscv/kernel/process.c
arch/s390/kernel/process.c
arch/sh/kernel/process_32.c
arch/sparc/kernel/process_32.c
arch/sparc/kernel/process_64.c
arch/um/kernel/process.c
arch/x86/kernel/process.c
arch/xtensa/kernel/process.c

index 4c7b0414a3ff3b2437ab27ece6bbb9b04f9eb31d..08335b2294b3c1b2d6b91e99edbec1320ee93417 100644 (file)
@@ -249,7 +249,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
        childti->pcb.ksp = (unsigned long) childstack;
        childti->pcb.flags = 1; /* set FEN, clear everything else */
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                /* kernel thread */
                memset(childstack, 0,
                        sizeof(struct switch_stack) + sizeof(struct pt_regs));
index a85e9c625ab50b693337ad1ebbf1f5b36372b68f..8cf2caae93f1a8884a971883c84d2c5f83e804bb 100644 (file)
@@ -191,7 +191,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
        childksp[0] = 0;                        /* fp */
        childksp[1] = (unsigned long)ret_from_fork; /* blink */
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                memset(c_regs, 0, sizeof(struct pt_regs));
 
                c_callee->r13 = kthread_arg;
index 9f199b1e838391a71f9018e1763867f597f5ad85..2647e48c537e618ec631b077538b5f43485017ed 100644 (file)
@@ -243,7 +243,7 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,
        thread->cpu_domain = get_domain();
 #endif
 
-       if (likely(!(p->flags & PF_KTHREAD))) {
+       if (likely(!(p->flags & (PF_KTHREAD | PF_IO_WORKER)))) {
                *childregs = *current_pt_regs();
                childregs->ARM_r0 = 0;
                if (stack_start)
index 22275d8518eb39fa8bd4287deaad832453cfa0fb..3696dbcbfa80c6bc2c1e6568834a62bc8714a7ba 100644 (file)
@@ -398,7 +398,7 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,
 
        ptrauth_thread_init_kernel(p);
 
-       if (likely(!(p->flags & PF_KTHREAD))) {
+       if (likely(!(p->flags & (PF_KTHREAD | PF_IO_WORKER)))) {
                *childregs = *current_pt_regs();
                childregs->regs[0] = 0;
 
index 69af6bc87e6473d2c0c868cf364893e3593f8adf..3d0ca22cd0e2e6075c4bcdcb5d69d6e55f5131f1 100644 (file)
@@ -49,7 +49,7 @@ int copy_thread(unsigned long clone_flags,
        /* setup thread.sp for switch_to !!! */
        p->thread.sp = (unsigned long)childstack;
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                memset(childregs, 0, sizeof(struct pt_regs));
                childstack->r15 = (unsigned long) ret_from_kernel_thread;
                childstack->r10 = kthread_arg;
index bc1364db58feb01e82c1fd407dea4ee0a8611944..46b1342ce515b3a33b63a9559786fbe55f2770ce 100644 (file)
@@ -112,7 +112,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
 
        childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1;
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                memset(childregs, 0, sizeof(struct pt_regs));
                childregs->retpc = (unsigned long) ret_from_kernel_thread;
                childregs->er4 = topstk; /* arg */
index 6a980cba7b294ce709c5b7e971a065c0d451b7b2..c61165c99ae0ba9d45c79e6f3ab9323ef72cebc4 100644 (file)
@@ -73,7 +73,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,
                                                    sizeof(*ss));
        ss->lr = (unsigned long)ret_from_fork;
        p->thread.switch_sp = ss;
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                memset(childregs, 0, sizeof(struct pt_regs));
                /* r24 <- fn, r25 <- arg */
                ss->r24 = usp;
index 70649a5b3e8881a07ec3e504eb23ad4fc4d25d3f..8159b7af5509f4e21818f76bf15ac2ee24289390 100644 (file)
@@ -338,7 +338,7 @@ copy_thread(unsigned long clone_flags, unsigned long user_stack_base,
 
        ia64_drop_fpu(p);       /* don't pick up stale state from a CPU's fph */
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                if (unlikely(!user_stack_base)) {
                        /* fork_idle() called us */
                        return 0;
index 08359a6e058f632294989db6800dcddd5626a0f2..da83cc83e79123b92654fb99f1dbbeb972593d09 100644 (file)
@@ -157,7 +157,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,
         */
        p->thread.fs = get_fs().seg;
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                /* kernel thread */
                memset(frame, 0, sizeof(struct fork_frame));
                frame->regs.sr = PS_S;
index f99860771ff4854f13b1c3832edb53f1fd61ac1c..ee000ae17e3956529f2d72933943518a11375c44 100644 (file)
@@ -59,7 +59,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,
        struct pt_regs *childregs = task_pt_regs(p);
        struct thread_info *ti = task_thread_info(p);
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                /* if we're creating a new kernel thread then just zeroing all
                 * the registers. That's OK for a brand new thread.*/
                memset(childregs, 0, sizeof(struct pt_regs));
index 75ebd8d7bd5d00bd0bdd29e9c80e0581a69bfbdf..98ecaf6f3edb0c1b8c0e82626292c2668c39cc60 100644 (file)
@@ -135,7 +135,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
        /*  Put the stack after the struct pt_regs.  */
        childksp = (unsigned long) childregs;
        p->thread.cp0_status = (read_c0_status() & ~(ST0_CU2|ST0_CU1)) | ST0_KERNEL_CUMASK;
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                /* kernel thread */
                unsigned long status = p->thread.cp0_status;
                memset(childregs, 0, sizeof(struct pt_regs));
index e01ad5d1722450f2f4b54e16e615b4c9cf4dea40..c1327e552ec6c68a66ea708c127e7fc7e00d1df3 100644 (file)
@@ -156,7 +156,7 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,
 
        memset(&p->thread.cpu_context, 0, sizeof(struct cpu_context));
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                memset(childregs, 0, sizeof(struct pt_regs));
                /* kernel thread fn */
                p->thread.cpu_context.r6 = stack_start;
index 50b4eb19a6cc9962198ddbe12e1ba02bf2324d4b..c5f916ca6845f02876a9826a0b0fa9dcfa265715 100644 (file)
@@ -109,7 +109,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,
        struct switch_stack *childstack =
                ((struct switch_stack *)childregs) - 1;
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                memset(childstack, 0,
                        sizeof(struct switch_stack) + sizeof(struct pt_regs));
 
index 3c98728cce2491c80e586945760b4603e1714c71..83fba4ee44535db18c39c528f82b51cddc14f7dc 100644 (file)
@@ -167,7 +167,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,
        sp -= sizeof(struct pt_regs);
        kregs = (struct pt_regs *)sp;
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                memset(kregs, 0, sizeof(struct pt_regs));
                kregs->gpr[20] = usp; /* fn, kernel thread */
                kregs->gpr[22] = arg;
index 9a8b2e60adcf16863493b0816e715ee1823b04da..7868050ff426da5a270703d324d09bc55013ecc5 100644 (file)
@@ -114,7 +114,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,
        memset(&p->thread.s, 0, sizeof(p->thread.s));
 
        /* p->thread holds context to be restored by __switch_to() */
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                /* Kernel thread */
                memset(childregs, 0, sizeof(struct pt_regs));
                childregs->gp = gp_in_global;
index 137a170f47d4fb5e9dd2b752c9a250b4047bae3a..bd7da4049707cb72a9d9d52e69f499eaa9dd7bfe 100644 (file)
@@ -127,7 +127,7 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp,
        frame->sf.gprs[9] = (unsigned long) frame;
 
        /* Store access registers to kernel stack of new process. */
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                /* kernel thread */
                memset(&frame->childregs, 0, sizeof(struct pt_regs));
                frame->childregs.psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT |
index 80a5d1c66a5175ffa4af49fe8ddd086d41eac978..1aa508eb0823ae3d0ffd70437d22227a585b21b9 100644 (file)
@@ -114,7 +114,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,
 
        childregs = task_pt_regs(p);
        p->thread.sp = (unsigned long) childregs;
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                memset(childregs, 0, sizeof(struct pt_regs));
                p->thread.pc = (unsigned long) ret_from_kernel_thread;
                childregs->regs[4] = arg;
index a023637359154e9bbd874a574bd9f95ba50c5b10..0f9c606e1e78edce6a3e1abedca7a9498a8e10b8 100644 (file)
@@ -309,7 +309,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, unsigned long arg,
        ti->ksp = (unsigned long) new_stack;
        p->thread.kregs = childregs;
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                extern int nwindows;
                unsigned long psr;
                memset(new_stack, 0, STACKFRAME_SZ + TRACEREG_SZ);
index 6f8c7822fc065d394c0e573aa5eae10851a34542..7afd0a859a78c8aa0389de0e6409df7defa7adc7 100644 (file)
@@ -597,7 +597,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, unsigned long arg,
                                       sizeof(struct sparc_stackf));
        t->fpsaved[0] = 0;
 
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                memset(child_trap_frame, 0, child_stack_sz);
                __thread_flag_byte_ptr(t)[TI_FLAG_BYTE_CWP] = 
                        (current_pt_regs()->tstate + 1) & TSTATE_CWP;
index 067fb85fbf118813d5144e3d8ab4a00b467f5e81..e6c9b11b20334169b0408dc0d77938dfccc8e53e 100644 (file)
@@ -157,7 +157,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
                unsigned long arg, struct task_struct * p, unsigned long tls)
 {
        void (*handler)(void);
-       int kthread = current->flags & PF_KTHREAD;
+       int kthread = current->flags & (PF_KTHREAD | PF_IO_WORKER);
        int ret = 0;
 
        p->thread = (struct thread_struct) INIT_THREAD;
index 383afcc1098bf1de38761b2546353b8ea4336fb4..4d46c52d9c055b5592867fb8f732c6492d0d58f6 100644 (file)
@@ -162,7 +162,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, unsigned long arg,
 #endif
 
        /* Kernel thread ? */
-       if (unlikely(p->flags & PF_KTHREAD)) {
+       if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                memset(childregs, 0, sizeof(struct pt_regs));
                kthread_frame_init(frame, sp, arg);
                return 0;
index 397a7de563776acbc5c8a17b27abae1cf1564d43..9534ef515d7487d9a82cdbb1aa626f2f4b9b99f7 100644 (file)
@@ -217,7 +217,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn,
 
        p->thread.sp = (unsigned long)childregs;
 
-       if (!(p->flags & PF_KTHREAD)) {
+       if (!(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
                struct pt_regs *regs = current_pt_regs();
                unsigned long usp = usp_thread_fn ?
                        usp_thread_fn : regs->areg[1];