Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2345964rdb; Mon, 5 Feb 2024 03:57:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqjRjBIuyxpPPqvfNykich8IC1Zd4G1ejBZztDq3wqNp0s+ZBF5e1hvn4nIN50sx/8ew1I X-Received: by 2002:a17:906:3097:b0:a37:4f7c:c9c1 with SMTP id 23-20020a170906309700b00a374f7cc9c1mr3682593ejv.56.1707134275916; Mon, 05 Feb 2024 03:57:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707134275; cv=pass; d=google.com; s=arc-20160816; b=YgNJpnQ9zYuOIH3+dctb8TQ84alHfUfRWsiSqLBPqhUFOMlBTd/yy6qibloH4X35Bp u+SU+3hg4uG9H0V0vi8yY8efi9Xp4FjtZ4/B9/LBV0q9I+02ctUtTn+m/eRk9wnjUxl8 Y/tNSyBaV8BHbytpyvxOXU32pX1gEu8zjkyLjw9XYt0wRNXdceoXD5qt78/FNZYDm5Ey PcNGBIjcSrvaV0EGdptQyNIPX3iMgBQFuw44ge+SONEKms+Q/zXJs+KI7+E3Mm8hG858 RhSgjd+7O7nylrdkcaE/xFQtj1jVNxQeE2xGhi38g6nLir+6ratcUVEl25e7/0oRePqT uHcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:in-reply-to:date:subject:cc:to:from:user-agent :references:dkim-signature; bh=z4R0rwDo9vY3aJTCDcs4YY0bxD1wBPoqccCPAZB+f6Y=; fh=T1Ue+Rh5aXlVha7iAikuZZEQbmriZh+9C0+oiceKUzY=; b=Lw3AkZmsuZXGnPzoZrEoUPYloxd3cRXD/SvREHgbT1+Wu4cVUQBgr+Z1Ae8Jfz+wGi rNC/GcQ0TLYM8fuwLGJfgEPjw/T49EVzT3F6x/SacN/33aumL51LN4RXEBipRBH1KJMW Rz1yYsFffzEP2e3CLx/dDMF4gMVJs+0ObnCTmQj9Y0duXWCIvSOaW4NJbSYxewQtmRr5 I5e5YC2lditdGAcpGhrP21ZyqtjiMuZ5eR79IVjSOIZvqur1mKqKjqkmhCtZekvVHKyT YhaU4hANf9XnqoEih8zWON4hkMrXG5VGFmv4Jjm88rmhSiccoZYUWUOKxXFQt2QyHP23 t21g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qSfpQl+V; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-52529-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVMY/nn+T5BWKhyqI6BQGM2WQ76s2f/76D/31kQAus634xi/v92YYni6ZA85zROMa1TQO3wsJEt6N8SthPLm9Q+VLVQ75A1BWEhKXi4hw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id p27-20020a17090628db00b00a3793cf942dsi1613818ejd.424.2024.02.05.03.57.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 03:57:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52529-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qSfpQl+V; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-52529-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A8BB71F21FA5 for ; Mon, 5 Feb 2024 11:57:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA81C199A7; Mon, 5 Feb 2024 11:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qSfpQl+V" 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 1E35B18EB9; Mon, 5 Feb 2024 11:57:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707134266; cv=none; b=XmoiF/B7phj5A6M6NM0U0v/2Sbf8NKkz6wSxbGI2JtF8hjKDHs/fqX1t0VEmF+GZr8ruUJgb0kdiYN7Hyj/lRl94ydlMD8xkioOPIsoA+0C/mwvpFpFyai3B4Q8pAJP6qrYB9k+nukOmzkXpGqrbB/SCEGP2fyHp+MUB1Wlm3wg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707134266; c=relaxed/simple; bh=GVqGwsZ3oAzNGM6DmqmUlOaiQdppIpSmPlxDVDHqgzY=; h=References:From:To:Cc:Subject:Date:In-reply-to:Message-ID: MIME-Version:Content-Type; b=dmA3juokE2H4NXgaMdosk241TtcDPZZNpsQ6uotZeYFzspXOnzfvWqiGOgBs1SCKXo3uoEopF3M1FPGayZPXsgG9MvQtaN1ebyuqNevYfV7FNSN891QOOPneBp0SSCqUIDqRZoMkVVjCGk5BY41+4AyLnlDUdJOaAgiFJ+btYyY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qSfpQl+V; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0669CC433C7; Mon, 5 Feb 2024 11:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707134265; bh=GVqGwsZ3oAzNGM6DmqmUlOaiQdppIpSmPlxDVDHqgzY=; h=References:From:To:Cc:Subject:Date:In-reply-to:From; b=qSfpQl+VMN9Sym0+Rh/3jeZVEaw7L1pOoKN5Deqz6QmNqS0tdC8OeFEu8f+EQpUpB lL/5KZSiyL8qZkLaQqWLYs6WSosqRS894q2NXDXit7zPo9VK5DorSXDFJ12rSTD1Nc hm7lio8CA9KZPNWgJYDSWY/jHmNGQHL+XvkLNuhQ6aBk1eVitcR59NTplECGqn0Nma WlJ7wQcUt76nNKRLY8RMzCEVQOKG9olavtCaGIBcCP8fpM05nQQt/U2r4rX/kIJqHb 3UsgLpr9xnTDplkyigfQ8kPz6Sti78R9Hdt7QozPbypHNLDW8bVdhi0DuE8bJeH2dz XDey3pWDv0dmQ== References: <87o7cxeehy.fsf@debian-BULLSEYE-live-builder-AMD64> User-agent: mu4e 1.10.8; emacs 27.1 From: Chandan Babu R To: Tejun Heo Cc: jiangshanlai@gmail.com, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: Re: [PATCH wq/for-6.9] workqueue: Fix pwq->nr_in_flight corruption in try_to_grab_pending() Date: Mon, 05 Feb 2024 17:25:38 +0530 In-reply-to: Message-ID: <877cjji0ne.fsf@debian-BULLSEYE-live-builder-AMD64> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Sun, Feb 04, 2024 at 11:14:21 AM -1000, Tejun Heo wrote: > dd6c3c544126 ("workqueue: Move pwq_dec_nr_in_flight() to the end of work > item handling") relocated pwq_dec_nr_in_flight() after > set_work_pool_and_keep_pending(). However, the latter destroys information > contained in work->data that's needed by pwq_dec_nr_in_flight() including > the flush color. With flush color destroyed, flush_workqueue() can stall > easily when mixed with cancel_work*() usages. > > This is easily triggered by running xfstests generic/001 test on xfs: > > INFO: task umount:6305 blocked for more than 122 seconds. > ... > task:umount state:D stack:13008 pid:6305 tgid:6305 ppid:6301 flags:0x00004000 > Call Trace: > > __schedule+0x2f6/0xa20 > schedule+0x36/0xb0 > schedule_timeout+0x20b/0x280 > wait_for_completion+0x8a/0x140 > __flush_workqueue+0x11a/0x3b0 > xfs_inodegc_flush+0x24/0xf0 > xfs_unmountfs+0x14/0x180 > xfs_fs_put_super+0x3d/0x90 > generic_shutdown_super+0x7c/0x160 > kill_block_super+0x1b/0x40 > xfs_kill_sb+0x12/0x30 > deactivate_locked_super+0x35/0x90 > deactivate_super+0x42/0x50 > cleanup_mnt+0x109/0x170 > __cleanup_mnt+0x12/0x20 > task_work_run+0x60/0x90 > syscall_exit_to_user_mode+0x146/0x150 > do_syscall_64+0x5d/0x110 > entry_SYSCALL_64_after_hwframe+0x6c/0x74 > > Fix it by stashing work_data before calling set_work_pool_and_keep_pending() > and using the stashed value for pwq_dec_nr_in_flight(). > > Signed-off-by: Tejun Heo > Reported-by: Chandan Babu R > Link: http://lkml.kernel.org/r/87o7cxeehy.fsf@debian-BULLSEYE-live-builder-AMD64 > Fixes: dd6c3c544126 ("workqueue: Move pwq_dec_nr_in_flight() to the end of work item handling") > --- > Hello, Chandan. > > Thanks a lot for the report. I could reproduce the problem and verified that > this patch fixes the issue. I'm applying this to wq/for-6.9 but would really > appreciate if you could confirm the fix. fstests executed without any regressions on a next-20240202 kernel with this patch applied. -- Chandan