From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pd0-x236.google.com ([2607:f8b0:400e:c02::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z2Dpu-0000P2-9u for linux-mtd@lists.infradead.org; Tue, 09 Jun 2015 07:20:39 +0000 Received: by pdbnf5 with SMTP id nf5so8787976pdb.2 for ; Tue, 09 Jun 2015 00:20:16 -0700 (PDT) Sender: Tejun Heo Date: Tue, 9 Jun 2015 16:20:03 +0900 From: Tejun Heo To: Petr Mladek Subject: Re: [RFC PATCH 07/18] kthread: Make iterant kthreads freezable by default Message-ID: <20150609072003.GY21465@mtj.duckdns.org> References: <1433516477-5153-1-git-send-email-pmladek@suse.cz> <1433516477-5153-8-git-send-email-pmladek@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433516477-5153-8-git-send-email-pmladek@suse.cz> Cc: linux-nfs@vger.kernel.org, Borislav Petkov , Thomas Gleixner , Jiri Kosina , Peter Zijlstra , Richard Weinberger , Trond Myklebust , Oleg Nesterov , Steven Rostedt , linux-kernel@vger.kernel.org, Michal Hocko , Chris Mason , Ingo Molnar , linux-mtd@lists.infradead.org, linux-api@vger.kernel.org, Linus Torvalds , live-patching@vger.kernel.org, Andrew Morton , "Paul E. McKenney" , David Woodhouse , Anna Schumaker List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Hello, Petr. On Fri, Jun 05, 2015 at 05:01:06PM +0200, Petr Mladek wrote: > Many kthreads already calls set_freezable() before they enter the main > cycle. One of the reasons for creating iterant kthreads is to create > a safe point for freezing and make even more kthreads properly > freezable. Therefore it would make sense to set all iterant > kthreads freezable by default. Actually, for most cases, making kthreads freezable is unnecessary and often indicative of something going wrong. This is a crude mechanism which goes along the line of "if all threads are stopped, the machine should be safe to be put into whatever state", which isn't true at all as there usually are a lot of stuff going on asynchronously especially when interacting with hardware. In most cases, we want to implement proper power management callbacks which plug new issuance of whatever work-unit the code is dealing with and drain in-flight ones. Whether the worker threads are frozen or not doesn't matter once that's implemented. It seems that people have been marking kthreads freezable w/o really thinking about it - some of them are subtly broken due to missing drainage of in-flight things while others simply don't need freezing for correctness. We do want to clean up freezer usage in the kernel but definitely do not want to make kthreads freezable by default especially given that the freezer essentially is one giant lockdep-less system-wide lock. > However some kthreads might be hard to make properly freezable. > For example, if they do non-interruptible sleeps. They would > need to explicitly clear PF_NOFREEZE flag in the init() call. > But it should be avoided whenever possible. So, big no here. Thanks. -- tejun