Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3856056imm; Mon, 25 Jun 2018 05:52:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIIG8OkV2hvmqIDvsERQggVen+cEqJcKxoAq0prchecTTxxN1MNdFTVJ/oFpPRaO3iiyLho X-Received: by 2002:a17:902:e093:: with SMTP id cb19-v6mr12458665plb.189.1529931127158; Mon, 25 Jun 2018 05:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529931127; cv=none; d=google.com; s=arc-20160816; b=jiT35zEhrxg1/40bmy5CbQ8cUy4b3d2iuTD3rw/d4I2NSTw9B7s7zIrtHUBZyQbvKI 4HMC/QPpgMgREAJAiCKmpTYs0v5loLmsYRi5yxWHLCoLWRohvHpSyT6t6wvcduY3FX97 f0ypwjnBlqQyfm/bJ59EYemqMkD7kv1MS6lQYRsxEdqcW04+HXpJ1jKe5ouwVXM/yQOG jy0qd29M9J+q6Bnoqn+xhx+TyYkvbZrX4JN79RbcUPldHypGaFoTDy/u8IE3QolY+z6t NhMaZOHUUkFjEAuLRlgEZE+tcdapr0GEP3lGDlgCts5RUFHkuvst6dKbHOGd3BsQZ89a 3Bvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=dzU7Pfw81TZ224pAbrf3aoni5cUEEoExpOyR9ny06vs=; b=ZPjcOGKomaJ2ZbvVm6nq4pM1I3P4psdS1NjFAL6Xe++S1hFAGrqdr8oBEx5W0m9Abj lmmfT7kSmjqZMrBGrPp2iWGBMC4Wx1JVKBZhYcjVGGEb7rsv1Qo3cP9i+yehAb0BBJZk n8Clh/k7UEy+CFyXZVHgsDQNQpiv4AJAOs6hsX1aOvgqiaYG9oNdoVQzLIv9e9RNZmz/ 4ePooJomdCfWImJnf7oV6sCyvsuvFTj8hJSHpIE8ZpCG3YL3EO31r5q+CFm01aYZt7Nd ygWljDyIavEBY+YCYHslGiuhva2rfIJhuZWwu7ShvruVDdCpAgLGm5G84OS0tX5Pu8fi a8fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ECd5NlR3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1-v6si13394285plq.280.2018.06.25.05.51.52; Mon, 25 Jun 2018 05:52:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ECd5NlR3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755287AbeFYMvN (ORCPT + 99 others); Mon, 25 Jun 2018 08:51:13 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:36788 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752124AbeFYMvM (ORCPT ); Mon, 25 Jun 2018 08:51:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dzU7Pfw81TZ224pAbrf3aoni5cUEEoExpOyR9ny06vs=; b=ECd5NlR34kYzwAR/jpygf932Bh L8PHghAxcijEsMc8jvGQb2dfBVl8VsOuWod98695yrFFA6By6psC36DUQGBrfOFS1iEUZS+xYVfpV K9jzHGr51LJfdtHAP6bp4xS8T3fTjgwy49u2j7yqb1DQn2ss27qZQP4SC0hphNqD6liJAHHvInWo0 +QUIP7Pe1fcUgJtlsWQ99doW2/O4AMLQT7VGAgE2VUhBPtoGNdjPEsKfHSff3y4yhXa9AlZ22O9ro Wj5L6kCBLiwEgsm69Zp3zd3jzdpBDRqbhoNMNFXbXEU+lZdJWS5ITgNjqgvwOBFRh5A6fOJXsj5tp PoduYILw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXQxX-00034D-SV; Mon, 25 Jun 2018 12:51:08 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B113F2029FA0A; Mon, 25 Jun 2018 14:51:05 +0200 (CEST) Date: Mon, 25 Jun 2018 14:51:05 +0200 From: Peter Zijlstra To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: linux-kernel@vger.kernel.org, Oleg Nesterov , "Eric W . Biederman" , "Rafael J . Wysocki" , Andrew Morton , Gavin Schenk , kernel@pengutronix.de Subject: Re: [PATCH] RFC: siox: don't create a thread without starting it Message-ID: <20180625125105.GZ2494@hirez.programming.kicks-ass.net> References: <20180625102056.28468-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180625102056.28468-1-u.kleine-koenig@pengutronix.de> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 25, 2018 at 12:20:56PM +0200, Uwe Kleine-K?nig wrote: > when I just boot without any other siox-related action. So the kthread (created > in drivers/siox/siox-core.c:siox_master_register()) is never started. > > While you could argue that there is little reason to not start the > thread there also is little reason to actually do it. Well, you really _should_ wake up the thread. That first wakeup really is part of the whole 'create/setup' kthread pattern. > peterz in #kernelnewbies said "[...] kernel/kthread.c:kthread() should > really be using __set_current_state(TASK_IDLE), I suppose". This however > seems to interfere with problems fixed in a076e4bca2fd ("freezer: fix > kthread_create vs freezer theoretical race"). I don't think so, that patch has an issue with INTERRUPTIBLE, but IDLE very much doesn't allow signals like INTERRUPTIBLE does. > So I wonder where the real problem is and how it can be fixed. Without the first wakeup, the kthread will not run the provided function and we can therefore argue the creation is incomplete. I really feel you should just wake the thing up to land in your own wait-condition-loop. That said, irrespective of the whole UNINTERRUPTIBLE/IDLE thing, I find this construct fairly fragile. We rely on not getting any spurious wakeups without a 'special' state. The only reason this doesn't normally happen is because it's a new task, but since it is already hashed, it might well be possible to trick someone into sending a wakeup.