From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755328AbcFQO73 (ORCPT ); Fri, 17 Jun 2016 10:59:29 -0400 Received: from mga01.intel.com ([192.55.52.88]:37800 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751103AbcFQO71 (ORCPT ); Fri, 17 Jun 2016 10:59:27 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,484,1459839600"; d="scan'208";a="830283527" Subject: Re: initialize a mutex into locked state? To: Oleg Drokin , Jeff Layton References: <55315ADD-4AE1-4EA4-8291-1B07F659BD99@linuxhacker.ru> <20160617082559.GD30935@twins.programming.kicks-ass.net> <38111D58-C42F-4ED3-BC31-04884795BE38@linuxhacker.ru> <20160617141912.GS30154@twins.programming.kicks-ass.net> <20160617143200.GU30154@twins.programming.kicks-ass.net> <17E58758-CA23-420D-89B4-50E71F8A6428@linuxhacker.ru> <1466174540.3596.16.camel@poochiereds.net> Cc: Peter Zijlstra , Mailing List , mingo@redhat.com, "J . Bruce Fields" From: Arjan van de Ven Message-ID: Date: Fri, 17 Jun 2016 07:59:25 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/17/2016 7:54 AM, Oleg Drokin wrote: > > Yes, we can add all sorts of checks that have various impacts on code readability, > we can also move code around that also have code readability and CPU impact. > > But in my discussion with Arjan he said this is a new use case that was not met before > and suggested to mail it to the list. I'm all in favor of having "end code" be as clear as possible wrt intent. (and I will admit this is an curious use case, but not an insane silly one) one other option is to make a wrapper mutex_init_locked( ) { mutex_init() mutex_trylock() } that way the wrapper can be an inline in a header, but doesn't need to touch a wide berth of stuff... while keeping the end code clear wrt intent