Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4648688rdh; Wed, 29 Nov 2023 07:08:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1/FYDKPB2MywVq57J1Vpyn9LWBWgh3zbY/ITeRVbyzWovd2UfyDnHsvUFOyUYTbKsDAKU X-Received: by 2002:a17:90b:3884:b0:285:d803:8945 with SMTP id mu4-20020a17090b388400b00285d8038945mr10167502pjb.46.1701270539006; Wed, 29 Nov 2023 07:08:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701270538; cv=none; d=google.com; s=arc-20160816; b=I/pFpek8r0MG4Vel2bup5LtUNUT2ec8goramn8CXbMdnR4DCv9U6+hY3iZGkK8yMoe PUW+bg1L7R3qaUMuhG7wMXdlMeekJlLarYKJu0P2pwlFOFHYrrig7zjQOkuPm6PZVVhS Bu/Cl7P4hf4NwgF/D/mo2Iq/WqAOyxcUbxuUoulV3PU/ldGV53a71qofsC77kdNfzjFp HklSsjZW5mnMFHIB/I1THlaLTbttjdfOOCqeJf1RZgqKZOezQOKNEkrQ0qPdlrPXQR+v PClqqEybi1uZ5WQ6UOQNyZM/+KSBoP688e8HcXP2lki344FNdTqUAPQeaNa+2uf/BUby oktQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=u7fdg9HsOCuKA61WgZU0Q3a150uw7ZsSmWZm77p0STY=; fh=pIvq8ubd1qLpmITja4IINl0Y8I44GyKtT/re3tlUWsI=; b=JoIv9LklLcGJwfrqecA2uJFQT3zRzLXPe4fqN7PmYjwYfKWgmtsO2HO7ajb77St7jS kzWnjwO5YHWZcW95Dek/UaW66R8Ar50nrSw7ksnh5BGxIk6eW8fi182EALfHUJSLWBLV GzP3I9JODncZyhMonoXA9+YMC5oP0L0NTLbIDmEaoCEfI5gMqswAu+ctpcIWWjchj8Qp 2rcy2+ptAjkrOm8m47Y805VG2uV87sJ+vUNmh2r0X9VL1JDXbF5pFenhiQu1o+eWIZQI dNj+s4HJUxdTxg/qt828OqkLx7RJFoJ1zZzQS18cyH2XgdklisNYzz90dYfzbuWE99yl BvGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3VS2nUxh; dkim=neutral (no key) header.i=@linutronix.de header.b=Fp0sg0f3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id on7-20020a17090b1d0700b00285b940b290si1554101pjb.190.2023.11.29.07.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:08:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3VS2nUxh; dkim=neutral (no key) header.i=@linutronix.de header.b=Fp0sg0f3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 5C71180AE501; Wed, 29 Nov 2023 07:08:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbjK2PIk (ORCPT + 99 others); Wed, 29 Nov 2023 10:08:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234844AbjK2Ozk (ORCPT ); Wed, 29 Nov 2023 09:55:40 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2045310DF; Wed, 29 Nov 2023 06:55:45 -0800 (PST) Date: Wed, 29 Nov 2023 14:55:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701269743; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u7fdg9HsOCuKA61WgZU0Q3a150uw7ZsSmWZm77p0STY=; b=3VS2nUxhbvX0YkzobvkabVg1G3ZXYUUY0jsOHrr1xGUq925nsPWUfxr+Pe+Uj1OA9ECpMP YK24kCIQjXaT3FOwFPZAcWo4rIrJKB+ScNMprL93VsHStttXFHe7YUtUAFvMt2VkGDXg0S hzvJitaCLYKZmqlm08WTE4ExFf0jnPbapHlxhBoslbH3bfn/7leN4hLCLxkkmovPyUVUGa XE1CFmGKsNk1np+UC4Zt7ktOv2uUf4Hm/pfMQGg/ZrrL+WC10uF/8N58NRSMLqsbH8WJzd VGI7eRuYv+6/HLQE4wnkFSbo/UQ9SyXJtZANpLFUpfof+q3T2jQEYf1NF4iNRA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701269743; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u7fdg9HsOCuKA61WgZU0Q3a150uw7ZsSmWZm77p0STY=; b=Fp0sg0f3pICor0IYtjwps1teD4BvPlL6tKD7Z/lZmK7hU5NZggyIUwRj6UC3jpDt4XhAZY TnGK6OytYQMq14DA== From: "tip-bot2 for Elliot Berman" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] freezer,sched: Do not restore saved_state of a thawed task Cc: Elliot Berman , "Peter Zijlstra (Intel)" , Abhijeet Dharmapurikar , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231120-freezer-state-multiple-thaws-v1-1-f2e1dd7ce5a2@quicinc.com> References: <20231120-freezer-state-multiple-thaws-v1-1-f2e1dd7ce5a2@quicinc.com> MIME-Version: 1.0 Message-ID: <170126974302.398.5668977195119638525.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 07:08:56 -0800 (PST) The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 23ab79e8e469e2605beec2e3ccb40d19c68dd2e0 Gitweb: https://git.kernel.org/tip/23ab79e8e469e2605beec2e3ccb40d19c68dd2e0 Author: Elliot Berman AuthorDate: Mon, 20 Nov 2023 09:36:31 -08:00 Committer: Peter Zijlstra CommitterDate: Wed, 29 Nov 2023 15:43:48 +01:00 freezer,sched: Do not restore saved_state of a thawed task It is possible for a task to be thawed multiple times when mixing the *legacy* cgroup freezer and system-wide freezer. To do this, freeze the cgroup, do system-wide freeze/thaw, then thaw the cgroup. When this happens, then a stale saved_state can be written to the task's state and cause task to hang indefinitely. Fix this by only trying to thaw tasks that are actually frozen. This change also has the marginal benefit avoiding unnecessary wake_up_state(p, TASK_FROZEN) if we know the task is already thawed. There is not possibility of time-of-compare/time-of-use race when we skip the wake_up_state because entering/exiting TASK_FROZEN is guarded by freezer_lock. Fixes: 8f0eed4a78a8 ("freezer,sched: Use saved_state to reduce some spurious wakeups") Signed-off-by: Elliot Berman Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Abhijeet Dharmapurikar Link: https://lore.kernel.org/r/20231120-freezer-state-multiple-thaws-v1-1-f2e1dd7ce5a2@quicinc.com --- kernel/freezer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/freezer.c b/kernel/freezer.c index c450fa8..759006a 100644 --- a/kernel/freezer.c +++ b/kernel/freezer.c @@ -201,7 +201,7 @@ void __thaw_task(struct task_struct *p) if (WARN_ON_ONCE(freezing(p))) goto unlock; - if (task_call_func(p, __restore_freezer_state, NULL)) + if (!frozen(p) || task_call_func(p, __restore_freezer_state, NULL)) goto unlock; wake_up_state(p, TASK_FROZEN);