Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3363455imu; Mon, 14 Jan 2019 01:27:51 -0800 (PST) X-Google-Smtp-Source: ALg8bN58Ch2qg2GM4Vl5XSITwrv+IkMjgXE+2Wldq4fmkUgSf4L9x0pHxcWxW8SHmKXkXx1wqf9u X-Received: by 2002:a63:5d20:: with SMTP id r32mr22188115pgb.329.1547458071254; Mon, 14 Jan 2019 01:27:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547458071; cv=none; d=google.com; s=arc-20160816; b=d1Mpb8kCo4fKhPU9aaLqVlO6YKJYy4bskGe2c9K+OlHvBk5Tvc4W+UiRppv6ZbA0dO 2bJ2ITP0wgYXyJG2bp+bCmPscbh28AjjiaFpgSoIDFc22WnzJYKPBFIlIQu6Bprs6evV QVf2/kKVsNZsX4ZSbxLcqTqFGsGwU4mjVSchrcUf/X8DkEsdpDk3IKoAbtW2eE2fqxZT 9/OAB7hgvbZl9sP1xtCpv6jXnYzx5YCzeLqP+Z7KF7hg2hl+2ssrwgDxNpIDGNcESnEJ 5u7RZSVfCX9OwGiKdtIlochIXO+AU/X2c/ZPVGJa7wIRsTOZJh75LqU9cmOUtAJd5CYH +SJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:subject:cc:to:from:date:message-id :mime-version:dkim-signature; bh=PawYpizz0/DfJUnNnFd8yW+6KJqQFIbIu2k7H48az90=; b=zoWeFlN78oBu/kbC66IJguRvxkG0lLsuAhCgesDqsZlo1fPOXEnSp9kjgIR/LVqxfe v3C0m+zKWGUiBqqNXS27r0c/C9A2HfSV5xX5CEZFH+WKGcEulyDU1FGaNsMbsoK/v2Wc k0ZfQ/gyxyoKY23UoCyRhl8oBi4xB0TzwU4wp2o29apf9e/37ad6En6SaTa3pN0H+6je wLByeO1VChhd0cMLTpZ7TB4/0eMKXQARxEYBqexLLQpM3OFTzksLBXE1q52dCbsawgAQ uM89xVElEPqytfLIxpU5lAyIgDoV8NEDu0vza0XHb6p+Jik7XrkMJXNLqQoGLXcNJoEu 6YGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="w7/OPUXY"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si15212499pgm.250.2019.01.14.01.27.35; Mon, 14 Jan 2019 01:27:51 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="w7/OPUXY"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726574AbfANJZy (ORCPT + 99 others); Mon, 14 Jan 2019 04:25:54 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:55724 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726306AbfANJZy (ORCPT ); Mon, 14 Jan 2019 04:25:54 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0E9OLiV102436; Mon, 14 Jan 2019 09:25:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : to : cc : subject : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=PawYpizz0/DfJUnNnFd8yW+6KJqQFIbIu2k7H48az90=; b=w7/OPUXY1ibyStKNWDqOPZD700MflDVpfNcZk4sLWlSsffMBXilxCq2c4+Ygx1eVMGoO 5GNbxzeteDHgw4inPffyFnWk2IetZwal/6MRFh47tHhuxitmuA05Y41m2/9ua31s9eK/ cWn2jj4wrxVZOE2Q5tQOSbNZoxUTj9ESwwZA2E8ZYTQ63eCoyTAyIQj26N4na6XKRa9I fMR4yi7K/rlVLkm1CF9XvP7zOflZlFzo6TVgaLPYfxE/1XCk1tjbPzWYPMIFOyBkBkY6 vsspUkq1MyPk2WuwyUxYklB+Q2uwHzJRfGcQr1/wIr6MwpCBCetciDemh0zie61gCfC2 Xw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2pybkc4a36-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Jan 2019 09:25:42 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0E9PgPV009777 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 14 Jan 2019 09:25:42 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0E9Pf2l026452; Mon, 14 Jan 2019 09:25:41 GMT MIME-Version: 1.0 Message-ID: Date: Mon, 14 Jan 2019 01:25:41 -0800 (PST) From: Zhenzhong Duan To: Cc: , , Subject: Re: Question about qspinlock nest X-Mailer: Zimbra on Oracle Beehive Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9135 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901140079 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- longman@redhat.com wrote: > On 01/11/2019 12:06 AM, Zhenzhong Duan wrote: > > > > > > On 2019/1/10 22:43, Waiman Long wrote: > >> On 01/10/2019 03:02 AM, Zhenzhong Duan wrote: > >>> Hi Maintainer, > >>> > >>> > >>> 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? > >>> > >>> > >>> /* > >>> =C2=A0* Per-CPU queue node structures; we can never have more than 4 > nested > >>> =C2=A0* contexts: task, softirq, hardirq, nmi. > >>> =C2=A0* > >>> =C2=A0* Exactly fits one 64-byte cacheline on a 64-bit architecture. > >>> =C2=A0* > >>> =C2=A0* PV doubles the storage and uses the second cacheline for PV > state. > >>> =C2=A0*/ > >>> 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? > > Not for debug exception, for MCE exception handler I found below > two: > > > > do_machine_check->mce_report_event->schedule_work > > do_machine_check->force_sig->force_sig_info > > > > schedule_work() and force_sig_info() take spinlocks. > > --=20 > > Thanks > > Zhenzhong >=20 > The comment for do_machine_scheck() has already state that: >=20 > =C2=A0* This is executed in NMI context not subject to normal locking > rules. This > =C2=A0* implies that most kernel services cannot be safely used. Don't > even > =C2=A0* think about putting a printk in there! >=20 > So even if it doesn't exceed the MAX_NODES limit, it could hit > deadlock > and other kind of locking hazards. So supporting MCE is not a reason > strong enough to extend MAX_NODES. Agree. >=20 > In hindsight, we should have added a "BUG_ON(idx >=3D MAX_NODES);" > check > to avoid silent corruption because of that issue. Looks a good idea if it's hard to avoid using spinlock in MCE handler. Thanks Zhenzhong