Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp907594pxf; Thu, 25 Mar 2021 17:43:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzITEm71tlzkvox6hw0sknO7+3RGhtfwoG8Fc/Uj8IxwyqPDSyzqwmDUbygVdA3+J7pR8jG X-Received: by 2002:a17:906:828e:: with SMTP id h14mr12614885ejx.529.1616719399692; Thu, 25 Mar 2021 17:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616719399; cv=none; d=google.com; s=arc-20160816; b=UvqN4i5TYP03+3IOIkE7l8SQO8MA8q6fyHeu1Z83UeUwQ4ZrzxmgVuHfZC6vMsEu81 pDjwWcLApqBxmoAwO7lRyrV5CmuFVkuSsasePEA9/jwQS3GLf+/WoqODdYL2QSs7emr8 7AL2Mu28kxZhLytNqwOzwnCUqrGIWaSAkWmPhxa5XL3QRQmpFj0CnjPNRJ4Hv2uh9Zr4 9AHJLO2X5m/6qg6wK2i3pzKALDSqHQYUyUDsUYoTTRrGsKqiK0ao01uuD6TCwuG8vCfk uri/QGVvBVX46FbWZuixEUn99IWzlhb2mOiMWRKR3G5LgTAQNsN+aRskHRPFF7BtKZBJ S6wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=u31N5Wr92UrFihPVzfkVhThkgUf8nV6eK/V9ieSsv2s=; b=MKcwsU+POITpjAQoVezXuV2UqSedzm1zu5QqfsSQUpgy+TnY6+CANqyFL+c080V/fT zuma99oixK9zsvXB9F6gh7XRFYj4xlZVSy7+tT0RLOKGf5upnJcx9i7n0NMkiGTg3Cwm yyvfc3QBmVyFWXzom680QfXvKlgc25ScoWUpTSXBfPQeGQd/ts3ZXk4tx3G+q1louZ7s NrjJ+2+rNlZX1yzpnUZxDmzEHkj4sR0Fd+kThsCAytO+tkWQ7T0kemrBKSDKuecR6NSW RxO2JkXiOA7NraRCQnZAr01cGrPc0icmb0/xTkrNJpjAulfH506qmSWhGhQXxB3BsaEc yezg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=W8MjlAyn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v10si5499655ejq.299.2021.03.25.17.42.57; Thu, 25 Mar 2021 17:43:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=W8MjlAyn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230105AbhCZAlT (ORCPT + 99 others); Thu, 25 Mar 2021 20:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229951AbhCZAkr (ORCPT ); Thu, 25 Mar 2021 20:40:47 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A748C061760 for ; Thu, 25 Mar 2021 17:40:47 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id o2so75043plg.1 for ; Thu, 25 Mar 2021 17:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u31N5Wr92UrFihPVzfkVhThkgUf8nV6eK/V9ieSsv2s=; b=W8MjlAynV2PBwCxaVG1EzhkOH8TEqd+g9rkxajjr7j0TWk9FOdMAcKQEyT4F9Z5ij3 ++XkBhY7GQUZXY2cOHUoW7FldybK4vJhbwo3YPIWNb4G3lWiVIrCq8sxh6c0HGY55LcF 4s+Lu/Mjon51sfo0NSkddEvHt+Vi6+cx3oM/spENBEHII5sdMNj44dJY78cYXYvbygfQ 4koToRAxKyUGLuf0xa/rdZl2+o2oSInjRE6ZyUQH98Tg3j4U3zmNEPn2jCH1Eh1AZ/6v 30afjrJRawb3Asem0+wYTZKp8DUaDH9Ai/3iQY0mG9TY5XA0wPpel6iFCt5HbY7Upx9x isKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u31N5Wr92UrFihPVzfkVhThkgUf8nV6eK/V9ieSsv2s=; b=THjo0T72lYdPf0+eZZKz6HwcfiWE8oJ19q9ltHjEI/w9gPBQZBr7j91dXxSMS/UagS 6WKHbTSw2IWILSUg7BKO2SjQPWn9sWBdR5AZqG4VgEGDspwootL9Jc0mJjGu2DPx7Fba WC2R34hMlJUcaVmFy+QQ0Zs7O4gKAEaYx+mqEYp386++UUJEyDs/9Djy3yDx4ojrvzPe 8ejsVqmVyG73dDsqIAAMoIIWSxyNwq73aEocYEg7wZSX6Kx1z090k20juelmx64xU0bN sAu4/6VZXvUJnxpwxcabBOx11jfBRbgaYMPOsdouSquchQVKp+7X98j8Z/9j69hQ/oZC OXQg== X-Gm-Message-State: AOAM5337qX3kbo4unRX//0Zpsdnetf8HSh7vBGIgKv2tdup2EAsQuSsC NkRo1bLHcm8Nfi513CopeWyBUw== X-Received: by 2002:a17:90a:bc06:: with SMTP id w6mr10859453pjr.44.1616719246498; Thu, 25 Mar 2021 17:40:46 -0700 (PDT) Received: from localhost.localdomain ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id c128sm6899448pfc.76.2021.03.25.17.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Mar 2021 17:40:46 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: torvalds@linux-foundation.org, ebiederm@xmission.com, metze@samba.org, oleg@redhat.com, linux-kernel@vger.kernel.org, Jens Axboe Subject: [PATCH 1/8] io_uring: handle signals for IO threads like a normal thread Date: Thu, 25 Mar 2021 18:39:24 -0600 Message-Id: <20210326003928.978750-2-axboe@kernel.dk> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210326003928.978750-1-axboe@kernel.dk> References: <20210326003928.978750-1-axboe@kernel.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We go through various hoops to disallow signals for the IO threads, but there's really no reason why we cannot just allow them. The IO threads never return to userspace like a normal thread, and hence don't go through normal signal processing. Instead, just check for a pending signal as part of the work loop, and call get_signal() to handle it for us if anything is pending. With that, we can support receiving signals, including special ones like SIGSTOP. Signed-off-by: Jens Axboe --- fs/io-wq.c | 21 +++++++++++++++++---- fs/io_uring.c | 10 ++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/fs/io-wq.c b/fs/io-wq.c index b7c1fa932cb3..2dbdc552f3ba 100644 --- a/fs/io-wq.c +++ b/fs/io-wq.c @@ -505,8 +505,14 @@ static int io_wqe_worker(void *data) ret = schedule_timeout(WORKER_IDLE_TIMEOUT); if (try_to_freeze() || ret) continue; - if (fatal_signal_pending(current)) - break; + if (signal_pending(current)) { + struct ksignal ksig; + + if (fatal_signal_pending(current)) + break; + get_signal(&ksig); + continue; + } /* timed out, exit unless we're the fixed worker */ if (test_bit(IO_WQ_BIT_EXIT, &wq->state) || !(worker->flags & IO_WORKER_F_FIXED)) @@ -715,8 +721,15 @@ static int io_wq_manager(void *data) io_wq_check_workers(wq); schedule_timeout(HZ); try_to_freeze(); - if (fatal_signal_pending(current)) - set_bit(IO_WQ_BIT_EXIT, &wq->state); + if (signal_pending(current)) { + struct ksignal ksig; + + if (fatal_signal_pending(current)) + set_bit(IO_WQ_BIT_EXIT, &wq->state); + else + get_signal(&ksig); + continue; + } } while (!test_bit(IO_WQ_BIT_EXIT, &wq->state)); io_wq_check_workers(wq); diff --git a/fs/io_uring.c b/fs/io_uring.c index 54ea561db4a5..3a9d021db328 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6765,8 +6765,14 @@ static int io_sq_thread(void *data) timeout = jiffies + sqd->sq_thread_idle; continue; } - if (fatal_signal_pending(current)) - break; + if (signal_pending(current)) { + struct ksignal ksig; + + if (fatal_signal_pending(current)) + break; + get_signal(&ksig); + continue; + } sqt_spin = false; cap_entries = !list_is_singular(&sqd->ctx_list); list_for_each_entry(ctx, &sqd->ctx_list, sqd_list) { -- 2.31.0