Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp866611ybt; Tue, 7 Jul 2020 02:09:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7k2TFsfGDx1V1IGnUZvmmnIbcb4VSprGOqwqVHqiZ7KfUqmVh4b++1vBoYCIoETuOJVqr X-Received: by 2002:a50:fe0c:: with SMTP id f12mr53620850edt.360.1594112983010; Tue, 07 Jul 2020 02:09:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594112983; cv=none; d=google.com; s=arc-20160816; b=wSCzZWls/sLMH6kdOCOE6ADAslZPBb3DBpH+w5TRt/lTPOl6DxyXmg3LN8bLGYHhHE GRGHLTAm2LmHm4DTg6JaQCZO/7aB1cyiPQvFujSGLilrUav4EXJmRq+Ii4Cd0XTZssAG D0jUO2VSdHyGzXL7hP9HJuBOAz9c64FkcwmtexLLS7OmjJBUtMmQpLCD0CMZllFRKfUI CZUmVI+MCSgpyWFC0Xatl30bAWLvPY13biahOgM5OaFfvw2CHySjI5X0hcAFU2STk2Z+ vuTrqmg9kpnVdlK9wkJSAby/tXjpeDKCS0JBAhwtx3A9GJdF8zUkpkMlBnxFCNjO3Cgw kQ/Q== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=YTxEboBnqR8aSHcyAhlxWkJuuK7x04Bjb8Tp/CnrAJM=; b=ug5eZskyeUGBLWZymzAaG/YgF8Yk8Nk4/4bJQq0Yj96fI4WdP0xD8BCCIVnuHklfy6 BTliDY/7snwAsqH2Radih9AhqC6u1ax86mWgbmgXtNgj2iLS57Te8CzwUrQ1rQ+xTXiW bvCTF0VwnbqRj5Lk4LJFwmpOpFfNixG36ak8geuvg3bZWMDaONfx5H44jZ5QQJYiyXbO 0/pCIB+RlWsp1pnK7adomFJFlc8rL9YVGveKAm5R42yEn6e0aTjLSOhBm82xLJgwfWKQ 8sz4LHqBw+i4HAsAKbRnhLtMS3mbu3UVciXeQ2fBKFod7sUQkADc1CgMSbtl49cA06rD LFdg== ARC-Authentication-Results: i=1; mx.google.com; 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 p13si14411611edh.504.2020.07.07.02.09.18; Tue, 07 Jul 2020 02:09:43 -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; 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 S1726763AbgGGJGZ (ORCPT + 99 others); Tue, 7 Jul 2020 05:06:25 -0400 Received: from mx2.suse.de ([195.135.220.15]:60742 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbgGGJGY (ORCPT ); Tue, 7 Jul 2020 05:06:24 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 454C6AF6E; Tue, 7 Jul 2020 09:06:23 +0000 (UTC) Date: Tue, 7 Jul 2020 11:06:21 +0200 From: Petr Mladek To: qiang.zhang@windriver.com Cc: ben.dooks@codethink.co.uk, bfields@redhat.com, cl@rock-chips.com, peterz@infradead.org, tj@kernel.org, akpm@linux-foundation.org, naresh.kamboju@linaro.org, mm-commits@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] kthread: Work could not be queued when worker being destroyed Message-ID: <20200707090621.GC4087@alley> References: <20200706054647.5344-1-qiang.zhang@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200706054647.5344-1-qiang.zhang@windriver.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 2020-07-06 13:46:47, qiang.zhang@windriver.com wrote: > From: Zhang Qiang > > Before the work is put into the queue of the worker thread, > the state of the worker thread needs to be detected,because > the worker thread may be in the destruction state at this time. > > Signed-off-by: Zhang Qiang > Suggested-by: Petr Mladek > Reviewed-by: Petr Mladek This patch is completely different from the one that I suggested or acked. Please, never keep acks when doing major rework and people did not agree with it. For this patch: Nacked-by: Petr Mladek See below why. > --- > v1->v2: > Add warning information for condition "!worker->task". > v2->v3: > Modify submission information and add "Reviewed-by" tags. > v3->v4: > Fix spi controller register trigger Warning. > when a spi controller register, a "kthread_worker_fn" worker is created > through "kthread_run" instead of "kthread_create_worker" which in this > func the "worker->task" will be initialized. and then the "spi_start_queue" > func queue a work to worker queue, at this time, if the worker has not > begin to running, the "!worker->task" will be true, so a warning is triggered. > > kernel/kthread.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/kernel/kthread.c b/kernel/kthread.c > index bfbfa481be3a..825bd4dcdb95 100644 > --- a/kernel/kthread.c > +++ b/kernel/kthread.c > @@ -791,6 +791,11 @@ static inline bool queuing_blocked(struct kthread_worker *worker, > { > lockdep_assert_held(&worker->lock); > > + if (kthread_should_stop()) { This does not make much sense. kthread_should_stop() checks a flag set for the "current" process. It works only when called from inside the kthread worker thread. queuing_blocked() is called from kthread_queue_work() or kthread_queue_delayed_work(). These are typically called from another process. The only exception is when they get re-queued from inside the work. Best Regards, Petr > + WARN_ON(1); > + return true; > + } > + > return !list_empty(&work->node) || work->canceling; > } > > -- > 2.24.1