From patchwork Wed Jun 28 18:52:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric DeVolder X-Patchwork-Id: 114003 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9139773vqr; Wed, 28 Jun 2023 11:56:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZVvgAVJEfTKq79Vmg1ZIQtzgCRbASbQ3AJc9/PDR8ogeJmSSN0/74mhbmEd2WEdqdvqlg X-Received: by 2002:a05:6a20:244c:b0:11b:3e33:d2f3 with SMTP id t12-20020a056a20244c00b0011b3e33d2f3mr43924652pzc.0.1687978619011; Wed, 28 Jun 2023 11:56:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687978618; cv=pass; d=google.com; s=arc-20160816; b=qfIhKTlbV93BsLE6QVu6Lq3d7pP53Ol9WkEnTiyWCrYq1FOeWHtrT1Ng9M6ND4KelA 5I/m1ZjMClsqupL9mMr5UePCKP3vUbo1pf56RXaSlg8UsgoMKwlQ+BPkKoJUT1LxGP0V rdcKTusJSrDPDiFD/bUNLaA9RoB/h6C5/GWaOJHNzug5dJ4JQ2a9q1A8+Z8+QY4S3us5 rqdkfYYViEBVwevRQOYei6cJjJ1KYC/Q0J8GlPW/uDRbAgNWfxXEK1h0d/GvIAET4YbN YyP1CVLU0L2sLUXm4BOaiBYzNIyY4QTsdnWApmx7uVmSmd8X72mJbBrIGIeXWVMQKzKl PIRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=Nlp/oHypkgqILKUkxsjCRnUeHefJfb6/VFa3Fe0IQP4=; fh=j+K5GuuLTbxxisV+wJRNZBqbr6zhGMwAghI8ANXi4rw=; b=J4u1rrJlBd6hGylCop1k1cpMlt/J/4d2w0OvRPT10F6Mf4xjqv+cToJqI8j3WP1nTn 06eMcRyAWvI3q6acRXYSEfFwYiGjX7qXA+38j/TGlTNzT//1w87PnollbFpjXLNReYnT 5BUENH7RtF5ofJBAgwuk/pqC7zd20jlObbxunomcc8iMryuJ1f+Hh7Dysz0ycFTsL57/ 4ei0JEhe58t9VUs0vhAr4LqoNZGHu6Ag+Z0tMr0l7TdFyJU2I/SEqBIpI3+C404FPB4O wvQr3ivqnSrIJDsLK97+Hzbr9NXI/vgx7zzbDSvcAHD8O/2fS1ee7yxaZ/Fy37Qd9SN9 Djaw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=wEDojz5E; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GA8eWVcf; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fi30-20020a056a00399e00b0064d533abfd4si9530072pfb.189.2023.06.28.11.56.45; Wed, 28 Jun 2023 11:56:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=wEDojz5E; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=GA8eWVcf; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231346AbjF1SxT (ORCPT + 99 others); Wed, 28 Jun 2023 14:53:19 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:37092 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231916AbjF1SxQ (ORCPT ); Wed, 28 Jun 2023 14:53:16 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35SGwlru011815; Wed, 28 Jun 2023 18:52:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=Nlp/oHypkgqILKUkxsjCRnUeHefJfb6/VFa3Fe0IQP4=; b=wEDojz5EXTZD9bYL4oDmK+Z6WGFb+A3H/lYaWc0gt7UOV6qavrq/dwQqz+GP4TWJ2z9/ im4MwaWaj8UFfo/TJvsSL05l76dRtgEIDitmpbAh7ksD58YPStLAonWbB1Lnu9BFry+u CBMvs9eSUK6Wrw5IUJdmKD7W0wqByOh3fQM4XM1czBi630Q+kaeYcy59yDRnFgii1YGW 7JGHSVfMSg/lQELXhuvghz69cQaC77kvmwVKcisMMOPTf15PrfUZMR0LN+vMDBuGlqIu qpUh1qWzCKHZ4REeX0/EQsdqB9GLTWhghrNPxYzavIEcSaQDr1ge6VMXMImYeo8H5kR+ nQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq938me7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:34 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35SIAF0N019910; Wed, 28 Jun 2023 18:52:33 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2107.outbound.protection.outlook.com [104.47.58.107]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxc6cs4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jun 2023 18:52:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hRBaetnxKKQp16askjhdKNsw/z5/+vPpD/4818cWZo7tEFkP58IJMuGp4xOJPNoVT06k3YwSZYAS+YwZ0xEuni2umvGCYlnDBsHAoEgvlh6WzYdQo7XW3tWmQi3CH7gS0OeYKvLXXdU5fChUZ7AHYYY1f0uM0x0Y4R9l4CluNm3uHKfNwsksFtg+BSEZMvbp+QUQ6MwhcPZrg0tukBAt7Q4DXLpG9mNKpMgedWJeNXEG1XMSqyGBxH+nEJhNISMugEXii3Jj4I201ibVkc6X11jHaiQcn9B1HaJ/hbHZohR+qDTIsNqxnfV84JuTtXWaK3UTGkcdo5AfMVQ9vmfnJQ== 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=Nlp/oHypkgqILKUkxsjCRnUeHefJfb6/VFa3Fe0IQP4=; b=PmNdQ/ThdzVQfNdxP3VWOOeK4j7Ic2xEDc05r2NuFrU0GBn5vp6k245Py+CGbP0mgtzBQx8oZELXQM7xEn3SGLriEtDb9EOG4oOQkI+HLk8PD8z1BlpIiCE+JvYj3slCE4D1yEle/QzpKu0+mwAKNtecTRlItGa3HAwYn6xawxIKM9BnqcwgTyu9hZpWxPiHpYsJAs5rKIiNZVjTP0LCZB9e1S+9QbXaeCb1f8n1RXy4ERlpy/mOxm526/y43GETLziYT0LTsN1N9juFPahVDYxM1EIaNPBJ3HEoz2tFzrhyWYjv4m4Y3mE4gpbWRHxEuW7zJeE5ofcspzsQTcG4Gw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Nlp/oHypkgqILKUkxsjCRnUeHefJfb6/VFa3Fe0IQP4=; b=GA8eWVcfriY0UOBZC8Lz6w6JmCn78MsjrtwVmoayL7Gz33cLfUqjZA3kykZHn+IHAHjacWQyEQZ4UTbYSbFyvCJuEfefI42/ZCTOu85S2DgP1TDJQtFPoHnoxwqP6v6w6y/fyvd/0k6ffwLK0n1dS2yb/rLk3OotTHF9VK0nADE= Received: from CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) by LV3PR10MB7820.namprd10.prod.outlook.com (2603:10b6:408:1b4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Wed, 28 Jun 2023 18:52:30 +0000 Received: from CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048]) by CO1PR10MB4531.namprd10.prod.outlook.com ([fe80::8b8f:b4b1:bb78:b048%5]) with mapi id 15.20.6521.024; Wed, 28 Jun 2023 18:52:30 +0000 From: Eric DeVolder To: linux-kernel@vger.kernel.org, david@redhat.com, osalvador@suse.de, corbet@lwn.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, bhe@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org Cc: hpa@zytor.com, gregkh@linuxfoundation.org, rafael@kernel.org, vgoyal@redhat.com, dyoung@redhat.com, lf32.dev@gmail.com, akpm@linux-foundation.org, naveen.n.rao@linux.vnet.ibm.com, zohar@linux.ibm.com, bhelgaas@google.com, vbabka@suse.cz, tiwai@suse.de, seanjc@google.com, linux@weissschuh.net, vschneid@redhat.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, sourabhjain@linux.ibm.com, konrad.wilk@oracle.com, boris.ostrovsky@oracle.com, eric.devolder@oracle.com Subject: [PATCH v24 02/10] drivers/base: refactor memory.c to use .is_visible() Date: Wed, 28 Jun 2023 14:52:07 -0400 Message-Id: <20230628185215.40707-3-eric.devolder@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628185215.40707-1-eric.devolder@oracle.com> References: <20230628185215.40707-1-eric.devolder@oracle.com> X-ClientProxiedBy: SN7PR18CA0026.namprd18.prod.outlook.com (2603:10b6:806:f3::18) To CO1PR10MB4531.namprd10.prod.outlook.com (2603:10b6:303:6c::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR10MB4531:EE_|LV3PR10MB7820:EE_ X-MS-Office365-Filtering-Correlation-Id: 31af01ab-f988-47d9-40d3-08db7808d343 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZY0pl8kacdguKCc6ErHusyUYZHjwavz/+DZ6xiuj4hZ57L6LVnqNLRDjaKgezJcaShFI09xDvPAJisV6j7cBfWS/2GoxK6OeVNeceTHxhIyivKceicC6/2vOHjD5x9yLRspRRNbTeZl/iixzTZbpY7LWrRHjsPMVimHbsRiwaee24nG5clyMeAxCgYP06GGY6vD8OJXPc+HR+KHHG62aov4+HtIzGe2w+elgTQEyqeDY3Z0GfVr/tngs1gkX12F9km/2GLvGLva4xi8/mch/QeHvVAdN8AQPa6IDwOt/SYOpWY7T6Tq+ib78tWWb9YONCVEJfwJYn2foOzGyApUHvwJhs6lMMYydrbz5rXVOfqyTbZcEMp3fG7RH+5hreC42AOzLXf/1+UmJKncvVEwYa9dTazYPhgYVEck9hOU1KXLcZxCAYZY67COu3fp9JdkJwBY/Tz8Ekq+3mqiOvMRUdyp2xE9+t4KnvbzHNWdU3ejGnyJwrsDe1d9bih/iSqfnzhwcJQGfdqvQblQ/pmEz2pA7xyE3Ua64ncwFQ3peGaUP+qZ6PlJ+Qbpuf0rqj0GgPK7gTnybOwNsTx1whgj3ZI/PNC7Nvl4m0c+XJwLWWs0HpM6OUea0MO74wVd5dw6S X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR10MB4531.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(396003)(366004)(346002)(39860400002)(136003)(451199021)(2906002)(83380400001)(316002)(26005)(6506007)(6512007)(1076003)(6666004)(6486002)(186003)(478600001)(86362001)(107886003)(921005)(2616005)(66476007)(41300700001)(8936002)(7406005)(7416002)(4326008)(66556008)(66946007)(8676002)(36756003)(38100700002)(5660300002)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 34tY1uLMlIKWQ3svrmqUzGTts3kIr6IrckEWIAw6shL6QMPzHCpSnT1aC+kDv+0WNuhJ29rbGHerWR1sVb9Pxbji0ZAxMVb4zgP22VUhAiEy6uPXVF9AaB/Jc1DErMz1z8pJQmBH/Ur6CioYDq6OpQ6SpTYQwy+yus2xhtH8ltY4NQbFq/UOKZx3TgOASORncOFs2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mLNZirFhDfx3+o4mK5L42Q8MnJL4490zyMwF8IgxJgXuaZvtv97rxi30zziNp674ScjaTPbKP6nA4imTYr/PPl1OuRDJxojNdEUaJek4JPhBzh4zoJJzeOgM63RCTHejlsoOxt1wJiJjgR4SUreydr4k9c3hLqjZWD1IQmEJ5OMpjmPRdPEuvOTlth5rscGTrHhN+QvUJtCXS37xXHAx9SwDA1V85ITsl368sy25u9mq/6wFOMRjysbvWvjqH4DDXlnvFg6CPp5DwpaTptDL5AjhG2v8lXjATcfzGOiJczyFNu43tVjhYgOjuV8Swz6EoIW2kajMZ73Y4Lei7TOCkD+aZmQyLvTAjtEV1hu5ogC2iHbIJ6Wn9nHA+mbjRStffmXGo3PVjhVlWQ6hnvXXxfvjA1HV26FZwERkvviiqyNaDjDSLvN/7OLY2FPC1P/odxSVyCwjFC2+N55G8UQ4WqdHwhNTNsN5V72J9x9wpdlcK5E3ycuBRqabwMnU2CBOsyjLNMRf1mD6zD77OGRBG+hmYDmDRPzi/WD7e8Za7tKIqUIAxk/WHhF4nGNtSrg32cR3ZZeKmLTrVRRoYb+8gtFhPk8P9bUKvabi74hr2KlY9dETN5YAx+yNosvOROcPZU0vkDAwGFLDVPhJuuY8T+6ArvHpTMUCoA8LZz61YOnqVYGOKgGx5+ZKPLZ2WPalUfL4UQ0FO/fvuwopj7LEOQNPu7viUZgpfcNinSxnWSXc6HQyr51Iv9YpK0LleEYbquRnRC4jSNmOtHUAggD4UqpMgUGqr7tM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 31af01ab-f988-47d9-40d3-08db7808d343 X-MS-Exchange-CrossTenant-AuthSource: CO1PR10MB4531.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 18:52:30.4452 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GeboyiBjZ05uQafzkaxyon6u7g6sRF5T2XOSWdWAc21AAb1JcyA8UGYQv67XOHBXUCXBEJhne9hRm6zj+jYIHuNh2/3K5WBsTh/QqdmXCgw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB7820 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-28_13,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306280168 X-Proofpoint-ORIG-GUID: Z38sp8V1JUnGnibKTkDYpu9lWibXkn8Q X-Proofpoint-GUID: Z38sp8V1JUnGnibKTkDYpu9lWibXkn8Q Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769973868683101691?= X-GMAIL-MSGID: =?utf-8?q?1769973868683101691?= Greg Kroah-Hartman requested that this file use the .is_visible() method instead of #ifdefs for the attributes in memory.c. static struct attribute *memory_memblk_attrs[] = { &dev_attr_phys_index.attr, &dev_attr_state.attr, &dev_attr_phys_device.attr, &dev_attr_removable.attr, #ifdef CONFIG_MEMORY_HOTREMOVE &dev_attr_valid_zones.attr, #endif NULL }; and static struct attribute *memory_root_attrs[] = { #ifdef CONFIG_ARCH_MEMORY_PROBE &dev_attr_probe.attr, #endif #ifdef CONFIG_MEMORY_FAILURE &dev_attr_soft_offline_page.attr, &dev_attr_hard_offline_page.attr, #endif &dev_attr_block_size_bytes.attr, &dev_attr_auto_online_blocks.attr, NULL }; To that end: - the .is_visible() method is implemented, and IS_ENABLED(), rather than #ifdef, is used to determine the visibility of the attribute. - the DEVICE_ATTR_xx() attributes are moved outside of #ifdefs, so that those structs are always present for the memory_memblk_attrs[] and memory_root_attrs[]. - the #ifdefs guarding the attributes in the memory_memblk_attrs[] and memory_root_attrs[] are moved to the corresponding callback function; as the callback function must exist now that the attribute is always compiled-in (though not necessarily visible). No functionality change intended. Signed-off-by: Eric DeVolder --- drivers/base/memory.c | 78 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 13 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index b456ac213610..f03eda7e1c9c 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -405,10 +405,12 @@ static int print_allowed_zone(char *buf, int len, int nid, return sysfs_emit_at(buf, len, " %s", zone->name); } +#endif static ssize_t valid_zones_show(struct device *dev, struct device_attribute *attr, char *buf) { +#ifdef CONFIG_MEMORY_HOTREMOVE struct memory_block *mem = to_memory_block(dev); unsigned long start_pfn = section_nr_to_pfn(mem->start_section_nr); unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; @@ -444,9 +446,11 @@ static ssize_t valid_zones_show(struct device *dev, out: len += sysfs_emit_at(buf, len, "\n"); return len; +#else + return 0; +#endif } static DEVICE_ATTR_RO(valid_zones); -#endif static DEVICE_ATTR_RO(phys_index); static DEVICE_ATTR_RW(state); @@ -496,10 +500,10 @@ static DEVICE_ATTR_RW(auto_online_blocks); * as well as ppc64 will do all of their discovery in userspace * and will require this interface. */ -#ifdef CONFIG_ARCH_MEMORY_PROBE static ssize_t probe_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { +#ifdef CONFIG_ARCH_MEMORY_PROBE u64 phys_addr; int nid, ret; unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block; @@ -527,12 +531,13 @@ static ssize_t probe_store(struct device *dev, struct device_attribute *attr, out: unlock_device_hotplug(); return ret; +#else + return 0; +#endif } static DEVICE_ATTR_WO(probe); -#endif -#ifdef CONFIG_MEMORY_FAILURE /* * Support for offlining pages of memory */ @@ -542,6 +547,7 @@ static ssize_t soft_offline_page_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { +#ifdef CONFIG_MEMORY_FAILURE int ret; u64 pfn; if (!capable(CAP_SYS_ADMIN)) @@ -551,6 +557,9 @@ static ssize_t soft_offline_page_store(struct device *dev, pfn >>= PAGE_SHIFT; ret = soft_offline_page(pfn, 0); return ret == 0 ? count : ret; +#else + return 0; +#endif } /* Forcibly offline a page, including killing processes. */ @@ -558,6 +567,7 @@ static ssize_t hard_offline_page_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { +#ifdef CONFIG_MEMORY_FAILURE int ret; u64 pfn; if (!capable(CAP_SYS_ADMIN)) @@ -569,11 +579,13 @@ static ssize_t hard_offline_page_store(struct device *dev, if (ret == -EOPNOTSUPP) ret = 0; return ret ? ret : count; +#else + return 0; +#endif } static DEVICE_ATTR_WO(soft_offline_page); static DEVICE_ATTR_WO(hard_offline_page); -#endif /* See phys_device_show(). */ int __weak arch_get_memory_phys_device(unsigned long start_pfn) @@ -611,14 +623,35 @@ static struct attribute *memory_memblk_attrs[] = { &dev_attr_state.attr, &dev_attr_phys_device.attr, &dev_attr_removable.attr, -#ifdef CONFIG_MEMORY_HOTREMOVE &dev_attr_valid_zones.attr, -#endif NULL }; +static umode_t +memory_memblk_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int unused) +{ + umode_t mode = attr->mode; + + if (attr == &dev_attr_phys_index.attr) + return mode; + if (attr == &dev_attr_state.attr) + return mode; + if (attr == &dev_attr_phys_device.attr) + return mode; + if (attr == &dev_attr_removable.attr) + return mode; + if (IS_ENABLED(CONFIG_MEMORY_HOTREMOVE)) { + if (attr == &dev_attr_valid_zones.attr) + return mode; + } + + return 0; +} + static const struct attribute_group memory_memblk_attr_group = { .attrs = memory_memblk_attrs, + .is_visible = memory_memblk_attr_is_visible, }; static const struct attribute_group *memory_memblk_attr_groups[] = { @@ -878,22 +911,41 @@ void remove_memory_block_devices(unsigned long start, unsigned long size) } static struct attribute *memory_root_attrs[] = { -#ifdef CONFIG_ARCH_MEMORY_PROBE &dev_attr_probe.attr, -#endif - -#ifdef CONFIG_MEMORY_FAILURE &dev_attr_soft_offline_page.attr, &dev_attr_hard_offline_page.attr, -#endif - &dev_attr_block_size_bytes.attr, &dev_attr_auto_online_blocks.attr, NULL }; +static umode_t +memory_root_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int unused) +{ + umode_t mode = attr->mode; + + if (IS_ENABLED(CONFIG_ARCH_MEMORY_PROBE)) { + if (attr == &dev_attr_probe.attr) + return mode; + } + if (IS_ENABLED(CONFIG_MEMORY_FAILURE)) { + if (attr == &dev_attr_soft_offline_page.attr) + return mode; + if (attr == &dev_attr_hard_offline_page.attr) + return mode; + } + if (attr == &dev_attr_block_size_bytes.attr) + return mode; + if (attr == &dev_attr_auto_online_blocks.attr) + return mode; + + return 0; +} + static const struct attribute_group memory_root_attr_group = { .attrs = memory_root_attrs, + .is_visible = memory_root_attr_is_visible, }; static const struct attribute_group *memory_root_attr_groups[] = {