Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757808AbcJQXVj (ORCPT ); Mon, 17 Oct 2016 19:21:39 -0400 Received: from mail-cys01nam02on0133.outbound.protection.outlook.com ([104.47.37.133]:19872 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754925AbcJQXVi (ORCPT ); Mon, 17 Oct 2016 19:21:38 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=waiman.long@hpe.com; Message-ID: <58055CF8.2060806@hpe.com> Date: Mon, 17 Oct 2016 19:21:28 -0400 From: Waiman Long User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130109 Thunderbird/10.0.12 MIME-Version: 1.0 To: Peter Zijlstra CC: Linus Torvalds , Jason Low , Ding Tianhong , Thomas Gleixner , Will Deacon , Ingo Molnar , Imre Deak , Linux Kernel Mailing List , Davidlohr Bueso , Tim Chen , Terry Rudd , "Paul E. McKenney" , Jason Low , Chris Wilson , Daniel Vetter Subject: Re: [PATCH -v4 8/8] locking/mutex: Enable optimistic spinning of woken waiter References: <20161007145243.361481786@infradead.org> <20161007150211.416377482@infradead.org> In-Reply-To: <20161007150211.416377482@infradead.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [72.71.243.218] X-ClientProxiedBy: BY1PR13CA0035.namprd13.prod.outlook.com (10.162.107.173) To DF4PR84MB0313.NAMPRD84.PROD.OUTLOOK.COM (10.162.193.27) X-MS-Office365-Filtering-Correlation-Id: 76d9cdbe-5fc5-47ad-961d-08d3f6e456fd X-Microsoft-Exchange-Diagnostics: 1;DF4PR84MB0313;2:fnpNKsn3iadLFOiHS8V5l+4KjDti/6l9S+6SKKtd5HhVxNmCADiRobq9oUklzzHLwlhyLMst5cM1Zq7wGXLD2HGVSFvyKW/l9uTsDHX3q+Eh43ZAsQPB07eNKdRvVzvgeXamJi+R+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X-Microsoft-Exchange-Diagnostics: 1;DF4PR84MB0313;31:hWnCTmxOGFuK7/seek0peeMFBva3TFrgAaqEilz2OpMJmWu06Pbomds9lLYzSkaaslxzONcZ7zA9F6KbrkV8KKc18/9c3ZAxWbcNhrBu92zoaATNYWnumP5aFbPympHGoyVZu9eQcnr6eT9yP0v3VSm2pMnkvDPguqsX3Jz9C40z1F4yJJKNPyBpRbutBYprHQjfK+rhiN3o9cxeWEsI75nyrWPfReE3CuNnsxeGI3jUyN6UBp4gL2KCV6GJpE1F;20:s/29ovmh4ORKAMaahoKPOFdghQ24B6IeiSqTG0H3n2j9NhFBGoB8B43gB+EbLwQYWQ3xjX63kiqnHd5YaD8tq8jBpNK45w6ww4CgrcIvxCGUVh9hVk78Z9kwYaI/zTLm2AmkrIIMnVmE1nkUdSMJNxHvTOmF+Rp2HzpQcDjWCNRjkU5KXh8+qyT0WepbMVzb/92AlNtVOLWosB232fiOTQP4EOACjZbuzCpyu3g9fXQ8OogwMhSdf6bVKczQBN5mV0++BsW+GmaHHMKg84o7a8JQVF2rSTj5+oSwOY2u9fGTfzbxtdeH0jYXPAxBwOSL5abN9FkrSvWV9jBPpUaYmEip+VpzRNUWMiabG4say8AQXrHRokq7nm7hyWdgpO7JqNkppDDZ5ozi00+gYKWB/VW1SEaXVD3A55rMCAOptVcoUYJL09Wxn88ca+5JJbjysE4j0XYGxJyeE4SPEcCRIur5qa5ZhmxWl1hoN5VBrL4Zy+wq7PuGgJajg6BpJXNZ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026);SRVR:DF4PR84MB0313;BCL:0;PCL:0;RULEID:;SRVR:DF4PR84MB0313; X-Microsoft-Exchange-Diagnostics: 1;DF4PR84MB0313;4:S1FZvfdXad5S/ryfGHjhPuZ8R2LZCu0bBBKcMPw9RB58YbTjEjhs4asNxi/ohjORfGuzqyYo3vQWiFy3Fe+ThANkZEkyVSiPoR0AGk5at39NOosjoPPDBk0kimkNgMBQJC4yOaUQPSmHGqyfJMhJjcN1W3/LJC+obr5z+SsSCKg8emIP8BESt3gm6FefRwa/gOf0NwiNEH5np+pGsY2dOM+vNqZJexUpC9gPJUxWlYBLK0zpeCT59a5LEG6a0KvEX/WtLtYMJVvwrfWlBesJNYSC44id7nUTLXsZgVwqfTwaFN5p+vbNBoyZjd+qFNfSQzCs+4bucS+OfGIDDA6ecLywA4P+whDKCSVf3k8DFXywOGbI0Qndx6WYUxQjZjaSQjVWVgX378Gttdigo9B4G/449AjRXPrFUIJ1An4Or6g= X-Forefront-PRVS: 0098BA6C6C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6049001)(6009001)(7916002)(199003)(57704003)(189002)(377454003)(24454002)(97736004)(2906002)(23676002)(4001350100001)(77096005)(4326007)(65956001)(66066001)(65806001)(80316001)(47776003)(64126003)(36756003)(50466002)(110136003)(83506001)(68736007)(5660300001)(86362001)(8676002)(81156014)(81166006)(305945005)(33656002)(92566002)(7846002)(7416002)(8666005)(65816999)(42186005)(101416001)(99136001)(189998001)(117156001)(6666003)(6916009)(2950100002)(230700001)(106356001)(105586002)(76176999)(87266999)(54356999)(50986999)(59896002)(3846002)(7736002)(586003)(6116002)(7059030);DIR:OUT;SFP:1102;SCL:1;SRVR:DF4PR84MB0313;H:[192.168.142.146];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtERjRQUjg0TUIwMzEzOzIzOkh3ZjhxTkphbVF5ZFVLOEo5R0Z3c0ZjRVJo?= =?utf-8?B?WEpkSkxXQXc0dXFXdGMyUFBneHpna0ZpeVpGWkQ5bE9WbXZlMzQ0dkMxeGhi?= =?utf-8?B?dWFLa2JFektlNlEraWtSWEFEU0ZhVWlJczd5TWNLZlpGclZpdnB2Wno1Yk00?= =?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1koniWl7OjndVJtQ0JeGLkE4I8RufD9o= X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2016 23:21:33.7094 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR84MB0313 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 924 Lines: 23 On 10/07/2016 10:52 AM, Peter Zijlstra wrote: > @@ -600,7 +630,7 @@ __mutex_lock_common(struct mutex *lock, > mutex_acquire_nest(&lock->dep_map, subclass, 0, nest_lock, ip); > > if (__mutex_trylock(lock, false) || > - mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx)) { > + mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, false)) { > /* got the lock, yay! */ > lock_acquired(&lock->dep_map, ip); > if (use_ww_ctx) > @@ -669,7 +699,8 @@ __mutex_lock_common(struct mutex *lock, > * state back to RUNNING and fall through the next schedule(), > * or we must see its unlock and acquire. > */ > - if (__mutex_trylock(lock, first)) > + if ((first&& mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, true)) || > + __mutex_trylock(lock, first)) Do we need a __mutex_trylock() here? mutex_optimistic_spin() will do the trylock and we have one at the top of the loop. Cheers, Longman