From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98E9BC4332F for ; Tue, 12 Dec 2023 10:10:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.652915.1019057 (Exim 4.92) (envelope-from ) id 1rCziQ-00073V-8I; Tue, 12 Dec 2023 10:10:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 652915.1019057; Tue, 12 Dec 2023 10:10:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCziQ-00073O-5E; Tue, 12 Dec 2023 10:10:14 +0000 Received: by outflank-mailman (input) for mailman id 652915; Tue, 12 Dec 2023 10:10:12 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCziO-00071w-Ax for xen-devel@lists.xenproject.org; Tue, 12 Dec 2023 10:10:12 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rCziO-0003ma-5O; Tue, 12 Dec 2023 10:10:12 +0000 Received: from gw1.octic.net ([88.97.20.152] helo=[10.0.1.240]) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1rCziO-0001xu-0O; Tue, 12 Dec 2023 10:10:12 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=nGj3+B8OEe25c1Z0PTh9vYkcMlVI0EeYu+rE+6Ttrwg=; b=ymvmOJY+F8b5sXbDa1mjbUTfSv KQuzmb9tAwVcaQwE5zTsgZa5RXgLoMmoQZTR5R7AN6vZ/UvCkBA2/w1LjEspsSLmICUTdTottCyR6 hBU9UZCFGqAuHl07E+BMbc/7c2W0mo63+/5J5WwABKnK9hCl87eKkvXi7bmSq2hErXSU=; Message-ID: <2c2f8ee1-bf97-4e42-a1ef-74ed1997722c@xen.org> Date: Tue, 12 Dec 2023 10:10:10 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 12/12] xen/spinlock: support higher number of cpus Content-Language: en-GB To: Juergen Gross , xen-devel@lists.xenproject.org Cc: Andrew Cooper , George Dunlap , Jan Beulich , Stefano Stabellini , Wei Liu References: <20231212094725.22184-1-jgross@suse.com> <20231212094725.22184-13-jgross@suse.com> From: Julien Grall In-Reply-To: <20231212094725.22184-13-jgross@suse.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Juergen, On 12/12/2023 09:47, Juergen Gross wrote: > Allow 16 bits per cpu number, which is the limit imposed by > spinlock_tickets_t. > > This will allow up to 65535 cpus, while increasing only the size of > recursive spinlocks in debug builds from 8 to 12 bytes. Looking at arch/Kconfig, it looks like we are limiting NR_CPUS to maximum 4096. So can you outline why we need this? Just to be clear is I am not against this change, but alone it seems a little bit odd to increase the size in debug when that limit can never be reached (at least today). Cheers, > > Signed-off-by: Juergen Gross > --- > xen/common/spinlock.c | 1 + > xen/include/xen/spinlock.h | 18 +++++++++--------- > 2 files changed, 10 insertions(+), 9 deletions(-) > > diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c > index 296bcf33e6..ae7c7c2086 100644 > --- a/xen/common/spinlock.c > +++ b/xen/common/spinlock.c > @@ -481,6 +481,7 @@ int rspin_trylock(rspinlock_t *lock) > > /* Don't allow overflow of recurse_cpu field. */ > BUILD_BUG_ON(NR_CPUS > SPINLOCK_NO_CPU); > + BUILD_BUG_ON(SPINLOCK_CPU_BITS > sizeof(lock->recurse_cpu) * 8); > BUILD_BUG_ON(SPINLOCK_RECURSE_BITS < 3); > > check_lock(&lock->debug, true); > diff --git a/xen/include/xen/spinlock.h b/xen/include/xen/spinlock.h > index 87946965b2..d720778cc1 100644 > --- a/xen/include/xen/spinlock.h > +++ b/xen/include/xen/spinlock.h > @@ -7,16 +7,16 @@ > #include > #include > > -#define SPINLOCK_CPU_BITS 12 > +#define SPINLOCK_CPU_BITS 16 > > #ifdef CONFIG_DEBUG_LOCKS > union lock_debug { > - uint16_t val; > -#define LOCK_DEBUG_INITVAL 0xffff > + uint32_t val; > +#define LOCK_DEBUG_INITVAL 0xffffffff > struct { > - uint16_t cpu:SPINLOCK_CPU_BITS; > -#define LOCK_DEBUG_PAD_BITS (14 - SPINLOCK_CPU_BITS) > - uint16_t :LOCK_DEBUG_PAD_BITS; > + uint32_t cpu:SPINLOCK_CPU_BITS; > +#define LOCK_DEBUG_PAD_BITS (30 - SPINLOCK_CPU_BITS) > + uint32_t :LOCK_DEBUG_PAD_BITS; > bool irq_safe:1; > bool unseen:1; > }; > @@ -210,10 +210,10 @@ typedef struct spinlock { > > typedef struct rspinlock { > spinlock_tickets_t tickets; > - uint16_t recurse_cpu:SPINLOCK_CPU_BITS; > + uint16_t recurse_cpu; > #define SPINLOCK_NO_CPU ((1u << SPINLOCK_CPU_BITS) - 1) > -#define SPINLOCK_RECURSE_BITS (16 - SPINLOCK_CPU_BITS) > - uint16_t recurse_cnt:SPINLOCK_RECURSE_BITS; > +#define SPINLOCK_RECURSE_BITS 8 > + uint8_t recurse_cnt; > #define SPINLOCK_MAX_RECURSE ((1u << SPINLOCK_RECURSE_BITS) - 1) > union lock_debug debug; > #ifdef CONFIG_DEBUG_LOCK_PROFILE -- Julien Grall