Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73DDE1103 for ; Mon, 15 Aug 2022 19:10:38 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id ha11so7721207pjb.2 for ; Mon, 15 Aug 2022 12:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc; bh=KUjRZPqE91jzSYN2iE0zIp+wxb3Fz8jBCptNiXCO28k=; b=nl5D74t6p6a2b7Jz2/xeLL85eNGxMaG3q869rymjnx1KUzapWeOISxWX+Bvmkl4271 z2s1HKqnfi00Leht9JdsPLQHpEJip7s09mwJrSD/co/QWkM4CP7FbOTt3cR8LqhGZjVX W39fR3JaIwng1yNdPmuW5bbBYDG/XxtfJdQhkl0eAfpCrKbB8ByBNKFQEgDQj4WCo46E Vq9u5iMZ2Z1FDRfICD6WBo7Z3wvd9rBk6M0Y1jDkBER6vmrodcDrxVS7C1gpbg576Ugx LpxTfqWuUSnDDOhQVS7U9pznNGBzDyQN40bxh5ZUTnzCn7V53y72UzUUiVUMmUasHbIw FkKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc; bh=KUjRZPqE91jzSYN2iE0zIp+wxb3Fz8jBCptNiXCO28k=; b=UK50jHlo6j1a1cZYR9jh81YFpmZSIl1oMmf/kRlvFxgEKva3RMbMyrm4qAeFWvYlUO HxnzSfpcJhjLbj70BVDL6e7wFTHr9ETzNCK+PHU16IQug03pXBR66yI6CJDyhMSIpCK7 fe9C8nLOVRDfNIsLYBIvpMbMvRsvsUCe9E+eJ+K07X/nrW+onEZ7xmNafgO/Do/MFcOM y+HTATatiq9oGX8vzxm5ftayi8eciLSd9/2dVaaA2Ns3YxBhrvvVYdAuBapUmu31wxI3 7xyQRLHd+RxMAhEKee99YqxpXOPY3mSuenflQA86CsJ7x9QDw/38X5k4WzR5PfeyYFn9 0YiA== X-Gm-Message-State: ACgBeo0XS/t/343yVjY7pPVywDvp6SIWucksdJ/fIsfWGw/sDWx0OOyI vmAdWop9dZmmVmJrffIsl28= X-Google-Smtp-Source: AA6agR4vn6iDlfADGbaSh46rlmxbHe822Dd3CTfESNqOHC4cvV2/XfoCT4HkKO1FddAI/ECHIaJ6qQ== X-Received: by 2002:a17:90a:20f:b0:1f8:cc20:1216 with SMTP id c15-20020a17090a020f00b001f8cc201216mr17823341pjc.225.1660590637729; Mon, 15 Aug 2022 12:10:37 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:3a69]) by smtp.gmail.com with ESMTPSA id b6-20020a1709027e0600b0016b90620910sm7361957plm.71.2022.08.15.12.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 12:10:36 -0700 (PDT) Sender: Tejun Heo Date: Mon, 15 Aug 2022 09:10:35 -1000 From: Tejun Heo To: Hector Martin Cc: Will Deacon , Peter Zijlstra , jirislaby@kernel.org, Marc Zyngier , Mark Rutland , Boqun Feng , Catalin Marinas , Oliver Neukum , Roman Pen , Asahi Linux , Linux ARM , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] workqueue: Fix memory ordering race in queue_work*() Message-ID: References: <20220815175810.17780-1-marcan@marcan.st> Precedence: bulk X-Mailing-List: asahi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220815175810.17780-1-marcan@marcan.st> On Tue, Aug 16, 2022 at 02:58:10AM +0900, Hector Martin wrote: > This has been broken since the dawn of time, and it was incompletely > fixed by 346c09f80459, which added the necessary barriers in the work > execution path but failed to account for the missing barrier in the > test_and_set_bit() failure case. Fix it by switching to > atomic_long_fetch_or(), which does have unconditional barrier semantics > regardless of whether the bit was already set or not (this is actually > just test_and_set_bit() minus the early exit path). ... Oh, tricky one and yeah you're absolutely right that it makes no sense to not guarantee barrier semantics when already pending. I didn't even know test_and_set_bit() wasn't a barrier when it failed. Thanks a lot for hunting down and fixing this. Applied to wq/for-6.0-fixes. Thanks. -- tejun