From patchwork Tue Jun 27 09:56:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 9811257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3632460351 for ; Tue, 27 Jun 2017 09:56:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2649D205D6 for ; Tue, 27 Jun 2017 09:56:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 175F322376; Tue, 27 Jun 2017 09:56:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 272ED205D6 for ; Tue, 27 Jun 2017 09:56:26 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 117E821BBC433; Tue, 27 Jun 2017 02:54:56 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 797552095D225 for ; Tue, 27 Jun 2017 02:54:55 -0700 (PDT) Received: by mail-pf0-x242.google.com with SMTP id e199so4082739pfh.0 for ; Tue, 27 Jun 2017 02:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=QdRCBltyi3231+5hq0EPCuGKzkMViHvyNGQwCVAfK7A=; b=WKx4wB+20QBfdQ0LD8JHT/Mo21Q7nFHs7bUA5V1TuMJL+BgBCnqWnLHD6dlCbNWTpk f3RuF8gt/kikIA5bDo1m/caSsImeLW0I3rfLBHcNQg9nbYpKjZIcHhjo0R4zxCuASq3I cxU7tuuRdIk7maiJU2ZMlfC3/PnkPx/dtQXvRcvuF9mhctBTSAJe3Ju4/uUogTx/507z 16MoWQchYjRgeCnhVsNeyqhaKvUyEUygwt9UdB23erorTAg3g6wHDFvmOhyWjCAJU/Y/ +0YldEh/iez2SKqax1Trj+f0SjpbwUj2G7oZEYcpfEsoROTR5joeB0zNKi0As04wDFlT Z1fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QdRCBltyi3231+5hq0EPCuGKzkMViHvyNGQwCVAfK7A=; b=fMCYshrAeAd1sbbwiZMBfWTNk6ScU/id0gjb6/RYgmvpEcrb3QZg5URg4wejH/3cxh RR4rIf6awV6LCw4U2K8XK9uxyTFnfiROVVituWen8Enxe1RUovUtNfT3Jllrp7XxCC7G vDu2kWSYdnM0kgBZIpk2zjCBeHMtLUuBI7D5Z92RSNBSsiB5txdPIHF8H7GSLpyb9Xc8 xJd+Gw++yPSbKXO9DQ5z8xUv+P6l3d+HAUCA5UT5iVCyWQmbecsqRzZ+D/vke0p+e7AY ZRTIl1qXSIxPaJIDPhKlI9DMiLGAIi+7I8ix0tCQI8PMr1//D7wFyYX9eT7DfqMcWy18 +uCw== X-Gm-Message-State: AKS2vOxoCopGiTo1la73vQX0AtNOdNd2KTCGoUZifjj8PTMH6aHSuzsi okTOoOukyVSYMtVq X-Received: by 10.84.143.100 with SMTP id 91mr4933376ply.186.1498557385407; Tue, 27 Jun 2017 02:56:25 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id j6sm5189310pgc.1.2017.06.27.02.56.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jun 2017 02:56:24 -0700 (PDT) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH] libnvdimm: show supported dax/pfn region alignments in sysfs Date: Tue, 27 Jun 2017 19:56:12 +1000 Message-Id: <20170627095612.6328-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.4 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP The alignment of a DAX and PFN regions dictates the page sizes that can be used to map the region. Even if the hardware page sizes are known the actual range of supported page sizes that can be used with DAX depends on the kernel configuration. As a result its best that the kernel advertises the alignments that should be used with these region types. This patch adds the 'supported_alignments' region attribute to expose this information to userspace. Signed-off-by: Oliver O'Halloran --- drivers/nvdimm/pfn_devs.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 2ae9a000b090..505d50ef9a91 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -260,6 +260,33 @@ static ssize_t size_show(struct device *dev, } static DEVICE_ATTR_RO(size); +static ssize_t supported_alignments_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + /* + * This needs to be a local variable because the *_SIZE macros + * aren't always constants. + */ + unsigned long supported_alignments[] = { + PAGE_SIZE, +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + HPAGE_PMD_SIZE, +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD + HPAGE_PUD_SIZE, +#endif +#endif + 0, + }; + + return nd_sector_size_show(0, supported_alignments, buf); +} +DEVICE_ATTR_RO(supported_alignments); + +static struct attribute *nd_dax_attributes[] = { + &dev_attr_supported_alignments.attr, + NULL, +}; + static struct attribute *nd_pfn_attributes[] = { &dev_attr_mode.attr, &dev_attr_namespace.attr, @@ -267,6 +294,7 @@ static struct attribute *nd_pfn_attributes[] = { &dev_attr_align.attr, &dev_attr_resource.attr, &dev_attr_size.attr, + &dev_attr_supported_alignments.attr, NULL, };