Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5287993ybb; Tue, 24 Mar 2020 14:32:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtr03rRx1dWA2MR9vT//dM7ngJ319+nH2OLd7Y763d/bxv1AAt6dSoFM1BSVObxOnV6xbAv X-Received: by 2002:aca:d68e:: with SMTP id n136mr228066oig.103.1585085528050; Tue, 24 Mar 2020 14:32:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585085528; cv=none; d=google.com; s=arc-20160816; b=xg2QtImkbJwaXj3R9ejxKrJ6y1bJiAlYNx3Yoa2DdirHNkGpjfMIQvN/x4BaP7WetS A6PzDMxiMQWE9xOnCgoouRGUTft2sFRWvBghkWwhbgjxky+40EQREsM6Gonid0s4WNfe kirZIeOHbf1AXmLwXu8euj+VoqdF9IFgx8SZYx9bLcctyDebh0q1h/pvUTup4wmlEJ/F soQoh5i2YRiHLLnSriQFeKjNyO0kdJ+MlQUQH3LzCWjpTvxe6T2SUUvSeWaX1nSxnbAT XHE0vkuGqTWqvPb1egFAxyXAecv4+J2Rn1T8q9ptNdv1G3rRUpcM8LZCS6vuRm+2t3f3 bvzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:date:message-id:from :references:cc:to:subject:dkim-signature; bh=yjVJersXVqbrRLg88fDfyrB3yVDE5LyqcnA1q1agUfc=; b=RtCS8LMgyy8jqqT9KjjCJhTn54ygUt5iOamPhqwS0jncyZ9N8YqwsbVinPPjVA5i4m 5LAZTsShMI6xPlu6q87JFhbuRGB88TICoIo2nw35vQv7S7JWk0wIPS7LJeYHUw4fMO25 epaiULNEO0QYpGNfrV0izU+QKYspXlJwdp4+TV2JbUkSsijXsBFlRey+E2NgmXh/rLNg 8DfL6D9nTQG/V+kCyv6sMoSqsCRu0vtIQ20Kbexe/9akHjkPQWd9ukXrVhq4rYB+p+Nl FLWjhoyJmWRmFz2Kmi9UvC0drK2AZXUU0Vc+1UtJeFvs3u32B1Prps2Bov+rAR+Vm6gn dncw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=HGfgC4P9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n125si3020470oib.97.2020.03.24.14.31.53; Tue, 24 Mar 2020 14:32:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=HGfgC4P9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727937AbgCXVbX (ORCPT + 99 others); Tue, 24 Mar 2020 17:31:23 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55144 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727270AbgCXVbX (ORCPT ); Tue, 24 Mar 2020 17:31:23 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02OLJBA3072086; Tue, 24 Mar 2020 21:31:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=yjVJersXVqbrRLg88fDfyrB3yVDE5LyqcnA1q1agUfc=; b=HGfgC4P9RWmuz1rfq1u8B0qDO1FAIlYu+QZNu+4U7xSoLNJZ5h4+05y5Bj+Gnm1eg9Xf dVxfNNo4Fq1LwtirCiitxISCWmUYuwMIGb1o8fQqAHgXB8+AhtQdRY+zj7lsDuZ13BA4 /XCLUYFUlEf3Efzftpsr/yok/E1NteuBwK5lzVMhq9aQ8Yc4DDTdD5tKwvHqPTLdzPoZ 6f1obNFs5KZszKe1e6M7sko+1QOpptytRhLcDXrEXPhV33lLjIGcYotN9yJGtPzXpBe4 n/d+6Jn0pXxJE6aKRw4v0Bruxiz9nQbZkv0Aesb1Jq0uY+aM1YH1++OrpgFSN/WAHBsZ Dw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2ywabr6syn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Mar 2020 21:31:01 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02OLKYtc050217; Tue, 24 Mar 2020 21:31:00 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2yymbuexnn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Mar 2020 21:31:00 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02OLUnJc028150; Tue, 24 Mar 2020 21:30:55 GMT Received: from [192.168.1.67] (/94.61.1.144) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 24 Mar 2020 14:30:49 -0700 Subject: Re: [PATCH v2 6/6] ACPI: HMAT: Attach a device for each soft-reserved range To: Dan Williams Cc: Linux ACPI , Jonathan Cameron , Brice Goglin , Ard Biesheuvel , "Rafael J. Wysocki" , Catalin Marinas , Will Deacon , Peter Zijlstra , Dave Hansen , linux-nvdimm , Linux Kernel Mailing List , X86 ML References: <158489354353.1457606.8327903161927980740.stgit@dwillia2-desk3.amr.corp.intel.com> <158489357825.1457606.17352509511987748598.stgit@dwillia2-desk3.amr.corp.intel.com> From: Joao Martins Message-ID: Date: Tue, 24 Mar 2020 21:30:42 +0000 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9570 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=5 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003240107 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9570 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=5 lowpriorityscore=0 malwarescore=0 phishscore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003240107 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/24/20 9:06 PM, Dan Williams wrote: > On Tue, Mar 24, 2020 at 12:41 PM Joao Martins wrote: >> >> On 3/22/20 4:12 PM, Dan Williams wrote: >>> The hmem enabling in commit 'cf8741ac57ed ("ACPI: NUMA: HMAT: Register >>> "soft reserved" memory as an "hmem" device")' only registered ranges to >>> the hmem driver for each soft-reservation that also appeared in the >>> HMAT. While this is meant to encourage platform firmware to "do the >>> right thing" and publish an HMAT, the corollary is that platforms that >>> fail to publish an accurate HMAT will strand memory from Linux usage. >>> Additionally, the "efi_fake_mem" kernel command line option enabling >>> will strand memory by default without an HMAT. >>> >>> Arrange for "soft reserved" memory that goes unclaimed by HMAT entries >>> to be published as raw resource ranges for the hmem driver to consume. >>> >>> Include a module parameter to disable either this fallback behavior, or >>> the hmat enabling from creating hmem devices. The module parameter >>> requires the hmem device enabling to have unique name in the module >>> namespace: "device_hmem". >>> >>> Rather than mark this x86-only, include an interim phys_to_target_node() >>> implementation for arm64. >>> >>> Cc: Jonathan Cameron >>> Cc: Brice Goglin >>> Cc: Ard Biesheuvel >>> Cc: "Rafael J. Wysocki" >>> Cc: Jeff Moyer >>> Cc: Catalin Marinas >>> Cc: Will Deacon >>> Signed-off-by: Dan Williams >>> --- >>> arch/arm64/mm/numa.c | 13 +++++++++++++ >>> drivers/dax/Kconfig | 1 + >>> drivers/dax/hmem/Makefile | 3 ++- >>> drivers/dax/hmem/device.c | 33 +++++++++++++++++++++++++++++++++ >>> 4 files changed, 49 insertions(+), 1 deletion(-) >>> >> >> [...] >> >>> diff --git a/drivers/dax/hmem/device.c b/drivers/dax/hmem/device.c >>> index 99bc15a8b031..f9c5fa8b1880 100644 >>> --- a/drivers/dax/hmem/device.c >>> +++ b/drivers/dax/hmem/device.c >>> @@ -4,6 +4,9 @@ >>> #include >>> #include >>> >>> +static bool nohmem; >>> +module_param_named(disable, nohmem, bool, 0444); >>> + >>> void hmem_register_device(int target_nid, struct resource *r) >>> { >>> /* define a clean / non-busy resource for the platform device */ >>> @@ -16,6 +19,9 @@ void hmem_register_device(int target_nid, struct resource *r) >>> struct memregion_info info; >>> int rc, id; >>> >>> + if (nohmem) >>> + return; >>> + >>> rc = region_intersects(res.start, resource_size(&res), IORESOURCE_MEM, >>> IORES_DESC_SOFT_RESERVED); >>> if (rc != REGION_INTERSECTS) >>> @@ -62,3 +68,30 @@ void hmem_register_device(int target_nid, struct resource *r) >>> out_pdev: >>> memregion_free(id); >>> } >>> + >>> +static __init int hmem_register_one(struct resource *res, void *data) >>> +{ >>> + /* >>> + * If the resource is not a top-level resource it was already >>> + * assigned to a device by the HMAT parsing. >>> + */ >>> + if (res->parent != &iomem_resource) >>> + return 0; >>> + >>> + hmem_register_device(phys_to_target_node(res->start), res); >>> + >>> + return 0; >> >> Should we add an error returning value to hmem_register_device() perhaps this >> ought to be reflected in hmem_register_one(). >> >>> +} >>> + >>> +static __init int hmem_init(void) >>> +{ >>> + walk_iomem_res_desc(IORES_DESC_SOFT_RESERVED, >>> + IORESOURCE_MEM, 0, -1, NULL, hmem_register_one); >>> + return 0; >>> +} >>> + >> >> (...) and then perhaps here returning in the initcall if any of the resources >> failed hmem registration? > > Except that hmem_register_one() is a stop-gap to collect soft-reserved > ranges that were not already registered, and it's not an error to find > already registered devices. > /nods And if we were to return an error (say for hmem0 out of 4 hmem ones) before walking through all soft-reserved found resources, if would skip registration for the remaining ones. Joao