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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82445C43334 for ; Tue, 12 Jul 2022 19:25:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED3C29400CC; Tue, 12 Jul 2022 15:25:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E8417940063; Tue, 12 Jul 2022 15:25:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4C449400CC; Tue, 12 Jul 2022 15:25:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C3736940063 for ; Tue, 12 Jul 2022 15:25:52 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 9094180658 for ; Tue, 12 Jul 2022 19:25:52 +0000 (UTC) X-FDA: 79679427744.16.7EF3481 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf20.hostedemail.com (Postfix) with ESMTP id E0E181C0099 for ; Tue, 12 Jul 2022 19:25:51 +0000 (UTC) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26CIBY6g011538; Tue, 12 Jul 2022 19:25:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=JNm0MlW2oldiXzH8OZltzuwYoPN4K2DhqBcxukdMHf0=; b=riyo6TLjsh9II/R03nIRtsQGM3FALLUp8EE2I9pS1PVvy/vXylGO20YruTXHYcdJ5bUB 2kissBqqgydFUM84HZEQAtt8d1pZ/f8ZInWZy0kloWLJ9Mpi/LFgE8zaUdrv4NowqjBf sKAQO9r1g7Z4CD99n87GKtCJiuvj4wKk9Scr1zXK7HDWeuTJQT+XedMx4R7N20jVw0Cw LZaclhnWUlmdKlLwQPfGMIWmP0qXsz7W+17Yvi1wiN0RmKFuimOXSNZT/UcnyOzsdw25 jsIb9t26Liy7jXg/klYsrTkgkhm3iFg2pOCRB92c/xg0GEjrD2NIbc63d4enpj6lpwPi +A== 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 3h9akqygsg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 19:25:50 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26CJK8cp015029; Tue, 12 Jul 2022 19:25:49 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06ams.nl.ibm.com with ESMTP id 3h70xhvm6r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 19:25:48 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26CJPjHm20250944 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Jul 2022 19:25:45 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1DAA42041; Tue, 12 Jul 2022 19:25:45 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4AF0842042; Tue, 12 Jul 2022 19:25:45 +0000 (GMT) Received: from osiris (unknown [9.145.52.105]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 12 Jul 2022 19:25:45 +0000 (GMT) Date: Tue, 12 Jul 2022 21:25:43 +0200 From: Heiko Carstens To: Steffen Eiden Cc: Alexander Gordeev , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Vasily Gorbik , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, nrb@linux.ibm.com Subject: Re: [PATCH 1/3] s390/cpufeature: rework to allow more than only hwcap bits Message-ID: References: <20220712105220.325010-1-seiden@linux.ibm.com> <20220712105220.325010-2-seiden@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220712105220.325010-2-seiden@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: rwykUcAM1w7sDQCPFMPMFACMf6XXEAsK X-Proofpoint-GUID: rwykUcAM1w7sDQCPFMPMFACMf6XXEAsK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-12_12,2022-07-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=923 malwarescore=0 mlxscore=0 impostorscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 clxscore=1015 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207120077 ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=riyo6TLj; spf=pass (imf20.hostedemail.com: domain of hca@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=hca@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657653952; a=rsa-sha256; cv=none; b=jOpbWBDjqcpaSF3XAYqTUuUyL6Hih6WLotlgm1b71ws0TPdQW2/7ZaK7MWTmE4WFJwBlxb jDC+RSLhkq397X/KEHEi1naJ2FL+B0AhiTxee3f/50elh5icSGrWs2nzeHd8M2A8zYlNfw Lmr1JmiWElya+aUer2aoidy/f90nXnQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657653952; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=JNm0MlW2oldiXzH8OZltzuwYoPN4K2DhqBcxukdMHf0=; b=DJqqPToLri3Dyne443hFUV2R1bdV4trxApGHBtUITfCPaGG0J4x5nQMRYuGJriVGqvxzG1 7yq7O28fttBs4zvQFI2EvZ8f2Y25s6dF0rq1j7NQhApnv2K6sWd21FuQ+luDF0Fy+ZWEiM YdbvMUfFrNZ2+E5AMX3y73c5rq8n3u0= Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=riyo6TLj; spf=pass (imf20.hostedemail.com: domain of hca@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=hca@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Stat-Signature: 9do338t6kcf6dprjco7tmnixjd3abs9m X-Rspamd-Queue-Id: E0E181C0099 X-HE-Tag: 1657653951-949008 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Jul 12, 2022 at 12:52:18PM +0200, Steffen Eiden wrote: > Rework cpufeature implementation to allow for various cpu feature > indications, which is not only limited to hwcap bits. This is achieved > by adding a sequential list of cpu feature numbers, where each of them > is mapped to an entry which indicates what this number is about. > > Each entry contains a type member, which indicates what feature > name space to look into (e.g. hwcap, or cpu facility). If wanted this > allows also to automatically load modules only in e.g. z/VM > configurations. > > Signed-off-by: Steffen Eiden > Signed-off-by: Heiko Carstens ... > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright IBM Corp. 2022 > + * Author(s): Steffen Eiden > + * Heiko Carstens Please don't add my name + email address in source code. I just recently removed that everywhere since email addresses may change, and git history is more than enough for me. It's up to you if you want to keep your name + email address here. > +static struct s390_cpu_feature s390_cpu_features[MAX_CPU_FEATURES] = { > + [S390_CPU_FEATURE_ESAN3] = {.type = TYPE_HWCAP, .num = HWCAP_NR_ESAN3}, > + [S390_CPU_FEATURE_ZARCH] = {.type = TYPE_HWCAP, .num = HWCAP_NR_ZARCH}, > + [S390_CPU_FEATURE_STFLE] = {.type = TYPE_HWCAP, .num = HWCAP_NR_STFLE}, > + [S390_CPU_FEATURE_MSA] = {.type = TYPE_HWCAP, .num = HWCAP_NR_MSA}, > + [S390_CPU_FEATURE_LDISP] = {.type = TYPE_HWCAP, .num = HWCAP_NR_LDISP}, > + [S390_CPU_FEATURE_EIMM] = {.type = TYPE_HWCAP, .num = HWCAP_NR_EIMM}, > + [S390_CPU_FEATURE_DFP] = {.type = TYPE_HWCAP, .num = HWCAP_NR_DFP}, > + [S390_CPU_FEATURE_HPAGE] = {.type = TYPE_HWCAP, .num = HWCAP_NR_HPAGE}, > + [S390_CPU_FEATURE_ETF3EH] = {.type = TYPE_HWCAP, .num = HWCAP_NR_ETF3EH}, > + [S390_CPU_FEATURE_HIGH_GPRS] = {.type = TYPE_HWCAP, .num = HWCAP_NR_HIGH_GPRS}, > + [S390_CPU_FEATURE_TE] = {.type = TYPE_HWCAP, .num = HWCAP_NR_TE}, > + [S390_CPU_FEATURE_VXRS] = {.type = TYPE_HWCAP, .num = HWCAP_NR_VXRS}, > + [S390_CPU_FEATURE_VXRS_BCD] = {.type = TYPE_HWCAP, .num = HWCAP_NR_VXRS_BCD}, > + [S390_CPU_FEATURE_VXRS_EXT] = {.type = TYPE_HWCAP, .num = HWCAP_NR_VXRS_EXT}, > + [S390_CPU_FEATURE_GS] = {.type = TYPE_HWCAP, .num = HWCAP_NR_GS}, > + [S390_CPU_FEATURE_VXRS_EXT2] = {.type = TYPE_HWCAP, .num = HWCAP_NR_VXRS_EXT2}, > + [S390_CPU_FEATURE_VXRS_PDE] = {.type = TYPE_HWCAP, .num = HWCAP_NR_VXRS_PDE}, > + [S390_CPU_FEATURE_SORT] = {.type = TYPE_HWCAP, .num = HWCAP_NR_SORT}, > + [S390_CPU_FEATURE_DFLT] = {.type = TYPE_HWCAP, .num = HWCAP_NR_DFLT}, > + [S390_CPU_FEATURE_VXRS_PDE2] = {.type = TYPE_HWCAP, .num = HWCAP_NR_VXRS_PDE2}, > + [S390_CPU_FEATURE_NNPA] = {.type = TYPE_HWCAP, .num = HWCAP_NR_NNPA}, > + [S390_CPU_FEATURE_PCI_MIO] = {.type = TYPE_HWCAP, .num = HWCAP_NR_PCI_MIO}, > + [S390_CPU_FEATURE_SIE] = {.type = TYPE_HWCAP, .num = HWCAP_NR_SIE}, > +}; I only realized now that you added all HWCAP bits here. It was intentional that I added only the two bits which are currently used for several reasons: - Keep the array as small as possible. - No need to keep this array in sync with HWCAPs, if new ones are added. - There is a for loop in print_cpu_modalias() which iterates over all MAX_CPU_FEATURES entries; this should be as fast as possible. Adding extra entries burns cycles for no added value. Any future user which requires a not yet listed feature, can simply add it when needed. > +int cpu_have_feature(unsigned int num) > +{ > + struct s390_cpu_feature *feature; > + > + feature = &s390_cpu_features[num]; > + switch (feature->type) { > + case TYPE_HWCAP: > + return !!(elf_hwcap & (1UL << feature->num)); Before somebody else mentions it, I could have done better. Nowadays this should be: return !!(elf_hwcap & BIT(feature->num));