Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1789304pxf; Fri, 26 Mar 2021 15:05:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkBpFam4u1b5CSXj2IXJzbA5oofKe8Ytc0LdOX31JUuuel/yAdzfV5fsOfy0jvz5NJIC6B X-Received: by 2002:aa7:c4cc:: with SMTP id p12mr17093934edr.325.1616796358786; Fri, 26 Mar 2021 15:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616796358; cv=none; d=google.com; s=arc-20160816; b=Vxzg3q9qQnxaOSAeYpww7LLHig0diTrgv198v+L3vnc3wHJ1YMja3DaVMI0hiVZlxs WuKOuWFVcXIDR9qe0F3522DSCcJDUinj5qDxTZtkYEnlFASD88Ac1c62gQP5Los6KVGt EW8/8O/839725c+acobiqOX9dWCvhNhpGi6AwY6BXn1WqeOOM0woKO6BJ4J5qsD5elb8 vm3BicsjpkDv3stXHsHcVQEL+GqCTmqm48FsX542NK7ua3/A2x/L0uAoyjKETr1AiCFL nk+bNAYCBl8kWNJhMs0dBRlLiGG1tDTYLGpPoY5J17FESbq5LjQJUZXuNjpYfzynCLjh vi+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NhMbn4GcAMbl9agNWrxMfpoDWOn9OHOKSjI2XlOKPcA=; b=O6BHwTUiam/CK5ON3mJmRU7iieT3usCoLLW99GJZ/O5dIN5Bk4S0Uh+exNgu6mDoQG g0AsT2G1F4nzNTuC6se6tiLV0Um1Q1FgTkkHDkFR0C0zrpbE4H/zyucGmx3bqda05O3b wCulcqmYz+z3KpB/OZpon0wJiKVR7jqpjcD5NUR4LEnmQ7wK7ABkquFZkNMUFdsMs3wO X53BC0nd7ZRgxuWe+lr+pDY653DUum5nJ/OihxLa3EFzdZe7vf4G40GnjFyjXg+A84mh bErlbsq0CMXOQl7ku5QYp2iCMt+eRLILJ++vbG4EDb2SPXlNMGfyuSGaoEP7mtth/Bu0 5wrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=JsRhNPVl; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si7550384ejy.55.2021.03.26.15.05.36; Fri, 26 Mar 2021 15:05:58 -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=@soleen.com header.s=google header.b=JsRhNPVl; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230210AbhCZWEV (ORCPT + 99 others); Fri, 26 Mar 2021 18:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbhCZWEF (ORCPT ); Fri, 26 Mar 2021 18:04:05 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 508AAC0613AA for ; Fri, 26 Mar 2021 15:04:05 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id bx7so7906993edb.12 for ; Fri, 26 Mar 2021 15:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NhMbn4GcAMbl9agNWrxMfpoDWOn9OHOKSjI2XlOKPcA=; b=JsRhNPVll2FnHcGnjMcKrlYEx0lYJGoaiEVYaYgYs0q/tSIU1iebSMJV2C4qXRNVHC j/xpHuTprrCE4mV4OBoEqPoLmBa4SbSIGF9YUwooquw7ZoXBZBPV3cFbJjfeOF+B233g pjXd5mtup9UXuW2zyO/jkUTpyMnUc3JSedUah8trDhNHU/4hDKbDRufTfhI8csZDzfCz UjWdiOEshHoumIBLy5vl9wrVfaQBk4bSwT9RzLGbv8TR0ondD0H1q7HjwDIUcATSTqd2 QYWEhwxdF/H5kTqSSiJFq2epyi3OIXJnchlgid7OKnKfV9iULl572sNFNI6Lm1oFH4fY 35JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NhMbn4GcAMbl9agNWrxMfpoDWOn9OHOKSjI2XlOKPcA=; b=NmPRmyhbDN/MgyQponTrntIiJbQUTiiz8IxGI1LGlZip8GNLx2bgv9U4AhWrMVdG9w p95rBxsjuXn4hplio3na6FCUjxrhHH2Hwkv71fXx1Ya2Bypun06HG62rWbCVPYij0dt0 yVC9bd/iZofWjAubB8L8QNXx84L/bZGKYo30WMo8FV23glUPz2VAByU8OPIuXi2O1DJj vXhOSQMcji9/DgZBb3VJSLWOZ26GbKNz5BcdzExWHhFiJXqFvI2cBmmKiiCqUNfuYlpt o5nqalS9xtp14xAUZ/9lBDoEUUDGAwfcx23L+iFWHs2RI+Of2XAB/3ueAcMECFCmuSzF M8uA== X-Gm-Message-State: AOAM5302mWHSZOAg30yONpl+VQq1dAvSQwenuRgg91b4TylDkfN9tajP Y36Xl7tLzMOSnzFFeUxtLKItnsK9/Pgjc+LHKzpzTuuui1cecw== X-Received: by 2002:a05:6402:c88:: with SMTP id cm8mr17363764edb.62.1616796243247; Fri, 26 Mar 2021 15:04:03 -0700 (PDT) MIME-Version: 1.0 References: <20210326152645.85225-1-tyhicks@linux.microsoft.com> In-Reply-To: <20210326152645.85225-1-tyhicks@linux.microsoft.com> From: Pavel Tatashin Date: Fri, 26 Mar 2021 18:03:27 -0400 Message-ID: Subject: Re: [PATCH] libnvdimm/region: Allow setting align attribute on regions without mappings To: Tyler Hicks Cc: Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , "Aneesh Kumar K.V" , Jeff Moyer , linux-nvdimm , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 26, 2021 at 11:27 AM Tyler Hicks wrote: > > 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 This solves the problem that I had in this thread: https://lore.kernel.org/lkml/CA+CK2bCD13JBLMxn2mAuRyVQGKBS5ic2UqYSsxXTccszXCmHkA@mail.gmail.com/ Thank you Tyler for root causing and finding a proper fix. Reviewed-by: Pavel Tatashin > --- > 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; > + } > + > /* > * Given that space allocation consults this value multiple > * times ensure it does not change for the duration of the > -- > 2.25.1 >