From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 69FD538582A3 for ; Fri, 3 Mar 2023 15:05:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69FD538582A3 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 323EwCiH004479 for ; Fri, 3 Mar 2023 15:05:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=D8n6P0ceQ8MW5oQXaefugLitG3gLJ0D8h6pAgum8Qho=; b=o6Fol5mP29Vu+sIi1e1amnmdF5T3/ZTO3mVx54pVlQl/+cB+3aSEig3/cnpqef6mEj65 qCo4Ibv6CEejVxvWu09wf5HiZ14pI+QTckOZXyC8XcN7gFv/zE4ZeX1hMNalv7gGBwHp JEbXAORDdq1NiY01bjO9Re7Q8hpSjSrk1QeUi9OfT8XRskKwjstUwr0999kR/QKoEciA CP+QQnHGcN9hG+/MA1P1R8ak6QnIOuWAqarqUMA8sFOrkwVrygmbqBjeGhroGxl9ZA7O d2hA9XgJ9aHx9IdYDZQc8E+fRfjbTMy5xhfZUa8p1Kzb6Zyp4ziPKa8eDHxUheigpoQa Pw== Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3p3k42r83y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 03 Mar 2023 15:04:59 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 322KgMVL013207 for ; Fri, 3 Mar 2023 15:04:58 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3nybdbnepj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 03 Mar 2023 15:04:57 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 323F4sCo31064486 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Mar 2023 15:04:54 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54AAF2004D; Fri, 3 Mar 2023 15:04:54 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1665420043; Fri, 3 Mar 2023 15:04:54 +0000 (GMT) Received: from [9.171.11.44] (unknown [9.171.11.44]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 3 Mar 2023 15:04:53 +0000 (GMT) Message-ID: <4d523bfb-0b22-8f80-a6f5-05ad26d6fd94@linux.ibm.com> Date: Fri, 3 Mar 2023 16:04:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] s390: libatomic: Fix 16 byte atomic {cas,load,store} Content-Language: en-US To: Stefan Schulze Frielinghaus , gcc-patches@gcc.gnu.org References: <20230302152450.1486452-1-stefansf@linux.ibm.com> From: Andreas Krebbel In-Reply-To: <20230302152450.1486452-1-stefansf@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: tKxtwAr0c3i4W4Lq_rpQkCjXhUm1G3Yb X-Proofpoint-GUID: tKxtwAr0c3i4W4Lq_rpQkCjXhUm1G3Yb Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-03_02,2023-03-03_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 clxscore=1015 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 lowpriorityscore=0 impostorscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303030126 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 3/2/23 16:24, Stefan Schulze Frielinghaus wrote: > This is a follow-up to commit a4c6bd0821099f6b8c0f64a96ffd9d01a025c413 > introducing a runtime check for alignment for 16 byte atomic > compare-exchange, load, and store. > > Bootstrapped and regtested on s390. > Ok for mainline and gcc-{12,11,10}? > > libatomic/ChangeLog: > > * config/s390/cas_n.c: New file. > * config/s390/load_n.c: New file. > * config/s390/store_n.c: New file. Ok. Thanks! Andreas > --- > libatomic/config/s390/cas_n.c | 65 +++++++++++++++++++++++++++++++++ > libatomic/config/s390/load_n.c | 57 +++++++++++++++++++++++++++++ > libatomic/config/s390/store_n.c | 54 +++++++++++++++++++++++++++ > 3 files changed, 176 insertions(+) > create mode 100644 libatomic/config/s390/cas_n.c > create mode 100644 libatomic/config/s390/load_n.c > create mode 100644 libatomic/config/s390/store_n.c > > diff --git a/libatomic/config/s390/cas_n.c b/libatomic/config/s390/cas_n.c > new file mode 100644 > index 00000000000..44b7152ca5d > --- /dev/null > +++ b/libatomic/config/s390/cas_n.c > @@ -0,0 +1,65 @@ > +/* Copyright (C) 2018-2023 Free Software Foundation, Inc. > + > + This file is part of the GNU Atomic Library (libatomic). > + > + Libatomic is free software; you can redistribute it and/or modify it > + under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY > + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + more details. > + > + Under Section 7 of GPL version 3, you are granted additional > + permissions described in the GCC Runtime Library Exception, version > + 3.1, as published by the Free Software Foundation. > + > + You should have received a copy of the GNU General Public License and > + a copy of the GCC Runtime Library Exception along with this program; > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > + . */ > + > +#include > + > + > +/* Analog to config/s390/exch_n.c. */ > + > +#if !DONE && N == 16 > +bool > +SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval, > + int smodel, int fmodel UNUSED) > +{ > + if (!((uintptr_t)mptr & 0xf)) > + { > + return __atomic_compare_exchange_n ( > + (UTYPE *)__builtin_assume_aligned (mptr, 16), eptr, newval, false, > + __ATOMIC_SEQ_CST, __ATOMIC_RELAXED); > + } > + else > + { > + UTYPE oldval; > + UWORD magic; > + bool ret; > + > + pre_seq_barrier (smodel); > + magic = protect_start (mptr); > + > + oldval = *mptr; > + ret = (oldval == *eptr); > + if (ret) > + *mptr = newval; > + else > + *eptr = oldval; > + > + protect_end (mptr, magic); > + post_seq_barrier (smodel); > + > + return ret; > + } > +} > +#define DONE 1 > +#endif /* N == 16 */ > + > +#include "../../cas_n.c" > diff --git a/libatomic/config/s390/load_n.c b/libatomic/config/s390/load_n.c > new file mode 100644 > index 00000000000..335d2f8b2c3 > --- /dev/null > +++ b/libatomic/config/s390/load_n.c > @@ -0,0 +1,57 @@ > +/* Copyright (C) 2018-2023 Free Software Foundation, Inc. > + > + This file is part of the GNU Atomic Library (libatomic). > + > + Libatomic is free software; you can redistribute it and/or modify it > + under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY > + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + more details. > + > + Under Section 7 of GPL version 3, you are granted additional > + permissions described in the GCC Runtime Library Exception, version > + 3.1, as published by the Free Software Foundation. > + > + You should have received a copy of the GNU General Public License and > + a copy of the GCC Runtime Library Exception along with this program; > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > + . */ > + > +#include > + > + > +/* Analog to config/s390/exch_n.c. */ > + > +#if !DONE && N == 16 > +UTYPE > +SIZE(libat_load) (UTYPE *mptr, int smodel) > +{ > + if (!((uintptr_t)mptr & 0xf)) > + { > + return __atomic_load_n ((UTYPE *)__builtin_assume_aligned (mptr, 16), > + __ATOMIC_SEQ_CST); > + } > + else > + { > + UTYPE ret; > + UWORD magic; > + > + pre_seq_barrier (smodel); > + magic = protect_start (mptr); > + > + ret = *mptr; > + > + protect_end (mptr, magic); > + post_seq_barrier (smodel); > + > + return ret; > + } > +} > +#define DONE 1 > +#endif /* N == 16 */ > + > +#include "../../load_n.c" > diff --git a/libatomic/config/s390/store_n.c b/libatomic/config/s390/store_n.c > new file mode 100644 > index 00000000000..9e5b2b8213d > --- /dev/null > +++ b/libatomic/config/s390/store_n.c > @@ -0,0 +1,54 @@ > +/* Copyright (C) 2018-2023 Free Software Foundation, Inc. > + > + This file is part of the GNU Atomic Library (libatomic). > + > + Libatomic is free software; you can redistribute it and/or modify it > + under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY > + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS > + FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + more details. > + > + Under Section 7 of GPL version 3, you are granted additional > + permissions described in the GCC Runtime Library Exception, version > + 3.1, as published by the Free Software Foundation. > + > + You should have received a copy of the GNU General Public License and > + a copy of the GCC Runtime Library Exception along with this program; > + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see > + . */ > + > +#include > + > + > +/* Analog to config/s390/exch_n.c. */ > + > +#if !DONE && N == 16 > +void > +SIZE(libat_store) (UTYPE *mptr, UTYPE newval, int smodel) > +{ > + if (!((uintptr_t)mptr & 0xf)) > + { > + __atomic_store_n ((UTYPE *)__builtin_assume_aligned (mptr, 16), newval, > + __ATOMIC_SEQ_CST); > + } > + else > + { > + UWORD magic; > + > + pre_seq_barrier (smodel); > + magic = protect_start (mptr); > + > + *mptr = newval; > + > + protect_end (mptr, magic); > + post_seq_barrier (smodel); > + } > +} > +#define DONE 1 > +#endif /* N == 16 */ > + > +#include "../../store_n.c"