Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752376AbZKPSTi (ORCPT ); Mon, 16 Nov 2009 13:19:38 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751893AbZKPSTi (ORCPT ); Mon, 16 Nov 2009 13:19:38 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:47415 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751825AbZKPSTh (ORCPT ); Mon, 16 Nov 2009 13:19:37 -0500 Date: Mon, 16 Nov 2009 10:18:59 -0800 (PST) From: Linus Torvalds X-X-Sender: torvalds@localhost.localdomain To: Ingo Molnar cc: Stijn Devriendt , Mike Galbraith , Peter Zijlstra , Andrea Arcangeli , Thomas Gleixner , Andrew Morton , peterz@infradead.org, linux-kernel@vger.kernel.org Subject: Re: [RFC] observe and act upon workload parallelism: PERF_TYPE_PARALLELISM (Was: [RFC][PATCH] sched_wait_block: wait for blocked threads) In-Reply-To: Message-ID: References: <1258311859-6189-1-git-send-email-HIGHGuY@gmail.com> <20091116083521.GC20672@elte.hu> User-Agent: Alpine 2.01 (LFD 1184 2008-12-16) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2234 Lines: 44 On Mon, 16 Nov 2009, Linus Torvalds wrote: > > Think of it like a classic user-level threading package, where one process > implements multiple threads entirely in user space, and switches between > them. Except we'd do the exact reverse: create multiple threads in the > kernel, but only run _one_ of them at a time. So as far as the scheduler > is concerned, it acts as just a single thread - except it's a single > thread that has multiple instances associated with it. Side note: before anybody asks why not do threads in user space to begin with, it's simple: IO, exceptions, and timers. All need kernel support. User-level threading works very well, and is usually efficient as hell. It's not that long since people constantly claimed that thread libraries in user space were much better, and tried to use complex NxM models to do them, exactly because user threads are so great. But almost nobody does user-level threading now, except for specific languages that are built around threading. Why? It's not because they don't work, it's because they have a few very annoying problems that make them not work at all for enough situations that it gets very painful. And it's usually about IO and system calls, but sometimes it's about page faults, and sometimes it's about the pain of multiplexing that annoying timer signal and all the crap that involves. So I'm suggesting that maybe we could look at doing kernel threads that do what user-level threading does. It sounds idiotic, and maybe it is - after all, traditionally one of the reasons for user-level threads is that you can avoid all the kernel overheads. But if we can make some really low-overhead "thread within a thread" model, maybe we could have close to the best of both worlds. Some people really want threads for multi-CPU workloads and spreading things out. That's what we have now. But other loads want threads for entirely different reasons, like just hiding IO latencies. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/