From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753740AbcEZLJG (ORCPT ); Thu, 26 May 2016 07:09:06 -0400 Received: from mga01.intel.com ([192.55.52.88]:64321 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753469AbcEZLJD (ORCPT ); Thu, 26 May 2016 07:09:03 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,367,1459839600"; d="scan'208";a="962761065" Subject: Re: [PATCH] mutex: Do not spin/queue before performing ww_mutex deadlock avoidance To: Chris Wilson , Peter Zijlstra , Ingo Molnar , intel-gfx@lists.freedesktop.org, =?UTF-8?Q?Christian_K=c3=b6nig?= , linux-kernel@vger.kernel.org References: <1464251487-23778-1-git-send-email-chris@chris-wilson.co.uk> <20160526104329.GS15901@nuc-i3427.alporthouse.com> From: Maarten Lankhorst Message-ID: <5c99773f-448d-6ca7-e28e-c262a82ee58a@linux.intel.com> Date: Thu, 26 May 2016 13:08:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <20160526104329.GS15901@nuc-i3427.alporthouse.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Op 26-05-16 om 12:43 schreef Chris Wilson: > On Thu, May 26, 2016 at 12:37:30PM +0200, Maarten Lankhorst wrote: >> The check should also not be for NULL, but for use_ww_ctx. >> This way the if check is optimized out for the ww_ctx path, where >> ww_ctx is always non-null. > The compiler can see use_ww_ctx == false => ww_ctx == NULL just as well > to do dead-code elimination, i.e. use_ww_ctx is superflouus and does not > reduce the code size. (gcc 4.7.2, 4.9.1, 5.3.1) That's true, but it cannot do the same when use_ww_ctx = true. In this case the function will always be called with ww_ctx != NULL, but the compiler can't see that, so it will keep the check even if it's always true. ~Maarten