Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2173797rwd; Tue, 13 Jun 2023 21:58:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6bzBlaC9SOGwiTcmnJxhfk07rRgo9Bk9VEOk0eXSP9IaamCKcg6Du/gcSWuQXJbGGKtH3i X-Received: by 2002:a17:90a:194b:b0:25b:aed4:a80b with SMTP id 11-20020a17090a194b00b0025baed4a80bmr773588pjh.1.1686718725896; Tue, 13 Jun 2023 21:58:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686718725; cv=none; d=google.com; s=arc-20160816; b=a3Bkz4pnYrRUFuRXc+rSMymBAOOgV76oAsAbdjNwyvBaz2lnCIhpHhmJkWtOiCXYxd mFZByYUFjkCejp2bviSKwOPsemdKtYf0qS+Mqu437Yxm028meyXgio1RszMm34fj+94P Otnr06UPywBXGqzcmvkiuR9ojA+5d0aya3clW/9TT3BAarW0KPFlzgDtZpDTmbnV/oIz Mfoj6tUTLpUBKOxI3KhVUxzKXe0IVvJ5Bes58tkowbPfLU7YbP+xu2EzfdbbaX1pv7Ko f1zRRljplqwlAFzX7t67gccx/u2yaLPldgH1sBPnLlciTEL0EkqGWfox2QwiLZeDNZxh O9JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qHRc1Mkyk+K0FJWIMqVw/kpFNdAJq+RCcKh1xxVrXLw=; b=lriQrfLmTUND+VRizLGPwG3srvW2yT4db2vafHn4xwMnoCzTZ9VANcWDoe9cw874+l IfCpZ5g5rpPB+fopOri+oUQjX1M2BcOhMWs0b1C3n2i60GFYnB4Q9uYANnpvI56RtMiI NXksuTWz5+o1fEwaC28a1m6Cls/HZ+S2Tm4cYZSj+ps48KbBlpXhQp1iBVHl6GDMXiAU swwa+O+blU/FUYFP5hxRZlrvfujZoJzXldC+t9Vwy76ffea74+XecEAwwRISI6Qz5+o5 uarsYY3xlRkoDLbqwBDzZKBuhwm+Kk4T264FkhoWluSgqKfwN+81BHPEZCo4S+99Xi6F 1S4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Rcpi/lCB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020a17090a1bc400b00252e51a9fbasi6703060pjr.122.2023.06.13.21.58.33; Tue, 13 Jun 2023 21:58:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Rcpi/lCB"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242637AbjFNEu2 (ORCPT + 99 others); Wed, 14 Jun 2023 00:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242671AbjFNEuT (ORCPT ); Wed, 14 Jun 2023 00:50:19 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A2EBE61 for ; Tue, 13 Jun 2023 21:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686718170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qHRc1Mkyk+K0FJWIMqVw/kpFNdAJq+RCcKh1xxVrXLw=; b=Rcpi/lCBZg06UHbvygYlyW6Gn6VM0rw6QsqHY+iguzCaA2nZ2GPqr/fdApAdlAsDFHrxc1 vb05V9HfQcoKhvAlK948+yMtCjv756gmj9EtxKB9fm18Y8dv7YvQEn4RUEFKRuCX4xjtPh 8U6lNXs/nJXXyWX4qUfJRXMvYeHy7xM= Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-377-2w9Z1wwIMlS6pv9Tu_APvA-1; Wed, 14 Jun 2023 00:49:27 -0400 X-MC-Unique: 2w9Z1wwIMlS6pv9Tu_APvA-1 Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-1b3cab3a48dso25018155ad.3 for ; Tue, 13 Jun 2023 21:49:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686718166; x=1689310166; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qHRc1Mkyk+K0FJWIMqVw/kpFNdAJq+RCcKh1xxVrXLw=; b=fGlJjdHXVp1ZdSQNC//aAw88aZsNEnMNvDOwXaTbygS5jkB27z+ZgXvnZqmALcEt0E agx8Lp6FCDFKVb+Ju/7IO04tmtKbqF8U6IGCrokcyF9eFRUQTBHxsggG1YWWpxZK0wXi 3YKwxUJQW+x6XKz3Apbp8KfZuk+UMfyv41XyXPgbMrZpQhT749phOphDFxs6xb3iI9/j ABHwjqwIMg8eO5GQuCQk5XuuK6qRo12p8JEt+A6R01YJCEG4Wo/riKHoRruXSKURbkID nMvq6Z8A/HEB4sKf4E4cDJPIT/C0TP4zMugCcCGlYc8gnHMCTIvbKKpwK9+wipK1En9P bpoA== X-Gm-Message-State: AC+VfDyisS7tL7fuV9uGqVw1Z/eRBcrELJA6X0COOYhmZm1DPeHJAlPS Z2iyYvd9ZBWIEja/HAIbIVixi5oeXdPRE6kkaMcGD87AMSxatQhCt/Uzlwv4KSrCN/C5pwarpBP dnim/jCSRkyDq0PzFHS9D6zFv X-Received: by 2002:a17:902:8205:b0:1b2:194b:9ce9 with SMTP id x5-20020a170902820500b001b2194b9ce9mr9570236pln.44.1686718166632; Tue, 13 Jun 2023 21:49:26 -0700 (PDT) X-Received: by 2002:a17:902:8205:b0:1b2:194b:9ce9 with SMTP id x5-20020a170902820500b001b2194b9ce9mr9570219pln.44.1686718166272; Tue, 13 Jun 2023 21:49:26 -0700 (PDT) Received: from zlang-mailbox ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id r21-20020a170902ea5500b001b19d14a3d5sm11107447plg.68.2023.06.13.21.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 21:49:25 -0700 (PDT) Date: Wed, 14 Jun 2023 12:49:21 +0800 From: Zorro Lang To: Jens Axboe Cc: io-uring , LKML , Linus Torvalds , Dave Chinner Subject: Re: [PATCH] io_uring/io-wq: don't clear PF_IO_WORKER on exit Message-ID: <20230614044921.7wxs7w3uncjns33i@zlang-mailbox> References: <2392dcb4-71f4-1109-614b-4e2083c0941e@kernel.dk> <20230614005449.awc2ncxl5lb2eg6m@zlang-mailbox> <5d5ccbb1-784c-52b3-3748-2cf7b5cf01ef@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5d5ccbb1-784c-52b3-3748-2cf7b5cf01ef@kernel.dk> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 13, 2023 at 07:14:25PM -0600, Jens Axboe wrote: > On 6/13/23 6:54?PM, Zorro Lang wrote: > > On Mon, Jun 12, 2023 at 12:11:57PM -0600, Jens Axboe wrote: > >> A recent commit gated the core dumping task exit logic on current->flags > >> remaining consistent in terms of PF_{IO,USER}_WORKER at task exit time. > >> This exposed a problem with the io-wq handling of that, which explicitly > >> clears PF_IO_WORKER before calling do_exit(). > >> > >> The reasons for this manual clear of PF_IO_WORKER is historical, where > >> io-wq used to potentially trigger a sleep on exit. As the io-wq thread > >> is exiting, it should not participate any further accounting. But these > >> days we don't need to rely on current->flags anymore, so we can safely > >> remove the PF_IO_WORKER clearing. > >> > >> Reported-by: Zorro Lang > >> Reported-by: Dave Chinner > >> Reported-by: Linus Torvalds > >> Link: https://lore.kernel.org/all/ZIZSPyzReZkGBEFy@dread.disaster.area/ > >> Fixes: f9010dbdce91 ("fork, vhost: Use CLONE_THREAD to fix freezer/ps regression") > >> Signed-off-by: Jens Axboe > >> > >> --- > > > > Hi, > > > > This patch fix the issue I reported. The bug can be reproduced on v6.4-rc6, > > then test passed on v6.4-rc6 with this patch. > > > > But I found another KASAN bug [1] on aarch64 machine, by running generic/388. > > I hit that 3 times. And hit a panic [2] (once after that kasan bug) on a x86_64 > > with pmem device (mount with dax=never), by running geneirc/388 too. > > Can you try with this? I suspect the preempt dance isn't really > necessary, but I can't quite convince myself that it isn't. In any case, > I think this should fix it and this was exactly what I was worried about > but apparently not able to easily trigger or prove... Hi Jens, Sure, I'm going to submit several new testing jobs to test this patch. BTW, besides the kasan warning, I'm sure that mount with "dax=never" can crash the kernel as [2], I just reproduced that. So it's worse than a kasan bug output. Thanks, Zorro > > > diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c > index fe38eb0cbc82..878ec3feeba9 100644 > --- a/io_uring/io-wq.c > +++ b/io_uring/io-wq.c > @@ -220,7 +220,9 @@ static void io_worker_exit(struct io_worker *worker) > list_del_rcu(&worker->all_list); > raw_spin_unlock(&wq->lock); > io_wq_dec_running(worker); > - worker->flags = 0; > + preempt_disable(); > + current->worker_private = NULL; > + preempt_enable(); > > kfree_rcu(worker, rcu); > io_worker_ref_put(wq); > > -- > Jens Axboe >