From patchwork Thu Mar 2 15:24:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schulze Frielinghaus X-Patchwork-Id: 63464 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp4293937wrd; Thu, 2 Mar 2023 07:28:16 -0800 (PST) X-Google-Smtp-Source: AK7set/VlHfBAfmKgJWyQzCngd5xqD+TEE7JioV8+XsmzTRhwrKYpbo5EKpHhkevTdXhMpWIvRxk X-Received: by 2002:a17:907:a49:b0:86c:a3ed:1442 with SMTP id be9-20020a1709070a4900b0086ca3ed1442mr14433235ejc.4.1677770895945; Thu, 02 Mar 2023 07:28:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677770895; cv=none; d=google.com; s=arc-20160816; b=yqgNw5h0RWcsKVAj9tKydG9xhA6htxxab/40J6qtf1J9lVEpheujQT1Tlpi+MhNOzI sx5WZPwZGoeIQpezorCQeZdOkYXsppjjlZSRxSJ2CiWDOfwvEUlQXjSbG10npPwDpV3n vXnGCcRAwpAnfh03U9qwgMtF/sSwpj/2s3U79f4RZGVFAZmPaqG4n3UU6baNnwPv0oAa hvR6lk2lMI92rw+GPHVrQ5iskVwrEG/X9WZMqaXPZP4MdkGF7SYwqW28LbHOR3wMgA20 99EdGRm2MFuzt992raHB3p0srTybxAK+kD//TC7Dl4bwLTl/Y2ZzeJtb9D7//gXigHEY E08g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:message-id:date:subject:cc:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=+v3ONVOUW0jtYgK/KTqlJk4chZKOWQuityYpZgaJt6U=; b=FL/c+87rUc2wOpLsXSTynB3dJY18ZqMpIeWJo7VHMvbLb+tojZd7mymH3IU371oyIa pEMgfDU3UCXRl2w19rp0EsrAhxYbiDA3+riSDGBMMlU5MeKhiBoklhtKOctk+ngnKyPQ 1u32P/l2977oIy/CNZPtllgeMFjoSFEEcSFp8fAIK5jSOZcBY5/cch3bNXpG9bP/4E5C gD+haNHMBz3on2OHF5qADWvKRfLIGW/3NciuA3gxTWc2RzCDXMEXpgKJpZewtO0MLLX2 CkkaiXB1SmoZd7utRg0Uk/uSz8k6u/KTfBVdzBZDbWkXaRhYl0g8Ld4zK+Rs+xGG7ElP gQcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pmbGDQso; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id hc44-20020a17090716ac00b008e416a5f36bsi22895995ejc.515.2023.03.02.07.28.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 07:28:15 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pmbGDQso; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D21B13858031 for ; Thu, 2 Mar 2023 15:28:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D21B13858031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677770888; bh=+v3ONVOUW0jtYgK/KTqlJk4chZKOWQuityYpZgaJt6U=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=pmbGDQso0138xzd2R7YRV1jov2cEQEXQZJlTw3i9tgg/h7E02jkt3WqWLkZS2lrOn VUEbFPzXNL75VtypO1jr4r8HhksyiMZaAog7QwI0OS+ZCNSorRgqXSk9Ksla3cqeGG 1CNQDilO3bLsnLQDWczdQzsGEeapW9xfN2u834VY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 7979D3858C5E for ; Thu, 2 Mar 2023 15:27:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7979D3858C5E Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 322E6ls4022198 for ; Thu, 2 Mar 2023 15:27:22 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2w96ajrp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 02 Mar 2023 15:27:21 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3226EP2L013020 for ; Thu, 2 Mar 2023 15:27:19 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3nybcq5ym3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 02 Mar 2023 15:27:19 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 322FRGju26345920 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Mar 2023 15:27:16 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 191E52004B; Thu, 2 Mar 2023 15:27:16 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E852E20040; Thu, 2 Mar 2023 15:27:15 +0000 (GMT) Received: from a8345010.lnxne.boe (unknown [9.152.108.100]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTPS; Thu, 2 Mar 2023 15:27:15 +0000 (GMT) To: krebbel@linux.ibm.com, gcc-patches@gcc.gnu.org Cc: Stefan Schulze Frielinghaus Subject: [PATCH] s390: libatomic: Fix 16 byte atomic {cas,load,store} Date: Thu, 2 Mar 2023 16:24:51 +0100 Message-Id: <20230302152450.1486452-1-stefansf@linux.ibm.com> X-Mailer: git-send-email 2.39.1 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _lLPob67e7AbNuLoX_zLPWaNu1mq4JFY X-Proofpoint-GUID: _lLPob67e7AbNuLoX_zLPWaNu1mq4JFY 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-02_08,2023-03-02_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 mlxlogscore=999 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303020130 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Stefan Schulze Frielinghaus via Gcc-patches From: Stefan Schulze Frielinghaus Reply-To: Stefan Schulze Frielinghaus Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759270295075072432?= X-GMAIL-MSGID: =?utf-8?q?1759270295075072432?= 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. --- 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"