From patchwork Thu Apr 27 09:15:52 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: 9702623 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 66AD36032C for ; Thu, 27 Apr 2017 09:16:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B90B2860F for ; Thu, 27 Apr 2017 09:16:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F0FC28623; Thu, 27 Apr 2017 09:16:06 +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 D2B362860F for ; Thu, 27 Apr 2017 09:16:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E4D2121951C96; Thu, 27 Apr 2017 02:16:05 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (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 09C8421951C94 for ; Thu, 27 Apr 2017 02:16:05 -0700 (PDT) Received: by mail-pf0-x241.google.com with SMTP id g23so8067724pfj.1 for ; Thu, 27 Apr 2017 02:16:05 -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=JuRNIvLcWL8EwAQEXzPUurwWRfCZxCi/0hxaA9ZDc5Q=; b=kQMk6g6yYFyGjDjb3d74OJR9OPEjg6vR43OYUv7uAPjqLqhBB8mXbPHrv/W9EOsWgC 7CQRTwrxvKrOtDSgTo1+EWy/+dQdoI1BBCyuQHrjw3tCTjW0Yr9XKYhIAdJduCFdqVHV 0k47o5Dxnpudwsaw/EhEZqFRzP8FS6LAjxXFp6W+APwEebJjf6i8oCtf+75Jgi9Fo1lV ib3XL61ebEBR5xYHdURIdim6xo/4d53/pfLhJDLh9GQK8c8TIGPBnTrdWQqhz4ozhKHz qfuUUW+D4zHL/I54jWuoUM+ns1CYi/fa4zG6mox5o2qG/umD3sFSwYjgDkWhaFlCiYJp ZpBA== 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=JuRNIvLcWL8EwAQEXzPUurwWRfCZxCi/0hxaA9ZDc5Q=; b=heZcGRmaRFXJeeEkRyuFWSHZKRmlT6RY7bJqeGLJxY50yGnlCh7XXJRpUsuBBr7Kh2 MmPTzfcN18OF52o8Wue135KdxSsBzB2LxHsv2FLlkFAyUdnewGcUkeAYvDLGpGU1+o2b ro2wbk2bDbPHkHdu0VbFYsnUggV0LWe66yJQxnE8uO4o2Y0S4SN6qphYZ5jsjnerMexG qQ0LtgoYUQp4wY3ZTleAkJi5w5qX4bRg5+ma7szZRuzCddA37rOu9ksNAoLKKMECeL8R DvIKYiosYL14jhrc0d7BoUoYVnGtwyMQ4bayDFewWMU6RkkNEAT7lALjQ+KXyevwcfjl qpAw== X-Gm-Message-State: AN3rC/4cD/fpPj82qZ+/wJKJuZ92n9RRPcN3nKhF1i1AQHHIId7sYq1b UsanocDB0JBxvQ== X-Received: by 10.98.193.65 with SMTP id i62mr4500978pfg.149.1493284564753; Thu, 27 Apr 2017 02:16:04 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id g5sm4115435pgn.38.2017.04.27.02.16.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Apr 2017 02:16:04 -0700 (PDT) From: Oliver O'Halloran To: linux-nvdimm@lists.01.org Subject: [PATCH] nvdimm: Export supported alignments via sysfs Date: Thu, 27 Apr 2017 19:15:52 +1000 Message-Id: <20170427091552.17694-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.3 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 Adds two new sysfs attributes for pfn (and dax) devices: supported_alignements and default_alignment. These advertise to userspace what alignments this kernel supports, and provides a nominal default alignment to use. Signed-off-by: Oliver O'Halloran --- I'm not sure it makes sense to provide these for pfn devices. In the dax case we have hard restrictions because of how fault handling works, but I'm not convinced this makes sense for the pfn case since it's going to be used with fs-dax. --- drivers/nvdimm/pfn_devs.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index 6c033c9a2f06..5157e7d89f0b 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -260,6 +260,30 @@ 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) +{ + /* Fun fact: These aren't always constants! */ + unsigned long supported_alignments[] = { + PAGE_SIZE, + HPAGE_PMD_SIZE, +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD + HPAGE_PUD_SIZE, +#endif + 0, + }; + + return nd_sector_size_show(0, supported_alignments, buf); +} +DEVICE_ATTR_RO(supported_alignments); + +static ssize_t default_alignment_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%ld\n", HPAGE_PMD_SIZE); +} +DEVICE_ATTR_RO(default_alignment); + static struct attribute *nd_pfn_attributes[] = { &dev_attr_mode.attr, &dev_attr_namespace.attr, @@ -267,6 +291,8 @@ static struct attribute *nd_pfn_attributes[] = { &dev_attr_align.attr, &dev_attr_resource.attr, &dev_attr_size.attr, + &dev_attr_supported_alignments.attr, + &dev_attr_default_alignment.attr, NULL, };