Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1800537pxf; Fri, 26 Mar 2021 15:26:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq0XFLEgyUqFM3D4U4MRRMbuTtLJYkLT9A629LEOJYoFIj4iSZOj206p6woN0JVWt11yQo X-Received: by 2002:aa7:cd64:: with SMTP id ca4mr17223626edb.334.1616797587139; Fri, 26 Mar 2021 15:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616797587; cv=none; d=google.com; s=arc-20160816; b=S2MThfj1gOpnvJruwjVLx434gdieV5igh7KA76N5dtB49l1JYGBkyB9VK8QjbVk1ba Z+UQd7WIVa2gdin0/S9Jb83iQC+9wmOGV0a93x151THPWRXu3K3y0jEJYiDcNFa0Zl6w bWuC729IGj7wrCjAkmT9CIpc6WKKrMpVqWZHjcnDt2p34jNFiU0iF3yS0L/pOUWtt/ZB kO5xuRox0s9UUhRoRgeyQmvWcblgmK9nzmzU/8mM4H1ILM2CqQDZhlFitofe35rEqfJW 6/oYHKgRlKBoJuOWHT3dPnRzf7yeV3aSnhVjPlQ5ATtjLNBIuLT5cX2qnKo8t1M4pr3r phHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:mime-version:user-agent:message-id :in-reply-to:date:references:cc:to:from; bh=jq0eFKeWYKE8rDbjAXDOrkLFVqmAd31UYtnYrCXmfcE=; b=02O8zpsMDFuGGxFq4PwvC1zqSSLkOGYnAHCIiWiPkGSe66mefarT1+x/6qhGsIAJuq 0pNyocuuvy0uEtRh6hikimPs5jFJpkrTSX1mY/Gl2uCya4kbvl1jQSujVeZatOm8Nu/o cURHvoSiGhX7IC87+tMpwtWbYUAU0eamuL6fTQm93Qis2sVxQkffWJ6DIGNhsKSzPwGk fsJpFazIVQNC0adsha+pHnCAbQ/oQRX7wCODlHwDj/4jzbQ/faUawGw3CN8bPVuXroki huSbZhHmmEOrTn1Tbr7ErY3ujHzc344qHL+FTL4UnLp5MTYUg5IQuL4xwSwo26RIbGWD e7vA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y5si7652127eda.385.2021.03.26.15.26.04; Fri, 26 Mar 2021 15:26:27 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230240AbhCZWYi (ORCPT + 99 others); Fri, 26 Mar 2021 18:24:38 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:45548 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbhCZWYK (ORCPT ); Fri, 26 Mar 2021 18:24:10 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lPusC-000XAB-LB; Fri, 26 Mar 2021 16:24:08 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=fess.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lPusB-00BL1H-2w; Fri, 26 Mar 2021 16:24:08 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Jens Axboe Cc: io-uring@vger.kernel.org, torvalds@linux-foundation.org, metze@samba.org, oleg@redhat.com, linux-kernel@vger.kernel.org References: <20210326155128.1057078-1-axboe@kernel.dk> <20210326155128.1057078-3-axboe@kernel.dk> <106a38d3-5a5f-17fd-41f7-890f5e9a3602@kernel.dk> Date: Fri, 26 Mar 2021 17:23:08 -0500 In-Reply-To: <106a38d3-5a5f-17fd-41f7-890f5e9a3602@kernel.dk> (Jens Axboe's message of "Fri, 26 Mar 2021 16:14:48 -0600") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1lPusB-00BL1H-2w;;;mid=;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/shYyeRWs6JVLWuaWNXtLje+PNW5eZ8CQ= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa06.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01,XMNoVowels, XMSubLong autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4999] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Jens Axboe X-Spam-Relay-Country: X-Spam-Timing: total 1081 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 18 (1.6%), b_tie_ro: 16 (1.4%), parse: 2.1 (0.2%), extract_message_metadata: 16 (1.5%), get_uri_detail_list: 1.79 (0.2%), tests_pri_-1000: 6 (0.5%), tests_pri_-950: 1.54 (0.1%), tests_pri_-900: 1.13 (0.1%), tests_pri_-90: 60 (5.5%), check_bayes: 58 (5.4%), b_tokenize: 8 (0.7%), b_tok_get_all: 8 (0.7%), b_comp_prob: 2.6 (0.2%), b_tok_touch_all: 36 (3.3%), b_finish: 1.32 (0.1%), tests_pri_0: 231 (21.3%), check_dkim_signature: 0.68 (0.1%), check_dkim_adsp: 2.5 (0.2%), poll_dns_idle: 710 (65.6%), tests_pri_10: 3.1 (0.3%), tests_pri_500: 738 (68.3%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 2/7] io_uring: handle signals for IO threads like a normal thread X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jens Axboe writes: > On 3/26/21 2:29 PM, Eric W. Biederman wrote: >> Jens Axboe writes: >> >>> 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 | 24 +++++++++++++++++------- >>> fs/io_uring.c | 12 ++++++++---- >>> 2 files changed, 25 insertions(+), 11 deletions(-) >>> >>> diff --git a/fs/io-wq.c b/fs/io-wq.c >>> index b7c1fa932cb3..3e2f059a1737 100644 >>> --- a/fs/io-wq.c >>> +++ b/fs/io-wq.c >>> @@ -16,7 +16,6 @@ >>> #include >>> #include >>> #include >>> -#include >>> >>> #include "../kernel/sched/sched.h" >>> #include "io-wq.h" >>> @@ -503,10 +502,16 @@ static int io_wqe_worker(void *data) >>> if (io_flush_signals()) >>> continue; >>> ret = schedule_timeout(WORKER_IDLE_TIMEOUT); >>> - if (try_to_freeze() || ret) >>> + if (signal_pending(current)) { >>> + struct ksignal ksig; >>> + >>> + if (fatal_signal_pending(current)) >>> + break; >>> + if (get_signal(&ksig)) >>> + continue; >> ^^^^^^^^^^^^^^^^^^^^^^ >> >> That is wrong. You are promising to deliver a signal to signal >> handler and them simply discarding it. Perhaps: >> >> if (!get_signal(&ksig)) >> continue; >> WARN_ON(!sig_kernel_stop(ksig->sig)); >> break; > > Thanks, updated. Gah. Kill the WARN_ON. I was thinking "WARN_ON(!sig_kernel_fatal(ksig->sig));" The function sig_kernel_fatal does not exist. Fatal is the state that is left when a signal is neither ignored nor a stop signal, and does not have a handler. The rest of the logic still works. Eric