Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1139781ybk; Wed, 20 May 2020 22:58:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWO4ju/9DIlxro/nmPAq5i2YBgkjsKX991R7Hn833lzRxOymDa6IBM/gMlZk6rrm4h6PCm X-Received: by 2002:a05:6402:1cad:: with SMTP id cz13mr6631762edb.56.1590040709051; Wed, 20 May 2020 22:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590040709; cv=none; d=google.com; s=arc-20160816; b=gzuB1009EXPXiH/mU22fotASAt2iaKzMq+Dt++wgS3vd/1esnMu92lv8HE2hou+hzv FdKQb4OtjBDFYzQqNTzRjM5XtdK6XKsvz8cSWQVjMbT0nuioqJDKg1vo82nEQgHo0TJp RjVYdc35WzKCg9X87zxAB9FZpMt5EyMc2UoCAKo7pocjrfkJu1c341T9tW/v443sM7gk /3zUD4vHf4WllF2Tx6zKF/sDKCI7rPqS8ho6p0elPBupvI/vCvpr+3FTpAoC8PIigf+u YUq0JTot4DtbSDi69fS4ZBcv7Y08aZd9QFEa+YPWwXIQnjUnZSW/3giVPUdjb2RDqFlt yVyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6hNI+qmykjW2A0eJLw8o9iQgVhxJqZLVepDxKRVGuSs=; b=VvMV/BRAF6bMReFDSTOTJLAuuxXCliUT7+/boRxkTog9qbZAxsNxGN7x7q/341ZdpI 0VSk6Ba7Bdb145fPsjyW1j4jjBmPDRdx/mNfWRMMhNrH1Al97X9O1DX5e8wXYa+erZpR RVyh4t00AckanZWzWfQ/ffKYwuv12ZqjMyfXfe50HKhvEimWw4GY05JtMI1uVd1oCvXw 1qV71RWlfYE9gFbVqx0bkykjUFbP+H6cUF2PS2lh6Ig2gAon9CEkpHbK84LxfzGYIwTa 0ayv2pl7hZgI67jnefrBX3RmnHY+ZejfPvkkqfCBWxsYcMLBuF7u5crTuXRIVuljTv7c p4nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fBGmHKrx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x25si2724148edi.132.2020.05.20.22.58.05; Wed, 20 May 2020 22:58:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fBGmHKrx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbgEUF4m (ORCPT + 99 others); Thu, 21 May 2020 01:56:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:50982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726869AbgEUF4m (ORCPT ); Thu, 21 May 2020 01:56:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 075912070A; Thu, 21 May 2020 05:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590040601; bh=dHzsAWGKpeSFLlFK2Hm9joNV5l95MR4v9De3FclSRqw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fBGmHKrxU4k4q7b7Zo0KSHkmspdADbOXPY5PRmNREWBCwrAW8ubi4nDhPofW6S6WW MlwxwblV6g1NlHECX7SJBIgzeNLWC2jGw7hN6uBMtIffRKJqsLq+be18tgzOsa+fue wlrZ7oyd3ClDkYMp6K0nme9jfLdICUsfCVG0AwOM= Date: Thu, 21 May 2020 07:56:39 +0200 From: Greg Kroah-Hartman To: Pavan Kondeti Cc: linux-kernel@vger.kernel.org, Vinayak Menon , Ben Dooks , "Peter Zijlstra (Intel)" , Thomas Gleixner , "Steven Rostedt (VMware)" , Liang Chen Subject: Re: [PATCH] kthread: Use TASK_IDLE state for newly created kernel threads Message-ID: <20200521055639.GA2337399@kroah.com> References: <1589975710-9283-1-git-send-email-pkondeti@codeaurora.org> <20200520181858.GA343493@kroah.com> <20200521013544.GC31725@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200521013544.GC31725@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 21, 2020 at 07:05:44AM +0530, Pavan Kondeti wrote: > On Wed, May 20, 2020 at 08:18:58PM +0200, Greg Kroah-Hartman wrote: > > On Wed, May 20, 2020 at 05:25:09PM +0530, Pavankumar Kondeti wrote: > > > When kernel threads are created for later use, they will be in > > > TASK_UNINTERRUPTIBLE state until they are woken up. This results > > > in increased loadavg and false hung task reports. To fix this, > > > use TASK_IDLE state instead of TASK_UNINTERRUPTIBLE when > > > a kernel thread schedules out for the first time. > > > > > > Signed-off-by: Pavankumar Kondeti > > > --- > > > kernel/kthread.c | 6 +++--- > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > diff --git a/kernel/kthread.c b/kernel/kthread.c > > > index bfbfa48..b74ed8e 100644 > > > --- a/kernel/kthread.c > > > +++ b/kernel/kthread.c > > > @@ -250,7 +250,7 @@ static int kthread(void *_create) > > > current->vfork_done = &self->exited; > > > > > > /* OK, tell user we're spawned, wait for stop or wakeup */ > > > - __set_current_state(TASK_UNINTERRUPTIBLE); > > > + __set_current_state(TASK_IDLE); > > > create->result = current; > > > /* > > > * Thread is going to call schedule(), do not preempt it, > > > @@ -428,7 +428,7 @@ static void __kthread_bind(struct task_struct *p, unsigned int cpu, long state) > > > > > > void kthread_bind_mask(struct task_struct *p, const struct cpumask *mask) > > > { > > > - __kthread_bind_mask(p, mask, TASK_UNINTERRUPTIBLE); > > > + __kthread_bind_mask(p, mask, TASK_IDLE); > > > } > > > > > > /** > > > @@ -442,7 +442,7 @@ void kthread_bind_mask(struct task_struct *p, const struct cpumask *mask) > > > */ > > > void kthread_bind(struct task_struct *p, unsigned int cpu) > > > { > > > - __kthread_bind(p, cpu, TASK_UNINTERRUPTIBLE); > > > + __kthread_bind(p, cpu, TASK_IDLE); > > > } > > > EXPORT_SYMBOL(kthread_bind); > > > > It's as if people never read mailing lists: > > https://lore.kernel.org/r/DM6PR11MB3531D3B164357B2DC476102DDFC90@DM6PR11MB3531.namprd11.prod.outlook.com > > > > Given that this is an identical resend of the previous patch, why are > > you doing so, and what has changed since that original rejection? > > > I did not know that it is attempted before. Thanks for pointing to the > previous discussion. > > We have seen hung task reports from customers and it is due to a downstream > change which create bunch of kernel threads for later use. Do you have a pointer to that specific change? > From Peter's reply, I understood that one must wake up the kthread > after creation and put it in INTERRUPTIBLE sleep. I will pass on the > message. Just go fix that code, it sounds like it's in your tree already :) thanks, greg k-h