Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7306091imm; Thu, 28 Jun 2018 01:15:02 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKjsGCw6jxRI2qQOJs/5Wv/1nEbQUmUbMIG8WQm0PP1jMqlQNEgsXF1GFZLOhPRhefXA3kK X-Received: by 2002:a17:902:b589:: with SMTP id a9-v6mr9596982pls.140.1530173702788; Thu, 28 Jun 2018 01:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530173702; cv=none; d=google.com; s=arc-20160816; b=dlqz/YGR9wba+LWcs37ObBmcj60f/vBUEJgDv3Yr3kHhSzHTCwQxzqZ/vHYU+95txZ +Syv1W6YBPjmxJ/7FiMMe9sFDk7nAOrMhhKuX5qLpb/hFZM1bz/YCSdnzPXU6wMI9uZ7 3KlVMRsDiAOrP7K7C3iZKwkkBkasmZL/4nEivSkOk32CQxojlQQI6vd2NRT88fUiFpsv GxJ4boWoZ0QAOu6fkfAm47a+JmIV+SyT4M/T0OyXVhQ1+ScIrhAJ5azKQAWwWJ0bKFpO rSPvRcLTFp66olArNK5o7Vgk/rcwrZksxgiU4kGDv5FWHeEYij5SW1QKTb14HhRjIpoU oGHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Ldy2ZljZvM5XZTCIpofQ8BNK/F4aPMUlmj2WfWXQ7lY=; b=QQF00Hvzace2pH8bAebH+ejOJxJzFpcKDoWRmkSwQn19pdNEq4vfDWKXtFXV6fz5AK zvC8oWB8OTbqSircucI0rC17QbGuzWbzrpLEmEDdzvscDb0adyJcN04LDTgv1TeDZipx zQvfwycSKI5C9jLeMyXU51iEaJ4Y0MdOCzK5q1m6HUSurW99tdC9c1X/qJoGYdTyH8vW z0VU+GjDHqJjnNm4rUEFCJRM6MyMYMtVsWzIkRdsyWoxusLj3j843f5IW8Aku440SZLa wt7IJD/+vOWKpKiS7i+XNC38opPsGRaXuIwwVlwrhY8qm+XyyRq8p930QuHYdeEfu7+s s1Kw== ARC-Authentication-Results: i=1; mx.google.com; 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 i11-v6si5231482pgs.674.2018.06.28.01.14.45; Thu, 28 Jun 2018 01:15:02 -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; 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 S934616AbeF1H5v (ORCPT + 99 others); Thu, 28 Jun 2018 03:57:51 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:56187 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934364AbeF1H5t (ORCPT ); Thu, 28 Jun 2018 03:57:49 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fYRoJ-0001LX-It; Thu, 28 Jun 2018 09:57:47 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1fYRoG-0003dN-IS; Thu, 28 Jun 2018 09:57:44 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Gavin Schenk , kernel@pengutronix.de, Peter Zijlstra Subject: [PATCH] siox: don't create a thread without starting it Date: Thu, 28 Jun 2018 09:57:42 +0200 Message-Id: <20180628075742.8991-1-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180626073134.GW2458@hirez.programming.kicks-ass.net> References: <20180626073134.GW2458@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a siox master device is registered a kthread is created that is only started when triggered by userspace. So this thread might be in TASK_UNINTERRUPTIBLE state for long and trigger a warning [ 241.130465] INFO: task siox-0:626 blocked for more than 120 seconds. with the respective debug settings enabled. It might be right to put an unstarted thread to TASK_IDLE (in kernel/kthread.c:kthread()) instead, but independant of this discussion it is cleaner for siox_master_register() to start the thread immediately. The effect is that it enters its own waiting state and then stays in state TASK_IDLE which doesn't trigger the above warning. As siox_poll_thread() uses some variables of the device the initialisation of these is moved before thread creation. Acked-by: Peter Zijlstra (Intel) Signed-off-by: Uwe Kleine-König --- Hello, this is the same patch as before with an updated commit log. I added Peter's ack anyhow assuming my text isn't too bad to make him withdraw it. I think this issue isn't critical as the machine works fine otherwise, so applying it for 4.18-rc isn't necessary. (OTOH it's an SMP machine so the tests might not have noticed one blocked CPU, didn't test this.) Greg, you applied the initial patches creating drivers/siox. I assume you will continue to apply siox patches and tell if I should search a different path for these. Best regards Uwe drivers/siox/siox-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/siox/siox-core.c b/drivers/siox/siox-core.c index 16590dfaafa4..cef307c0399c 100644 --- a/drivers/siox/siox-core.c +++ b/drivers/siox/siox-core.c @@ -715,17 +715,17 @@ int siox_master_register(struct siox_master *smaster) dev_set_name(&smaster->dev, "siox-%d", smaster->busno); + mutex_init(&smaster->lock); + INIT_LIST_HEAD(&smaster->devices); + smaster->last_poll = jiffies; - smaster->poll_thread = kthread_create(siox_poll_thread, smaster, - "siox-%d", smaster->busno); + smaster->poll_thread = kthread_run(siox_poll_thread, smaster, + "siox-%d", smaster->busno); if (IS_ERR(smaster->poll_thread)) { smaster->active = 0; return PTR_ERR(smaster->poll_thread); } - mutex_init(&smaster->lock); - INIT_LIST_HEAD(&smaster->devices); - ret = device_add(&smaster->dev); if (ret) kthread_stop(smaster->poll_thread); -- 2.18.0