From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2608BBA49 for ; Tue, 7 Mar 2023 18:33:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 915D0C433D2; Tue, 7 Mar 2023 18:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678214001; bh=e+aCyR8uFpK1KxrnJjdCn6s/aY7gP7DSHT5g7davwvg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oSio52BNAMNvWsgPMlySiBns95M1uy1ms2ck0JOmQ31jkRXntSx9q8DI5NKrFCl+S e4bKpG6FPJ+m9YYsjhAlGkCeba7yRBc0N2vwNtoKECXweeKnUgAKqiNN7lSbDmAiZ6 aoFaVZf69ZqWSav77PjaVzltsl0zoC4s+3aVTy6A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, kernel test robot , Jens Axboe Subject: [PATCH 6.1 688/885] io_uring: mark task TASK_RUNNING before handling resume/task work Date: Tue, 7 Mar 2023 18:00:22 +0100 Message-Id: <20230307170032.006354296@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170001.594919529@linuxfoundation.org> References: <20230307170001.594919529@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jens Axboe commit 2f2bb1ffc9983e227424d0787289da5483b0c74f upstream. Just like for task_work, set the task mode to TASK_RUNNING before doing any potential resume work. We're not holding any locks at this point, but we may have already set the task state to TASK_INTERRUPTIBLE in preparation for going to sleep waiting for events. Ensure that we set it back to TASK_RUNNING if we have work to process, to avoid warnings on calling blocking operations with !TASK_RUNNING. Fixes: b5d3ae202fbf ("io_uring: handle TIF_NOTIFY_RESUME when checking for task_work") Reported-by: kernel test robot Link: https://lore.kernel.org/oe-lkp/202302062208.24d3e563-oliver.sang@intel.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/io_uring.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -261,8 +261,10 @@ static inline int io_run_task_work(void) * notify work that needs processing. */ if (current->flags & PF_IO_WORKER && - test_thread_flag(TIF_NOTIFY_RESUME)) + test_thread_flag(TIF_NOTIFY_RESUME)) { + __set_current_state(TASK_RUNNING); resume_user_mode_work(NULL); + } if (task_work_pending(current)) { __set_current_state(TASK_RUNNING); task_work_run();