From patchwork Tue Dec 5 17:32:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 174149 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3589993vqy; Tue, 5 Dec 2023 09:33:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuZTPWUjwiFAo/vLkHFEWfNg3/onbzVvf0+QFb/e4xNppO8Y2M3FIfir0il86V3az+aApc X-Received: by 2002:a17:902:ee44:b0:1d0:700b:3f6a with SMTP id 4-20020a170902ee4400b001d0700b3f6amr1972439plo.36.1701797622855; Tue, 05 Dec 2023 09:33:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701797622; cv=none; d=google.com; s=arc-20160816; b=zRSyZ6jGGCldFvNOeXtcwW6Md3u2R81tO1Y9DBaDzWQkx6s8Y4G35mGocudD6JuhmZ 52awubOpaiYyYRisAxRj3b/8K2DN73yo9GuUBBPmbj7U9WJ0U2bQIgutMPLpGaXoZRpL Co6PVIhVALIDYF6VRvL+HNqNfjdEIfjtg0wwZDifmqsx2ISUEZOkB05a/2SnIACqjVZI YlhkouSVT625I1quaZbR2khlvN4z0spPVGRlq1Jx0aQ6pFFcC4vydiZ9ovsdqvzAnoiZ 9HuCcoSTALlO5LUfDEyQFkfcQdRPQGig/RoHbKa2Xv+KKY9PeFAQ5FP39L8qlhQsnUDd GbYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=MVbiPS6Os17Ey72kOOBZe4mf8N0Z9v7CVaiY4fv9F04=; fh=yuo0OclYCKDLxOy9jD+jp1us/WknRipSacep1mttrRM=; b=ILQMsmBJPghjm5fiDJMrUdQrugdiFJ6P4JchobvUFjJS5BihV7hWOFiCo6h1yWHTNb rcHnYcQJO+KxisoR7J/vj95QvA7S4qDbWR1Qy202UqHokdqW8b5DSla8mtPxSt6nPgic hiu4OtQTR6+89hAjtl2W1BdBcwxw++itZP+kXu2+MDjiLMitbv/VrGe40ASb3vw8/y/K 769+/2sAq9qzawI5soCn+vKRlMl78iC3i+HHAwa4xcET8BPIFiLogc6ljmUME0DJJmgC HVHsarV6l1Kgrf8ikbEYv5ZGIPgRVjAqLbbytB38TtSz/9HnrAdCvjl7i7jzSlQ1MEUD UATw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=e1vAl1Mc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id jm1-20020a17090304c100b001d07d6916f4si5201834plb.592.2023.12.05.09.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 09:33:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=e1vAl1Mc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D588E80A8DB7; Tue, 5 Dec 2023 09:33:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346112AbjLERc4 (ORCPT + 99 others); Tue, 5 Dec 2023 12:32:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232240AbjLERcz (ORCPT ); Tue, 5 Dec 2023 12:32:55 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B802618D; Tue, 5 Dec 2023 09:33:01 -0800 (PST) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3B5HRGHP023959; Tue, 5 Dec 2023 17:33:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=MVbiPS6Os17Ey72kOOBZe4mf8N0Z9v7CVaiY4fv9F04=; b=e1vAl1McWYuGDnShw/HwQwMHU48CnTMe15Iig9/p4ALO7NHLs4+mX28zb+1OGgOFxK4m 8tNluXFTRwofkEgyWLjSSgVxSYdhNOkVIoYDWrk1tRWX6fuH4RyGzewiRPYQS8jHGz05 59GP2mtfp4fRSFls5jcFP+dAHafwS4DqzbzCWj1F5Als4d+Dmu2z03HI8jmZhM+dM6zS dPSiivR/MSrjtwzMmcDRQbLALfCEGLvBY0sbkzdwDm9ZvLxxje/2d8aa5GwPc4HPrv2C iX63cm2IkGrHcsnAbrWesgI4JdWHrWTrGI1D4aFL5W7BtGAUqCDVSsMfqEdYwGzPQR6F Sw== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ut896r5cs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 Dec 2023 17:33:01 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3B5GfFXs000927; Tue, 5 Dec 2023 17:33:00 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3urewtgay6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 Dec 2023 17:33:00 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3B5HWqsT17105436 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 Dec 2023 17:32:52 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0E5620043; Tue, 5 Dec 2023 17:32:52 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C78B2004B; Tue, 5 Dec 2023 17:32:52 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.66]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 5 Dec 2023 17:32:52 +0000 (GMT) From: Claudio Imbrenda To: linux-kernel@vger.kernel.org Cc: linux-s390@vger.kernel.org, linux390-list@tuxmaker.boeblingen.de.ibm.com, kvm390-list@tuxmaker.boeblingen.de.ibm.com, hca@linux.ibm.com, borntraeger@de.ibm.com, frankja@linux.ibm.com, nrb@linux.ibm.com, nsg@linux.ibm.com, svens@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com Subject: [PATCH v1 1/1] s390: mm: convert pgste locking functions to C Date: Tue, 5 Dec 2023 18:32:52 +0100 Message-ID: <20231205173252.62305-1-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: BJkgwvXplodQTkKRLbAtdTM0yCZVkiXT X-Proofpoint-GUID: BJkgwvXplodQTkKRLbAtdTM0yCZVkiXT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-05_12,2023-12-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 mlxscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxlogscore=373 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2312050139 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 05 Dec 2023 09:33:05 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784464144187202305 X-GMAIL-MSGID: 1784464144187202305 Convert pgste_get_lock() and pgste_set_unlock() to C. There is no real reasons to keep them in assembler. Having them in C makes them more readable and maintainable, and better instructions are used automatically when available. Signed-off-by: Claudio Imbrenda Reviewed-by: Heiko Carstens Acked-by: Alexander Gordeev --- arch/s390/mm/pgtable.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 3bd2ab2a9a34..6c4523aa4fdf 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -125,32 +125,23 @@ static inline pte_t ptep_flush_lazy(struct mm_struct *mm, static inline pgste_t pgste_get_lock(pte_t *ptep) { - unsigned long new = 0; + unsigned long value = 0; #ifdef CONFIG_PGSTE - unsigned long old; - - asm( - " lg %0,%2\n" - "0: lgr %1,%0\n" - " nihh %0,0xff7f\n" /* clear PCL bit in old */ - " oihh %1,0x0080\n" /* set PCL bit in new */ - " csg %0,%1,%2\n" - " jl 0b\n" - : "=&d" (old), "=&d" (new), "=Q" (ptep[PTRS_PER_PTE]) - : "Q" (ptep[PTRS_PER_PTE]) : "cc", "memory"); + unsigned long *ptr = (unsigned long *)(ptep + PTRS_PER_PTE); + + do { + value = __atomic64_or_barrier(PGSTE_PCL_BIT, ptr); + } while (value & PGSTE_PCL_BIT); + value |= PGSTE_PCL_BIT; #endif - return __pgste(new); + return __pgste(value); } static inline void pgste_set_unlock(pte_t *ptep, pgste_t pgste) { #ifdef CONFIG_PGSTE - asm( - " nihh %1,0xff7f\n" /* clear PCL bit */ - " stg %1,%0\n" - : "=Q" (ptep[PTRS_PER_PTE]) - : "d" (pgste_val(pgste)), "Q" (ptep[PTRS_PER_PTE]) - : "cc", "memory"); + barrier(); + WRITE_ONCE(*(unsigned long *)(ptep + PTRS_PER_PTE), pgste_val(pgste) & ~PGSTE_PCL_BIT); #endif }