From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753756AbcKIR1i (ORCPT ); Wed, 9 Nov 2016 12:27:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41664 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752699AbcKIR1h (ORCPT ); Wed, 9 Nov 2016 12:27:37 -0500 Date: Wed, 9 Nov 2016 18:27:44 +0100 From: Oleg Nesterov To: Thomas Gleixner Cc: Andy Lutomirski , Roman Pen , Andy Lutomirski , Peter Zijlstra , Ingo Molnar , Tejun Heo , "linux-kernel@vger.kernel.org" , Chunming Zhou , Alex Deucher Subject: Re: [PATCH 2/2] kthread: don't use to_live_kthread() in kthread_park() and kthread_unpark() Message-ID: <20161109172743.GB26446@redhat.com> References: <20161025154301.GA12015@redhat.com> <20161026141359.GA6893@redhat.com> <20161026155155.GA28832@redhat.com> <20161028161106.GA8933@redhat.com> <20161031200729.GA19430@redhat.com> <20161031200823.GC19430@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 09 Nov 2016 17:27:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/09, Thomas Gleixner wrote: > > > - watchdog_park_threads() and it does not look nice. The code is actually > > correct, get_online_cpus() ensures that kthread_park() can't race with > > itself (note that kthread_park() can't handle this race correctly), but > > imo it should not use kthread_park() directly. > > Should we provide an interface through the smpboot thread infrastructure for > this? IMHO yes, I'll write another email. > I can see why that gpu driver wants to use the park mechanism and I guess > there are other legitimate use cases as well. I prefer to implement a > park/unpark variant which is safe to use on arbitrary kthreads Yes, agreed. Again, I'll write another email. Perhaps we should even keep park/unpark exported and change them to avoid the races with exit/itself, I dunno. My real point was, imo the KTHREAD_IS_PER_CPU/__kthread_bind(kthread->cpu) logic in kthread_unpark() should be private to smpboot.c/cpu.c. I'll send another patch tomorrow. kthread_create_worker_on_cpu() ab-uses this logic too for no reason, but this is trivial. > Reviewed-by: Thomas Gleixner Thanks! Probably I should re-send these 2 short series to Ingo with your acks applied. Oleg.