Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1749681ybg; Sat, 19 Oct 2019 01:41:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzI/8U0mtLSWb4o0ZRwBfU003h9xtUwK4/sOyfsqCP9BbBQc9qTlwgxr+U5HtJnXnzSTg0A X-Received: by 2002:a17:906:c49:: with SMTP id t9mr12564215ejf.267.1571474460456; Sat, 19 Oct 2019 01:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571474460; cv=none; d=google.com; s=arc-20160816; b=OumRf8IJ0r5eVdV2RHkoXm3i8pBez1IMIuVkoR16+rO3ERxl5DzPQiRiy8itI8Ky76 P9R/58GTyWeitYqEWTpCpGBU2eFuBStwdMApUcm8OEvorKaW7Nr5NIVSBKEVtcn6eFl2 DV9Wf3zGfZx8QcxkYBuxZfv8wjKe+gGdovMLsQjcR5Qld+0fun1KnA0NeyiSyFfJ1qEC IGnUcGSB18oEThqXOS/7ArtOzjoQUpsucu6Dp/UcYHBdU8r33lkkxVH42MT0BCFMDI/i FcYfIhxPEsJx7FlEzokhrJIw2mR0yh3yuJrYlmFbmQxS4BIGvbGofLhHd4/bcesPtwXv pnkA== 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:from:references:cc:to:subject; bh=3KDJp3LHMpkCWtOS3FNMYD3wEPe/COrxM3BLsBtPGm0=; b=lMjsDe6ttxiQ6jUzNMcy/8V4ISUgQ9JOxiLENZjtPlp3zdjNGMoPsAan3zONAnMJ0C tTTYePWFbfVt/z/layyoRsy9O3FSmoyRMb0oY3xs5ELf5D7wnfrVM/WBO98L+BK8xMo2 iDnqAYAcqRS9rmTanjZO04/AwpW8hYEG/car3sb+ngLokYrily0AYi5V4ox1CrZ1XIem IZtrDbaHdr+i2s0/nIDWnoBGjWU4pPHGTVSK6yYxOQM9xGsr192OKv0svDUANFe53EKS zVofQuZaoQhgLm04/+6st53+eq+mJkknYsyXzbdtUCK6FkTL7QTgo4tomrOsu9xFVBvE ogUA== 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 sb7si4649124ejb.321.2019.10.19.01.40.37; Sat, 19 Oct 2019 01:41:00 -0700 (PDT) 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 S2409208AbfJRQDN (ORCPT + 99 others); Fri, 18 Oct 2019 12:03:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53790 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408951AbfJRQDN (ORCPT ); Fri, 18 Oct 2019 12:03:13 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEB5E3071D94; Fri, 18 Oct 2019 16:03:12 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-59.bos.redhat.com [10.18.17.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 250A95D71C; Fri, 18 Oct 2019 16:03:11 +0000 (UTC) Subject: Re: [PATCH v5 3/5] locking/qspinlock: Introduce CNA into the slow path of qspinlock To: Alex Kogan , linux@armlinux.org.uk, peterz@infradead.org, mingo@redhat.com, will.deacon@arm.com, arnd@arndb.de, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, bp@alien8.de, hpa@zytor.com, x86@kernel.org, guohanjun@huawei.com, jglauber@marvell.com Cc: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, dave.dice@oracle.com, rahul.x.yadav@oracle.com References: <20191016042903.61081-1-alex.kogan@oracle.com> <20191016042903.61081-4-alex.kogan@oracle.com> From: Waiman Long Organization: Red Hat Message-ID: <6ce50aeb-6b87-5d1c-9011-4329e8dadfec@redhat.com> Date: Fri, 18 Oct 2019 12:03:10 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20191016042903.61081-4-alex.kogan@oracle.com> 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 18 Oct 2019 16:03:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/16/19 12:29 AM, Alex Kogan wrote: > +static inline void cna_pass_lock(struct mcs_spinlock *node, > + struct mcs_spinlock *next) > +{ > + struct cna_node *cn = (struct cna_node *)node; > + struct mcs_spinlock *next_holder = next, *tail_2nd; > + u32 val = 1; > + > + u32 scan = cn->pre_scan_result; > + > + /* > + * check if a successor from the same numa node has not been found in > + * pre-scan, and if so, try to find it in post-scan starting from the > + * node where pre-scan stopped (stored in @pre_scan_result) > + */ > + if (scan > 0) > + scan = cna_scan_main_queue(node, decode_tail(scan)); > + > + if (!scan) { /* if found a successor from the same numa node */ > + next_holder = node->next; > + /* > + * make sure @val gets 1 if current holder's @locked is 0 as > + * we have to store a non-zero value in successor's @locked > + * to pass the lock > + */ > + val = node->locked + (node->locked == 0); node->locked can be 0 when the cpu enters into an empty MCS queue. We could unconditionally set node->locked to 1 for this case in qspinlock.c or with your above code. Perhaps, a comment about when node->locked will be 0. It may be easier to understand if you just do     val = node->locked ? node->locked : 1; Cheers, Longman