[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 1/5] xen/ppc: Implement atomic.h


  • To: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 5 Sep 2023 16:58:19 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kH8U8l8x3oH9VXoWQ8vgN+kErZjRLvzrKcTCOaCO2VI=; b=nFtsk8TaSuhqyM9hJpL5dqetHesDjXDVKEFSISih2QmNIKTagdRAROsHrlZjH9boCOjKTI9J6JAyIM2vJ3kdKXNMN7vZ65zZ3hmLQCpfAFCyVGPVD0TqsU7awdjtO70GM2egz3zTyJVYtFukz6RqcWGP8H+BoEWmdtvySViEpPyL43hLXTGi2QUenVCY0SKZfW6Kf9f1cbgTHSrqAOdIz+vt/DsExmRxaSdHM1Ph5faAKtwrXPDmjeRV0CWXR0q/CTHaBnztdHjKPjMw9AqKX/0nLxdDca8AyqNAy5puiueb8WahXasoRoWi+aQ1yQPYsZhfE2CFenCUoClQIT/9TA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FXEraWyAKrObJhq++y8qlZLozIyAkJ6F9uCPMXs2bD4HhooRmwIzoTHnMVFEien+JrWUFbkdt7hBjA0y3kLuhne7s8BIMIBFjd1llhYXK0Cwnm6mUIklw6GsKPjHO5XKC64EHYR+QAvxO88wwi66gt1hAWw4aa3eSZLAMcLQxXbquGNNK18fHurwISx8IQoO+K+JH1QY+IbVNZmjfwMLP+g6PRe/jERSVe9MGsKGS1mXAG1/qYjvDsBCYmUg7UPVvdtqORUYKBtGlllV63Y9LF5bBwmrTBI+qnG2PbKCPJ2oPG9YH6CGE2Fhq1bZGllnx8lr/MxsU9TRYFAqIewFNA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Timothy Pearson <tpearson@xxxxxxxxxxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 05 Sep 2023 14:58:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 01.09.2023 20:25, Shawn Anastasio wrote:
> +static inline atomic_t atomic_compareandswap(atomic_t old, atomic_t new,
> +                                             atomic_t *v)
> +{
> +    atomic_t rc;
> +    rc.counter = __cmpxchg(&v->counter, old.counter, new.counter, 
> sizeof(int));

I can't seem to be able to spot where __cmpxchg() is defined. (I really
only wanted to check why it needs the 4th argument, which here rather
would want to be e.g. sizeof(v->counter). If it can't be omitted.)

> +    return rc;
> +}
> +
> +#define arch_cmpxchg(ptr, o, n)                                              
>   \
> +    ({                                                                       
>   \
> +        __typeof__(*(ptr)) o_ = (o);                                         
>   \
> +        __typeof__(*(ptr)) n_ = (n);                                         
>   \
> +        (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long) o_,            
>   \
> +                                       (unsigned long) n_, sizeof(*(ptr)));  
>   \

Nit: Stray blanks again after cast specifiers.

> --- /dev/null
> +++ b/xen/arch/ppc/include/asm/memory.h
> @@ -0,0 +1,21 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (C) IBM Corp. 2005
> + *
> + * Authors: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
> + */
> +
> +#ifndef _ASM_MEMORY_H_
> +#define _ASM_MEMORY_H_
> +
> +#include <xen/config.h>

As mentioned before - no need for this explicit #include.

> +#ifdef CONFIG_SMP
> +#define PPC_ATOMIC_ENTRY_BARRIER "sync\n"
> +#define PPC_ATOMIC_EXIT_BARRIER  "sync\n"
> +#else
> +#define PPC_ATOMIC_ENTRY_BARRIER
> +#define PPC_ATOMIC_EXIT_BARRIER
> +#endif

Is this correct, considering that we have no CONFIG_SMP and assume SMP
in all cases?

I'm sorry for not paying attention earlier.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.