Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752197AbaABTXL (ORCPT ); Thu, 2 Jan 2014 14:23:11 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:45518 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751136AbaABTXJ (ORCPT ); Thu, 2 Jan 2014 14:23:09 -0500 MIME-Version: 1.0 In-Reply-To: <1388675120-8017-5-git-send-email-davidlohr@hp.com> References: <1388675120-8017-1-git-send-email-davidlohr@hp.com> <1388675120-8017-5-git-send-email-davidlohr@hp.com> Date: Thu, 2 Jan 2014 11:23:05 -0800 X-Google-Sender-Auth: W8tDgTDaRxLBVnkyB_EuQNgsT88 Message-ID: Subject: Re: [PATCH v5 4/4] futex: Avoid taking hb lock if nothing to wakeup From: Linus Torvalds To: Davidlohr Bueso Cc: Linux Kernel Mailing List , Ingo Molnar , Darren Hart , Peter Zijlstra , Thomas Gleixner , Paul McKenney , Mike Galbraith , Jeff Mahoney , Jason Low , Waiman Long , Tom Vaden , "Norton, Scott J" , "Chandramouleeswaran, Aswin" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1183 Lines: 27 On Thu, Jan 2, 2014 at 7:05 AM, Davidlohr Bueso wrote: > > In futex_wake() there is clearly no point in taking the hb->lock if we know > beforehand that there are no tasks to be woken. Btw, I think we could optimize this a bit further for the wakeup case. wake_futex() does a get_task_struct(p)/put_task_struct(p) around its actual waking logic, and I don't think that's necessary. The task structures are RCU-delayed, and the task cannot go away until the "q->lock_ptr = NULL" afaik, so you could replace that atomic inc/dec with just a RCU read region. Maybe it's not a big deal ("wake_up_state()" ends up getting the task struct pi_lock anyway, so it's not like we can avoid toucing the task structure), but I'm getting the feeling that we're doing a lot of unnecessary work here. This only triggers for the actual case of having a task to wake up, though, so not your particular test load. 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/