Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752107AbcDTRu7 (ORCPT ); Wed, 20 Apr 2016 13:50:59 -0400 Received: from mail-bn1bon0139.outbound.protection.outlook.com ([157.56.111.139]:37472 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751185AbcDTRu5 (ORCPT ); Wed, 20 Apr 2016 13:50:57 -0400 Authentication-Results: infradead.org; dkim=none (message not signed) header.d=none;infradead.org; dmarc=none action=none header.from=hpe.com; Message-ID: <5717C173.60103@hpe.com> Date: Wed, 20 Apr 2016 13:50:43 -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: Pan Xinhui , Ingo Molnar , , Scott J Norton , Douglas Hatch Subject: Re: [PATCH v2] locking/pvqspinlock: Add lock holder CPU argument to pv_wait() References: <1460659318-53312-1-git-send-email-Waiman.Long@hpe.com> <20160420120805.GB3408@twins.programming.kicks-ass.net> <57178EED.1060207@linux.vnet.ibm.com> <20160420141949.GE3430@twins.programming.kicks-ass.net> In-Reply-To: <20160420141949.GE3430@twins.programming.kicks-ass.net> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [72.71.243.67] X-ClientProxiedBy: CY1PR21CA0080.namprd21.prod.outlook.com (10.163.250.176) To TU4PR84MB0317.NAMPRD84.PROD.OUTLOOK.COM (10.162.186.27) X-MS-Office365-Filtering-Correlation-Id: 9db821d1-5451-4239-936b-08d3694451eb X-Microsoft-Exchange-Diagnostics: 1;TU4PR84MB0317;2:LfbmSwsHXk+g2FOoMqgzNRawzxBNrnjotlA09fKGSEnCuiEKZMC/DCqnL7ncMPx6kludE9PljpNOt1XrhvSHoCViNU3kx5SM9hbQ8KYwXg/4Ol5Rnlft1cODvQHlsX6mvSPmh5+w0Zh+hzJmM7llCmTzeo5wXSkC375RHFIyNDF7tMJuuk6iyN1AUDmu9cYm;3:lyB/IPRli861U3S5TNMKqMhBPK4qxKr4o4POYjqGmqNop8HnLtEW1t625Ul0VyDhV8v5u4yBF8NG41wHBYPN/g9WyF0Bav6Y6861FStpup6K4hNn/8L2EpTzqKI+vrmJ;25:iVYHJeiHeSXRVjNPF9/eEh+H4tw3Hja5xCXU5WkVhfDMUr2qbDbaEEh8ob0TVJjUaz99CdoIlKnV6LzVqMT6zK1mLb6zjTah39FUh5Kn7d1SpBCRTSH06UsgAIveHnavvudk6zjxKB5R5sWyrSsLlUi7KzmIcnmwtQ6TG6mZRqhR9/01X0vGOXYAJVjnV0OUnUtxiTE7hF58vTnrpRSne3Jlf4g3IDeYgUeZUfDorJU0qWZxb1Ovb8/xFrPbIFrUd/Ofd7SK2urysFU5o4g/BKNmcGs6FXOFAxclpZbbGVBYCz3WkyIPHAwPwyT2OTuFlg+9PT9PPv0C9hTOIFtsTwioXNRzp5blS0+a7f3CDqXDR4+An5FcliudXvEjfitgF58fQI5tD0ob4Q8whUQbURyli6Ii58UPMu6DFPA157/90lapB9ADX1FUpIgECD7qc9njJEtFpKt2fVQxeVAOaRGXiuU/sDP67Enc2QgYNuJdKFXwr95XWvEug0ysDJS2dCtWpLzZw4nIr7oSIzsgPtZbYEN6zbOEnqhGgLnAI+Hi8HLbE3qRgOLPvLnlKh0uiH/FASO7AXeHhzlFz5CwN3jMo19bgwQ/f0hvnZUI5QTVfX8eLQpPgs2hw+hmOCQk X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:TU4PR84MB0317; X-LD-Processed: 105b2061-b669-4b31-92ac-24d304d195dc,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;TU4PR84MB0317;20:Qe2884eWZ6LCs0A9NilKCsLmrvqMskujourhGQGjJYwnbYhhiKaEjLo+BPM4Sez7kpQudKXDfaS8tIJQ+zt8nT2DT+QHv8nbTWR80TfmosB/5KNgjTwRmQRGcXFRmMGrlL25q72fBGhjDCINTOkpPyB2JArZLp+ID1Ts0uTEu+2vuAK4NuIzm593Ec8muEq/cXkgAVNWUNFiuJnpkmGIRHJorV00D3WKcMtlHLFvZT6hQMHQ43VQ2VdQnR+FmuYm3g3lpJarLNAq8QIX+tHrt+qt8me/R7kqZa1C5E3IMjFrgfbsN1Rqoi26EMAR4x4av04f0obcZzQHy9SjAMCcfA==;4:jHWjYRc3YPYCJ55kPFso6SBGf4gbwP7Debsua/HBHpxgvu3/HubSLf2WazU/dLY/to9c7u1tyVDQv5U8J6cpc+i57x1oa1ZCx5NDi0BbzIZp0T0e4IJY8Qf2fFIw49TUgQ1U6iyvOHQRlJIO2y7MnT57OgNCuaYsSqLvEeEJk0tN2SPANFCA8HephIuRz2KT3aIhH5WMs7jNdHC73BUZoMAkzkT9jJorbFFChd/HEUjgKF0uDsEZq9Gk+kNm24Ck0qGBRLGcZ786t+tUN1y1cQHdvhgg9LiEzFAroDfeHMgENSRChpLsqjkVzYNKtXJc440HOCDWzHJzTYsU6sbBVk4boHKA3E2pvkdGwrqCY6dWc0XK0F5p/W53C8y8zO32VmBcXixG018N1ZoLCFRK77XPa9d2Du8M38YNtkrPRvA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(9101521026)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026);SRVR:TU4PR84MB0317;BCL:0;PCL:0;RULEID:;SRVR:TU4PR84MB0317; X-Forefront-PRVS: 0918748D70 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(377454003)(24454002)(77096005)(93886004)(4326007)(3846002)(83506001)(586003)(50986999)(76176999)(65956001)(1096002)(65806001)(66066001)(54356999)(47776003)(6116002)(110136002)(50466002)(5008740100001)(65816999)(86362001)(42186005)(117156001)(2950100001)(23756003)(33656002)(5004730100002)(230700001)(36756003)(4001350100001)(81166005)(92566002)(2906002)(189998001);DIR:OUT;SFP:1102;SCL:1;SRVR:TU4PR84MB0317;H:[192.168.142.160];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?iso-8859-1?Q?1;TU4PR84MB0317;23:xzh+n9lnswWlBzQ7x5ASVgAQVyAfFkgIRENU/D3?= =?iso-8859-1?Q?Y8MAVxZ5rDloV6zlmDgstAudlgEqzn2Seh8VWorvTGRNpUDKgZQO4KVDKk?= =?iso-8859-1?Q?ewutzEQuhof13iC0zMJUxtILs+pC4ICvmfLgTl4j39QBgrwb23zbWaueFd?= =?iso-8859-1?Q?6Zm8YpVYbM5GXnlUyPhbcxHc027NjULCfjpiANaSGz0F6z2vdy2u+cmFrv?= =?iso-8859-1?Q?qIe3H15eibZQjoU/B0RD7QTWg6jL3v3stvxIPLCJ55u2rlpZOviAb4dUuL?= =?iso-8859-1?Q?o1Au2jzVcrXX84IBoBsD2uucOg31BOpo0gNXckPQPSZpn1oaeXGCEydaBm?= =?iso-8859-1?Q?fIq7Tl0b+8f5DuA9K5FITIWBr3JMTV9CcG06oN4GS1iwKKbVINHI+o8o1e?= =?iso-8859-1?Q?IJI79H2AeVMBLJx3KaapOD5GTjJJFQrG6+1oYc9Mya4rqyWDbnPb3lgiBN?= =?iso-8859-1?Q?e3X5+YcECe41UZchVaLYP/bMv31Kb/aDWGxwxK7+VckLzjAOv5Bmi8J5WG?= =?iso-8859-1?Q?wuM+zIq1y2cd+p12SuDd5IXVgMbBoaLhojsW5/WtEItvuSxBH/XUbferJS?= =?iso-8859-1?Q?d+CZqniAIpjEZrEKos0h/OmMs2wi1xwiLKOnNR2Oj6ThlwGw8frZdxL9Kr?= =?iso-8859-1?Q?GDsu1jOOkrEQNx2FetRX6JhhUjVQ82poaRfnduN4lcgQSa5Y2fHJeybB+7?= =?iso-8859-1?Q?mKt76L8ycGZPqnrlnRdieFeqrRwCpIpMdq3Yo0y0RIY94BEgVYMI7OhleI?= =?iso-8859-1?Q?yvETE/l07UGJsBDUm8CWcN2ckyQFN2gxx0B3NuAMsV3QFt4HxVYcoTNcyU?= =?iso-8859-1?Q?iDoNlrqQvhGSgNMDVI09lK336uaa/DxgoaB0hHoKMyHPkLI4WnoN7RIo7b?= =?iso-8859-1?Q?zDIGekW8CDJiyPm7SxatTbGV7KFPBZSPI/AiLA4e+ar70tmPHDJhqM510Y?= =?iso-8859-1?Q?F1rPnrMHI415R0dpK/Nc8Ss9MD+9okt4YEIG9wxtLK6GuH6eon6GIZ1QpK?= =?iso-8859-1?Q?d1cQBF4KFaUJX9ujQFKIFQQxLQRmNglbpcgABrKvqmzIVOP0n7W7bpdAd?= X-Microsoft-Exchange-Diagnostics: 1;TU4PR84MB0317;5:NsszjrQs5FpldUzmNcmnfGlwBrDsgVwcZbyLbQOn/I0T1EBzicHt+tcKYbaCop3JQtThHC3oCQLvnzMu8hWctX07Qsbk3TE5Sg4IOrr3sKLVr+XUmPfucEmImeFFixTpRPe22HWf+Nf1TRYc22ou2w66WWh2NTeRVrYMX4sF4/ncsPbfUJpbP6z3kZaQUzXP;24:dZfJrYQ1NKy3jL8UpXpwzreTBhl9+BadYsnF2dQFC0JcwGGxXbbrGMp1H7iN6DBXwbxyIPsVIJRheA5JRNcmXHhg/nZ5V2JH625kk54O9j0=;7:LhSXJuNCbmGnCIgQU3g3DlaB42hMPJMbU/+d7E2zg2xdsZxOYJawAiasa4Fk6LYWq6bNyqH9dqG9wTrBHil1TKlcfzHnaeJusJyXJEG5n38pe7Em/Fe1iq7XxwQ84b459YUG6XErlLFZ8tmmeeXJY9ETWUfYpjWoq7p4OSVMDph6fXtdQFzBbgr5iyLw+Xj07MdBRPR8D5X9qskvhUEcVhlbV8jikAWZhZ1hqTa3G+4= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2016 17:50:53.4957 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: TU4PR84MB0317 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1235 Lines: 29 On 04/20/2016 10:19 AM, Peter Zijlstra wrote: > On Wed, Apr 20, 2016 at 10:15:09PM +0800, Pan Xinhui wrote: >> So there is such case that we search the whole hashtable and the lock is not found. :( >> Waiman assume that if l = null, the lock is not stored. however the lock might be there actually. >> But to avoid the worst case I just mentioned above, it can quickly finish the lookup. > >>>> + >>>> + /* >>>> + * We try to locate the queue head pv_node by looking >>>> + * up the hash table. If it is not found, use the >>>> + * CPU in the previous node instead. >>>> + */ >>>> + hn = pv_lookup_hash(lock); >>>> + if (!hn) >>>> + hn = pn; >>> This is potentially expensive... it does not explain why this lookup can >>> fail etc.. nor mentioned that lock stealing caveat. >>> >> Yes, it's expensive. Normally, PPC phyp don't always need the correct >> holder. That means current vcpu can just give up its slice. There is >> one lpar hvcall H_CONFER. I paste some spec below. > Ok, so if we can indeed scan the _entire_ hashtable, then we really > should not have that in common code. That's seriously expensive. No, it should not scan the entire hashtable and there is no point in doing so. Cheers, Longman