Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2286477imu; Thu, 10 Jan 2019 11:24:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Z7FTpx14IDEULVOnHtOzo2nU6gbM19N/MqSuF7ZOS36s5/6Z8CI7ZJHm8WfQ3fDfTmvlV X-Received: by 2002:a63:f515:: with SMTP id w21mr10475843pgh.220.1547148292244; Thu, 10 Jan 2019 11:24:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547148292; cv=none; d=google.com; s=arc-20160816; b=1DWoRQWLvjzowQ0SLEugkkihak0rbOaCvgmHXV6kILQinx/B/ba9AvwprTKXVPPqfD x2zArquSOBko1177Rau8B8Uq5YPTy3l5nRKCHwGD0oU8oWyPCJAhf6ZcmGgdh9vgzsC3 3pZ5WxDzjf5iSqUCPrIEavuVesh0kdretw+5Cw1WorkhROwZzcyW+oIWWcaHeTiJftzj aCtBQbaYFyDRp8PCoIVHy7Hp0foIbdyz/ybXzQSxcLscDAapoTN0H69SqQW1SLfgOBQt X0x5g+RyHCmB7fspetf9MLOz4ZdIvcoNHLENKpH2homdM0CAIVkxYvjRB5q3Cy0rzlYr 5fKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:openpgp:from:references:cc:to :subject; bh=99gMGTGplGbO2o/Uxg18PaOfsYZkgHHQnSuqtefnkQE=; b=HZaaV2EaA8Njpiu4zvqccQCYjdbU9ksTKO/sr9R3/MB+TjvJlQbI8AvP3dB+ovE9PN agMWQe4yZ9rdYwDZV9eTDgbhWEKJeABIFrbxD47zJlfooyNjiMkS69SOTGvv+RclHZCS 84tTghAT236YPlpxRWmIYmwDDbt7blVXg5gHmMuHld4LR7gtUhJEGZB0xq8WHRV68T2m jUsjBAlQvyTVeMyc8SqBpTNX0rU98eRW2MS0e8t1T4gwN8X2zwKH7+bcMmhRHdzOJKmK JbE56w/1nnQLtjYo17fmyHZnzOqo182ZDLT+3xCCtPKUQNv52f/PkO27bqDDsPRJFFLu pPTw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si2767678pgi.152.2019.01.10.11.24.36; Thu, 10 Jan 2019 11:24:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729711AbfAJTXI convert rfc822-to-8bit (ORCPT + 99 others); Thu, 10 Jan 2019 14:23:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60206 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728572AbfAJTXI (ORCPT ); Thu, 10 Jan 2019 14:23:08 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 92A6744818; Thu, 10 Jan 2019 19:23:07 +0000 (UTC) Received: from llong.remote.csb (ovpn-122-16.rdu2.redhat.com [10.10.122.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34AE184F1; Thu, 10 Jan 2019 19:23:06 +0000 (UTC) Subject: Re: Question about qspinlock nest To: James Morse Cc: Zhenzhong Duan , LKML , Peter Zijlstra , SRINIVAS References: <910e9fb6-d0df-4711-fe2b-244b3c20eb82@redhat.com> From: Waiman Long Openpgp: preference=signencrypt Autocrypt: addr=longman@redhat.com; prefer-encrypt=mutual; keydata= xsFNBFgsZGsBEAC3l/RVYISY3M0SznCZOv8aWc/bsAgif1H8h0WPDrHnwt1jfFTB26EzhRea XQKAJiZbjnTotxXq1JVaWxJcNJL7crruYeFdv7WUJqJzFgHnNM/upZuGsDIJHyqBHWK5X9ZO jRyfqV/i3Ll7VIZobcRLbTfEJgyLTAHn2Ipcpt8mRg2cck2sC9+RMi45Epweu7pKjfrF8JUY r71uif2ThpN8vGpn+FKbERFt4hW2dV/3awVckxxHXNrQYIB3I/G6mUdEZ9yrVrAfLw5M3fVU CRnC6fbroC6/ztD40lyTQWbCqGERVEwHFYYoxrcGa8AzMXN9CN7bleHmKZrGxDFWbg4877zX 0YaLRypme4K0ULbnNVRQcSZ9UalTvAzjpyWnlnXCLnFjzhV7qsjozloLTkZjyHimSc3yllH7 VvP/lGHnqUk7xDymgRHNNn0wWPuOpR97J/r7V1mSMZlni/FVTQTRu87aQRYu3nKhcNJ47TGY evz/U0ltaZEU41t7WGBnC7RlxYtdXziEn5fC8b1JfqiP0OJVQfdIMVIbEw1turVouTovUA39 Qqa6Pd1oYTw+Bdm1tkx7di73qB3x4pJoC8ZRfEmPqSpmu42sijWSBUgYJwsziTW2SBi4hRjU h/Tm0NuU1/R1bgv/EzoXjgOM4ZlSu6Pv7ICpELdWSrvkXJIuIwARAQABzR9Mb25nbWFuIExv bmcgPGxsb25nQHJlZGhhdC5jb20+wsF/BBMBAgApBQJYLGRrAhsjBQkJZgGABwsJCAcDAgEG FQgCCQoLBBYCAwECHgECF4AACgkQbjBXZE7vHeYwBA//ZYxi4I/4KVrqc6oodVfwPnOVxvyY oKZGPXZXAa3swtPGmRFc8kGyIMZpVTqGJYGD9ZDezxpWIkVQDnKM9zw/qGarUVKzElGHcuFN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pWorrPknbE/pm MUeZ2d3ss5G5Vbb0bYVFRtYQiCCfHAQHO6uNtA9IztkuMpMRQDUiDoApHwYUY5Dqasu4ZDJk bZ8lC6qc2NXauOWMDw43z9He7k6LnYm/evcD+0+YebxNsorEiWDgIW8Q/E+h6RMS9kW3Rv1N qd2nFfiC8+p9I/KLcbV33tMhF1+dOgyiL4bcYeR351pnyXBPA66ldNWvABEBAAHCwWUEGAEC AA8FAlgsZGsCGwwFCQlmAYAACgkQbjBXZE7vHeYxSQ/+PnnPrOkKHDHQew8Pq9w2RAOO8gMg 9Ty4L54CsTf21Mqc6GXj6LN3WbQta7CVA0bKeq0+WnmsZ9jkTNh8lJp0/RnZkSUsDT9Tza9r GB0svZnBJMFJgSMfmwa3cBttCh+vqDV3ZIVSG54nPmGfUQMFPlDHccjWIvTvyY3a9SLeamaR jOGye8MQAlAD40fTWK2no6L1b8abGtziTkNh68zfu3wjQkXk4kA4zHroE61PpS3oMD4AyI9L 7A4Zv0Cvs2MhYQ4Qbbmafr+NOhzuunm5CoaRi+762+c508TqgRqH8W1htZCzab0pXHRfywtv 0P+BMT7vN2uMBdhr8c0b/hoGqBTenOmFt71tAyyGcPgI3f7DUxy+cv3GzenWjrvf3uFpxYx4 yFQkUcu06wa61nCdxXU/BWFItryAGGdh2fFXnIYP8NZfdA+zmpymJXDQeMsAEHS0BLTVQ3+M 7W5Ak8p9V+bFMtteBgoM23bskH6mgOAw6Cj/USW4cAJ8b++9zE0/4Bv4iaY5bcsL+h7TqQBH Lk1eByJeVooUa/mqa2UdVJalc8B9NrAnLiyRsg72Nurwzvknv7anSgIkL+doXDaG21DgCYTD wGA5uquIgb8p3/ENgYpDPrsZ72CxVC2NEJjJwwnRBStjJOGQX4lV1uhN1XsZjBbRHdKF2W9g weim8xU= Organization: Red Hat Message-ID: <0dc6a5c2-a80d-5ebf-a3ed-5aedacffdd6d@redhat.com> Date: Thu, 10 Jan 2019 14:23:06 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 10 Jan 2019 19:23:07 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/10/2019 01:25 PM, James Morse wrote: > Hi Longman, Zhenzhong, > > On 10/01/2019 14:43, Waiman Long wrote: >> On 01/10/2019 03:02 AM, Zhenzhong Duan wrote: >>> There is a question confused me for days. Appreciate an answer. >>> >>> In below code, the comment says we never have more than 4 nested >>> contexts. >>> >>> What happen if debug and mce exceptions nest with the four, or we >>> ensure it never happen? >>> >>> >>> /* >>>  * Per-CPU queue node structures; we can never have more than 4 nested >>>  * contexts: task, softirq, hardirq, nmi. >>>  * >>>  * Exactly fits one 64-byte cacheline on a 64-bit architecture. >>>  * >>>  * PV doubles the storage and uses the second cacheline for PV state. >>>  */ >>> static DEFINE_PER_CPU_ALIGNED(struct qnode, qnodes[MAX_NODES]); >> Yes, both debug and mce exceptions are some kind of NMIs. So >> theoretically, it is possible to have more than four. Are you aware of >> any debug and MCE exception handlers that need to take a spinlock for >> synchronization? > On arm64 if all the RAS and psuedo-NMI patches land, our worst-case interleaving > jumps to at least 7. The culprit is APEI using spinlocks to protect fixmap slots. > > I have an RFC to bump the number of node bits from 2 to 3, but as this is APEI > four times, it may be preferable to make it use something other than spinlocks. > > > The worst-case order is below. Each one masks those before it: > 1. process context > 2. soft-irq > 3. hard-irq > 4. psuedo-nmi [0] > - using the irqchip priorities to configure some IRQs as NMI. > 5. SError [1] > - a bit like an asynchronous MCE. ACPI allows this to convey CPER records, > requiring an APEI call. > 6&7. SDEI [2] > - a firmware triggered software interrupt, only its two of them, either of > which could convey CPER records. > 8. Synchronous external abort Nested spinlocks isn't a problem as long as no more than 4 of them are contended. Adding one more bit for node will halving the number of CPUs supported without going to the slower version with a single pending bit. Cheers, Longman