Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2705968iog; Mon, 27 Jun 2022 00:46:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vy11tLuzWdV2oAMZGRxrcfikB+FqgWR/eLFx2MIs1fMGiRuyXhUFHN0h2vTrpkX54BEoct X-Received: by 2002:a17:90a:8d85:b0:1ee:dd88:f3f2 with SMTP id d5-20020a17090a8d8500b001eedd88f3f2mr3892892pjo.216.1656315966217; Mon, 27 Jun 2022 00:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656315966; cv=none; d=google.com; s=arc-20160816; b=OuijHckTec9JABhlKf0V4usimUttf+tutlJNXUlgCDbJXURBIKws6rdQYbfXsJwkif 7TTGM3nupj+hFOcWK8UJ85lOB3BW8PSWUDkNbrLU2ZVXWQOJMQ9+noi8gMXUWokWG0n2 WHI9NRC1Swvonarfuwxj0W1bHuV+rb+sTqyP5lNLHig3Ye6wrdinjUw7QyDAV0VFc7od 8ZngxrllDWmMvFP05NERG5gonyo+2GK2G7gMUIsIFPaSphLAYZA5T5ce0pFLaCRj7kfI 6yGMb24s+L9+sXMRY6VTktEXlVsuvBewiY93bQsxkiAvX8RpBUFlhdjLmVZm5572Xq/R KXMg== 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=K8NxPx1jbqhLbCIeQl9QlBhlrp1zweaLyeE/ESUidak=; b=JwSZx2BAYz7sYi0wOtD/nshla7hDdKnk86zSH/adrpaAIcsaf3JDBLPmUqhl6ClM7T xDUJqToBtawQHoMK35vbbxtyI+/apFd18R4uDE5QnSjF7tyMvSEX12ZrWLnMm7JLve4z YHcGqJAUoXSOZnP/9h/31BDXvxYWoMmhhQVZZZqHFpU/kx9QW6kO1JA/j4tb7nQeYnmb BFVNg2cUGMgLz7pqWLVKnFZcsg5/jzML2P5BqD+N6GyAfCcg6/fHTAXa8Hk2dqwBqrcr n/BnGvQ38VyoLHmsEQseMx1bDZS34ZQxplz+Ez9WUdzM3MMKFv0ZlANoCYrgbqlpL4zb JvYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uzdIbozA; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mq6-20020a17090b380600b001ca8baaa48fsi19653188pjb.120.2022.06.27.00.45.51; Mon, 27 Jun 2022 00:46:06 -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=@infradead.org header.s=casper.20170209 header.b=uzdIbozA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232712AbiF0HUJ (ORCPT + 99 others); Mon, 27 Jun 2022 03:20:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232362AbiF0HUH (ORCPT ); Mon, 27 Jun 2022 03:20:07 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B5C25FE5 for ; Mon, 27 Jun 2022 00:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=K8NxPx1jbqhLbCIeQl9QlBhlrp1zweaLyeE/ESUidak=; b=uzdIbozA0ktf0YFaK/anRamjlD SlZXIoHYFJZN0gnZbAz6jAVW1z1g1qF04O0Px871KkmaSR/StWRtGgMTBHezIGDVRBaAqb4O+Dudb Gm4jbtfX+l+4nyDeLLxZDHpVZYEePOPPDI3tQN6m4wID+1uYLXVcysTKyyQlk3mBEl+OOcBRgJ3We mVIBTaVKJZ6e9fCqS5qadsW0sDfK+Tr4hYpQMiBNC8aL5ALK6had5us6H8wIArsrIhT28w5xKW/+t yfu+ZaahSXD7ZayXAKWzvp+g38q884rtGCX+Ya/LWEEQYRQrU34+kdP/c8h+wduLuYF2+fgpqZjOO fR2fDU1g==; Received: from dhcp-077-249-017-003.chello.nl ([77.249.17.3] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5j28-00B8to-4F; Mon, 27 Jun 2022 07:19:44 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8FA2930040C; Mon, 27 Jun 2022 09:11:11 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E759D29BD6E00; Mon, 27 Jun 2022 09:11:10 +0200 (CEST) Date: Mon, 27 Jun 2022 09:11:10 +0200 From: Peter Zijlstra To: Wedson Almeida Filho Cc: "Eric W. Biederman" , Linus Torvalds , Christian Brauner , Tejun Heo , Petr Mladek , Lai Jiangshan , Michal Hocko , Linux Kernel Mailing List , Thomas Gleixner , Ingo Molnar , Andrew Morton , Oleg Nesterov Subject: Re: re. Spurious wakeup on a newly created kthread Message-ID: References: <874k0863x8.fsf@email.froward.int.ebiederm.org> <87pmiw1fy6.fsf@email.froward.int.ebiederm.org> <87y1xkwa28.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Mon, Jun 27, 2022 at 12:01:04AM +0000, Wedson Almeida Filho wrote: > On Sat, Jun 24, 2022 at 07:19:27PM -0500, Eric W. Biederman wrote: > > > > Further it is necessary for Peter Zijlstra's rewrite of the kernel > > freezer. As anything that isn't a special stop state (which > > TASK_UNINTERRUPTIBLE is not) will receive a spurious wake up on when > > thawed out. > > Do you know if the current (i.e., prior to the rewrite) kernel freezer > also sends spurious wakeups when thawing tasks? Current freezer can thaw at random points in time, even before SMP bringup if you're unlucky. And yes, I think it can induce 'spurious' wakeups as well. But really; like Linus already said upsteam, every wait loop *MUST* already be able to deal with spurious wakeups. This is why pretty much every wait primitive we have looks like: for (;;) { set_current_state(state); if (cond) break; schedule(); } __set_current_state(RUNNING); Which is immune to random wake-ups since it need @cond to make progress. *NEVER* rely on just the wakeup itself for progress, that's buggy as heck in lots of ways. There are a few exceptions, but they all require special wait states and much carefulness.