Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1001028ybl; Fri, 24 Jan 2020 13:32:21 -0800 (PST) X-Google-Smtp-Source: APXvYqw8g+g3SRCVCNmzymG9TqKNggsBxw/kS0USDfclqcOu8csAt4AK/u06sFHtKVmtRJWLvh4P X-Received: by 2002:aca:c74e:: with SMTP id x75mr622895oif.140.1579901541508; Fri, 24 Jan 2020 13:32:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579901541; cv=none; d=google.com; s=arc-20160816; b=braSwYJQlxUkr+0IkmctVlSk9tssdxVYUyIfeE0/ZjFBn2F0Hwbe/aACZjoeyEWL3D JN7xU1M0iZ4iNUdOlNpV2hlltXg+99MAgkLKtQ5tISdKh5vgnC4uNw5XWsa3gPyzNbVU OyY6hi4Pd1KjKcJoLP4CbgHzOggL6P8XZlICkmfQsSunFfH6Yz2KPHnEqhifFIRDqls9 QIf9u+qIQrt4VbPiKILgqfBdhLN6JwAx5SQ7LVCRNZJ8DjH66ffNaTGK8JJz9rSPN9Kl pMi4oK9q3b7e6Ue3bsLg3XSkMH969N0tPJHJ06ZnMmDaLxQDJPsdu/5GcWi8hRR5wASp 3FqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=p5t6LkqqtkLbFaU0MqEIWNiNkEIpgv1igSF09fB8KrA=; b=UM7MkpjhYLO3sozF+GjBTWOATsuJX27CbVGLwEVOcLpCSe3ymeDx1+7suW1o75Me3g 7H+xYAmB/92lfkaVtLEEeqXOiTiykpNJahxo+pe+7QpEWTHN06TTs+ftcOFh/swHGyiX +spTZnRSc4KN821/+6EDAmL8vUE58T7ptAUHeRTBKESsRtu3bvExNgQNE5NDM+KfEt4H jwHne9qrsCEJ4lJCSVmnwUnz+W1xdi/APmgcRgHv4nMZqKAbE10bq3s263V4qQijiECk /2WLrk1hTURx71dFSLbC/SneNynYI6MeAhLmQ5DoeD970V6MHL/eIAV/a4eXLDgT30Gc zBnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=VHKFEVeN; 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 g138si402648oib.190.2020.01.24.13.32.09; Fri, 24 Jan 2020 13:32:21 -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-2019-08-05 header.b=VHKFEVeN; 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 S1726771AbgAXV2f (ORCPT + 99 others); Fri, 24 Jan 2020 16:28:35 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:50892 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbgAXV2f (ORCPT ); Fri, 24 Jan 2020 16:28:35 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00OLDUX8030736; Fri, 24 Jan 2020 21:27:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=corp-2019-08-05; bh=p5t6LkqqtkLbFaU0MqEIWNiNkEIpgv1igSF09fB8KrA=; b=VHKFEVeNqeHq17YMHhlyAcOE2zv81FJr4giioXRcXUw+UhejgDR8KPlrH5TXonuDgb1s 14Baht/IkQtPfsr7o6zX4MyX42qVIGA3/1G333aHdYGrkbyohbhXuHEueUWLNjgX5Wqi WCPb8iyNq0fbsuYZVOF32EfOn7V/0w2f7lrImFDHhtnQlj/sgr5Yva+KD2+Q07OhA+Jl V6IDDUZz9kh43M89O5eriW01AWMTtg0L5ZKgr97edCkZCjpLA0lk+gb3b6AIHLiAasy4 k2FKyd7ykREklycu6ZglxkRxn/AOINsWvMPuuCEHv5dTi5Fse2f8bMmDvYiq5cEB0EDX zw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2xksev3nbb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jan 2020 21:27:50 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00OLE1Ca127966; Fri, 24 Jan 2020 21:27:50 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2xr2yhvtpq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jan 2020 21:27:50 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 00OLRaav016958; Fri, 24 Jan 2020 21:27:41 GMT Received: from [192.168.0.159] (/173.76.205.43) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 24 Jan 2020 13:27:35 -0800 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: [PATCH v8 4/5] locking/qspinlock: Introduce starvation avoidance into CNA From: Alex Kogan In-Reply-To: Date: Fri, 24 Jan 2020 16:27:32 -0500 Cc: Peter Zijlstra , linux@armlinux.org.uk, Ingo Molnar , Will Deacon , Arnd Bergmann , linux-arch@vger.kernel.org, linux-arm-kernel , linux-kernel@vger.kernel.org, Thomas Gleixner , Borislav Petkov , hpa@zytor.com, x86@kernel.org, Hanjun Guo , Jan Glauber , Steven Sistare , Daniel Jordan , dave.dice@oracle.com Content-Transfer-Encoding: quoted-printable Message-Id: References: <20191230194042.67789-1-alex.kogan@oracle.com> <20191230194042.67789-5-alex.kogan@oracle.com> <20200121132949.GL14914@hirez.programming.kicks-ass.net> <3862F8A1-FF9B-40AD-A88E-2C0BA7AF6F58@oracle.com> <20200124075235.GX14914@hirez.programming.kicks-ass.net> <2c6741c5-d89d-4b2c-cebe-a7c7f6eed884@redhat.com> <48ce49e5-98a7-23cd-09f4-8290a65abbb5@redhat.com> <8D3AFB47-B595-418C-9568-08780DDC58FF@oracle.com> <714892cd-d96f-4d41-ae8b-d7b7642a6e3c@redhat.com> <1669BFDE-A1A5-4ED8-B586-035460BBF68A@oracle.com> <45660873-731a-a810-8c57-1a5a19d266b4@redhat.com> <693E6287-E37C-4C5D-BE33-B3D813BE505D@oracle.com> To: Waiman Long X-Mailer: Apple Mail (2.3445.104.11) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9510 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1911140001 definitions=main-2001240175 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9510 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1911140001 definitions=main-2001240175 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Jan 24, 2020, at 4:12 PM, Waiman Long wrote: >=20 > On 1/24/20 3:09 PM, Alex Kogan wrote: >>>> We also probably do not want those =E2=80=9Cprioritized=E2=80=9D = threads to disrupt >>>> normal >>>> CNA operation. E.g., if the main queue looks like T1_1, P2_1, T1_2, >>>> =E2=80=A6, where >>>> T1_x is a thread running on node 1 and P2_1 is a prioritized thread >>>> running >>>> on node 2, we want to pass the lock from T1_1 to P2_1 and then to = T1_2 >>>> (rather than have P2_1 to scan for another thread on node 2). >>>>=20 >>>> There is a way to achieve that =E2=80=94 when we pass the lock to = P2_1, >>>> we can set its numa node field to 1. This means that we need to >>>> reset the numa >>>> node field in cna_init_node(), but AFAICT this is relatively cheap. >>>> The rest >>>> of the CNA logic should not change. >>>=20 >>> I won't recommend doing that. If the lock cacheline has been moved >>> from node 1 to 2, I will say it is better to stick with node 2 = rather >>> than switching back to node 1. That will mean that the secondary >>> queue may contain lock waiters from the same nodes, but they will >>> eventually be flushed back to the primary queue. >>>=20 >> That=E2=80=99s right, assuming we do not reset intra_node count when >> transferring the >> lock to a prioritized thread from another node. Otherwise, we may = starve >> waiters in the secondary queue.=20 >>=20 >> Still, that can make the lock even less fair to non-prioritized >> threads. When >> you flush the secondary queue, the preference may remain with the = same >> node. This will not happen in the current form of CNA, as we never = get=20 >> threads from the preferred node in the secondary queue. >=20 > That is true. >=20 > However, it is no different from the current scheme that a waiter from > another node may have to wait for 64k other waiters to go first before > it has a chance to get it. Now that waiter can be from the same node = as > well. The difference is that in the current form of CNA, the preferred node = _will change after 64k lock transitions. In the change you propose, this is no longer the case. It may take another ~64k transitions for that to = happen. More generally, I think this makes the analysis of the lock behavior = more convoluted. I think we should treat those prioritized threads as =E2=80=9Cwild=E2=80=9D= cards, passing the=20 lock through them, but keeping the preferred node intact. This will = potentially cost one extra lock migration, but will make reasoning about the lock behavior easier. Regards, =E2=80=94 Alex=