Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4280990pxf; Tue, 30 Mar 2021 04:04:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh8jAB0ZEYCCTHS/W5mbjDmu2hlSNRiWyIWz4vyR5eHamcZx/ww0HyQ2RJi+OzPNdcCeE/ X-Received: by 2002:a50:8524:: with SMTP id 33mr33345201edr.110.1617102261705; Tue, 30 Mar 2021 04:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617102261; cv=none; d=google.com; s=arc-20160816; b=mwK3zWRbfBYRpR7g2vPMC05PCeeeC1tNLXNEnfZ/EdmUrRWnWdxbZzHThGDg6eREQ+ 1Lz6DwCHNPy5OlLA2x9K3XAXc8xb6xwSfNf7zBvVyK6Z4SGj69hZdfJPzkvIZhg6wk8f 8Gj5dbEQiXKyjjhhkK47yYMU2RqyyNuG3GSqUx7vkbF5025fyJ4N/ZWTJZf4iiry2Sot ANImFdp7XDo2k1xYrLWuFbRs09v1kzwX3xfXxqi2N63ciVU4+ZZKU42lKmC7VRyDPx8S HIn1OcqlYXE2l5hNjHbfnG8nbsr+Q55CkBBAoinJdaJU242X49fu36WoGw37wsPW17/T MBUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=om4kXnc6pLolT/LnZcgl5vqCg2/CTpifzvCZklyOw3g=; b=AbVy5N3xnvVL3ZjV3PuiAjKOauTH5kypN1Q84qgHvDjEFYQ2frc5a5QDS25iY+P2Tc 6mzekwGvFY62cLwa7Eq88DwW2sxKsGK4nWYLme5Sj5O5MxfFHeKbNjoxT7XrU9RCaZuC fahIHYvVRMDGVaI4xXC/15gy8N53hzP0aDqTbLzEdY4n28t9fi32bIb6esjw89JUWF9r CM/8g8r4uAwltoquM2r0+OGU2bx8LNUNG/O/QldMPlkJ6EYPoWLT8PMI+x6nPEuKhbcU D97xoWoEP9Dfan7Eq/HnRNZr07JIPsDGw6KEB80V1Il02CbvzggaherDd4QirIq8A2U7 nVIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=GqOKa5c3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gg25si14940215ejb.693.2021.03.30.04.03.59; Tue, 30 Mar 2021 04:04:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=GqOKa5c3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231873AbhC3LCj (ORCPT + 99 others); Tue, 30 Mar 2021 07:02:39 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:19138 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231661AbhC3LCW (ORCPT ); Tue, 30 Mar 2021 07:02:22 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12UAWox4077568; Tue, 30 Mar 2021 07:02:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : in-reply-to : references : date : message-id : mime-version : content-type; s=pp1; bh=om4kXnc6pLolT/LnZcgl5vqCg2/CTpifzvCZklyOw3g=; b=GqOKa5c3QazKpLo+wJwVBdzBoLW2q+17G9fgrg/AKrXY2nGatyDmenB3C90GQogSiuQM B9z3b1aQ/g02KJhvf1XIhG4Z3HVKUfObjp5OXQzNQzCvoPyLtkrR3nrmMebPdAf4W2QK +xaqGFd6bqqJwWDZomD6nGTFCPO8nYXUbIip4ujPPr8meLoFKR5oN+T64osMvpTU/eKf npSk0OM1fguPKbDhIAANCgmAWX1rVOtP0XTX5bGHtjcE1dx2gWruhlF9mg2U8rfWwLkk K1ad8kRGoYXQCGSnPUcDl5hMQRa2muqPR/BEBxI3iRn9mOiVISagJqxntFIiALaJHuHu +g== Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 37jhrv5416-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 Mar 2021 07:02:18 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12UAv7Cs005488; Tue, 30 Mar 2021 11:02:17 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma02dal.us.ibm.com with ESMTP id 37hvb9a5yt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 Mar 2021 11:02:17 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 12UB2GSN12321244 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Mar 2021 11:02:16 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FCE46A04D; Tue, 30 Mar 2021 11:02:16 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E8286A057; Tue, 30 Mar 2021 11:02:13 +0000 (GMT) Received: from skywalker.linux.ibm.com (unknown [9.199.52.226]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 30 Mar 2021 11:02:12 +0000 (GMT) X-Mailer: emacs 28.0.50 (via feedmail 11-beta-1 I) From: "Aneesh Kumar K.V" To: Tyler Hicks , Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny Cc: Pavel Tatashin , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] libnvdimm/region: Allow setting align attribute on regions without mappings In-Reply-To: <20210326152645.85225-1-tyhicks@linux.microsoft.com> References: <20210326152645.85225-1-tyhicks@linux.microsoft.com> Date: Tue, 30 Mar 2021 16:32:10 +0530 Message-ID: <87h7ks7vm5.fsf@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: OxXYJEFgsgdkfzk5hXQMLRFhUREY3PS6 X-Proofpoint-ORIG-GUID: OxXYJEFgsgdkfzk5hXQMLRFhUREY3PS6 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-03-30_03:2021-03-30,2021-03-30 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 spamscore=0 suspectscore=0 malwarescore=0 clxscore=1011 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103300075 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tyler Hicks writes: > The alignment constraint for namespace creation in a region was > increased, from 2M to 16M, for non-PowerPC architectures in v5.7 with > commit 2522afb86a8c ("libnvdimm/region: Introduce an 'align' > attribute"). The thought behind the change was that region alignment > should be uniform across all architectures and, since PowerPC had the > largest alignment constraint of 16M, all architectures should conform to > that alignment. > > The change regressed namespace creation in pre-defined regions that > relied on 2M alignment but a workaround was provided in the form of a > sysfs attribute, named 'align', that could be adjusted to a non-default > alignment value. > > However, the sysfs attribute's store function returned an error (-ENXIO) > when userspace attempted to change the alignment of a region that had no > mappings. This affected 2M aligned regions of volatile memory that were > defined in a device tree using "pmem-region" and created by the > of_pmem_region_driver, since those regions do not contain mappings > (ndr_mappings is 0). > > Allow userspace to set the align attribute on pre-existing regions that > do not have mappings so that namespaces can still be within those > regions, despite not being aligned to 16M. > > Fixes: 2522afb86a8c ("libnvdimm/region: Introduce an 'align' attribute") > Signed-off-by: Tyler Hicks > --- > drivers/nvdimm/region_devs.c | 33 ++++++++++++++++++--------------- > 1 file changed, 18 insertions(+), 15 deletions(-) > > diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c > index ef23119db574..09cff8aa6b40 100644 > --- a/drivers/nvdimm/region_devs.c > +++ b/drivers/nvdimm/region_devs.c > @@ -545,29 +545,32 @@ static ssize_t align_store(struct device *dev, > struct device_attribute *attr, const char *buf, size_t len) > { > struct nd_region *nd_region = to_nd_region(dev); > - unsigned long val, dpa; > - u32 remainder; > + unsigned long val; > int rc; > > rc = kstrtoul(buf, 0, &val); > if (rc) > return rc; > > - if (!nd_region->ndr_mappings) > - return -ENXIO; > - > - /* > - * Ensure space-align is evenly divisible by the region > - * interleave-width because the kernel typically has no facility > - * to determine which DIMM(s), dimm-physical-addresses, would > - * contribute to the tail capacity in system-physical-address > - * space for the namespace. > - */ > - dpa = div_u64_rem(val, nd_region->ndr_mappings, &remainder); > - if (!is_power_of_2(dpa) || dpa < PAGE_SIZE > - || val > region_size(nd_region) || remainder) > + if (val > region_size(nd_region)) > return -EINVAL; > > + if (nd_region->ndr_mappings) { > + unsigned long dpa; > + u32 remainder; > + > + /* > + * Ensure space-align is evenly divisible by the region > + * interleave-width because the kernel typically has no facility > + * to determine which DIMM(s), dimm-physical-addresses, would > + * contribute to the tail capacity in system-physical-address > + * space for the namespace. > + */ > + dpa = div_u64_rem(val, nd_region->ndr_mappings, &remainder); > + if (!is_power_of_2(dpa) || dpa < PAGE_SIZE || remainder) > + return -EINVAL; > + } We still want else { if (!is_power_of_2(val) || val < PAGE_SIZE) return -EINVAL? } > + > /* > * Given that space allocation consults this value multiple > * times ensure it does not change for the duration of the > -- > 2.25.1 > _______________________________________________ > Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org > To unsubscribe send an email to linux-nvdimm-leave@lists.01.org