Re: [PATCH 04/16] libnvdimm: Move nd_numa_attribute_group to device_type

2019-11-12 Thread Dan Williams
On Tue, Nov 12, 2019 at 10:02 PM Aneesh Kumar K.V
 wrote:
>
> On 11/13/19 6:56 AM, Dan Williams wrote:
> > On Tue, Nov 12, 2019 at 1:23 AM Aneesh Kumar K.V
> >  wrote:
> >>
> >> Dan Williams  writes:
> >>
> >>> A 'struct device_type' instance can carry default attributes for the
> >>> device. Use this facility to remove the export of
> >>> nd_numa_attribute_group and put the responsibility on the core rather
> >>> than leaf implementations to define this attribute.
> >>>
> >>> Cc: Ira Weiny 
> >>> Cc: Michael Ellerman 
> >>> Cc: "Oliver O'Halloran" 
> >>> Cc: Vishal Verma 
> >>> Cc: Aneesh Kumar K.V 
> >>> Signed-off-by: Dan Williams 
> >>
> >>
> >> can we also expose target_node in a similar way? This allows application
> >> to better understand the node locality of the SCM device.
> >
> > It is already exported for device-dax instances. See
> > DEVICE_ATTR_RO(target_node) in drivers/dax/bus.c. I did not see a use
> > case for it to be exported for other nvdimm device types.
> >
>
> some applications do want to access the fsdax namspace as different
> mount points based on numa affinity. If can differentiate the two
> regions with different target_node and same numa_node, that will help
> them better isolate these mounts.

Can you be more explicit than "some", and what's the impact if the
kernel continues with the status quo and does not export this data?
I'm trying to come up with the justification to include into the
changelog that adds that information.

At least on the pmem platforms I am working with the pmem ranges with
different target nodes also appear on different numa nodes so there is
no incremental benefit for target node there.
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 04/16] libnvdimm: Move nd_numa_attribute_group to device_type

2019-11-12 Thread Aneesh Kumar K.V

On 11/13/19 6:56 AM, Dan Williams wrote:

On Tue, Nov 12, 2019 at 1:23 AM Aneesh Kumar K.V
 wrote:


Dan Williams  writes:


A 'struct device_type' instance can carry default attributes for the
device. Use this facility to remove the export of
nd_numa_attribute_group and put the responsibility on the core rather
than leaf implementations to define this attribute.

Cc: Ira Weiny 
Cc: Michael Ellerman 
Cc: "Oliver O'Halloran" 
Cc: Vishal Verma 
Cc: Aneesh Kumar K.V 
Signed-off-by: Dan Williams 



can we also expose target_node in a similar way? This allows application
to better understand the node locality of the SCM device.


It is already exported for device-dax instances. See
DEVICE_ATTR_RO(target_node) in drivers/dax/bus.c. I did not see a use
case for it to be exported for other nvdimm device types.



some applications do want to access the fsdax namspace as different 
mount points based on numa affinity. If can differentiate the two 
regions with different target_node and same numa_node, that will help 
them better isolate these mounts.


-aneesh
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 04/16] libnvdimm: Move nd_numa_attribute_group to device_type

2019-11-12 Thread Dan Williams
On Tue, Nov 12, 2019 at 1:23 AM Aneesh Kumar K.V
 wrote:
>
> Dan Williams  writes:
>
> > A 'struct device_type' instance can carry default attributes for the
> > device. Use this facility to remove the export of
> > nd_numa_attribute_group and put the responsibility on the core rather
> > than leaf implementations to define this attribute.
> >
> > Cc: Ira Weiny 
> > Cc: Michael Ellerman 
> > Cc: "Oliver O'Halloran" 
> > Cc: Vishal Verma 
> > Cc: Aneesh Kumar K.V 
> > Signed-off-by: Dan Williams 
>
>
> can we also expose target_node in a similar way? This allows application
> to better understand the node locality of the SCM device.

It is already exported for device-dax instances. See
DEVICE_ATTR_RO(target_node) in drivers/dax/bus.c. I did not see a use
case for it to be exported for other nvdimm device types.
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: DAX filesystem support on ARMv8

2019-11-12 Thread Matthew Wilcox
On Tue, Nov 12, 2019 at 09:15:18AM -0800, Dan Williams wrote:
> On Mon, Nov 11, 2019 at 6:12 PM Bharat Kumar Gogada  
> wrote:
> >
> > Hi All,
> >
> > As per Documentation/filesystems/dax.txt
> >
> > The DAX code does not work correctly on architectures which have virtually
> > mapped caches such as ARM, MIPS and SPARC.
> >
> > Can anyone please shed light on dax filesystem issue w.r.t ARM architecture 
> > ?
> 
> The concern is VIVT caches since the kernel will want to flush pmem
> addresses with different virtual addresses than what userspace is
> using. As far as I know, ARMv8 has VIPT caches, so should not have an
> issue. Willy initially wrote those restrictions, but I am assuming
> that the concern was managing the caches in the presence of virtual
> aliases.

The kernel will also access data at different virtual addresses from
userspace.  So VIVT CPUs will be mmap/read/write incoherent, as well as
being flush incoherent.
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 00/16] Memory Hierarchy: Enable target node lookups for reserved memory

2019-11-12 Thread Dan Williams
On Tue, Nov 12, 2019 at 3:43 AM Aneesh Kumar K.V
 wrote:
>
> Dan Williams  writes:
>
> > Yes, this patch series looks like a pile of boring libnvdimm cleanups,
> > but buried at the end are some small gems that testing with libnvdimm
> > uncovered. These gems will prove more valuable over time for Memory
> > Hierarchy management as more platforms, via the ACPI HMAT and EFI
> > Specific Purpose Memory, publish reserved or "soft-reserved" ranges to
> > Linux. Linux system administrators will expect to be able to interact
> > with those ranges with a unique numa node number when/if that memory is
> > onlined via the dax_kmem driver [1].
> >
> > One configuration that currently fails to properly convey the target
> > node for the resulting memory hotplug operation is persistent memory
> > defined by the memmap=nn!ss parameter. For example, today if node1 is a
> > memory only node, and all the memory from node1 is specified to
> > memmap=nn!ss and subsequently onlined, it will end up being onlined as
> > node0 memory. As it stands, memory_add_physaddr_to_nid() can only
> > identify online nodes and since node1 in this example has no online cpus
> > / memory the target node is initialized node0.
> >
> > The fix is to preserve rather than discard the numa_meminfo entries that
> > are relevant for reserved memory ranges, and to uplevel the node
> > distance helper for determining the "local" (closest) node relative to
> > an initiator node.
> >
> > The first 12 patches are cleanups to make sure that all nvdimm devices
> > and their children properly export a numa_node attribute. The switch to
> > a device-type is less code and less error prone as a result.
>
>
> Will this still allow leaf driver to have platform specific attribute
> exposed via sysfs? Or do we want to still keep them in nvdimm core and
> control the visibility via is_visible() callback?

The leaf driver can still have platform specific attributes, see:

acpi_nfit_attribute_groups
acpi_nfit_dimm_attribute_groups
acpi_nfit_region_attribute_groups

...that still exist after this conversion. This conversion simply
arranges for those to passed in without making the leaf driver also be
responsible for specifying the core attributes.
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [ndctl PATCH v2 1/2] ndctl/namespace: Rework counts reported by enable-namespace

2019-11-12 Thread Verma, Vishal L


On Tue, 2019-11-05 at 10:27 -0700, Vishal Verma wrote:
> Add detection of 'seed' namespaces
> (ndctl_namespace_is_configuration_idle()) to the enable-namespace
> operatiuon and libndctl API. In libndctl, return a '1' for seed
> namespaces. In namespace.c, reinterpret a '1' based on a check for a
> seed namespace, and decide on skip vs success accordingly. Collect this
> into a new namespace_enable helper, and make the reported count
> consistent by also skipping namespaces that were already enabled.
> 
> Link: https://github.com/pmem/ndctl/issues/119
> Reported-by: Aneesh Kumar K.V 
> Cc: Dan Williams 
> Signed-off-by: Vishal Verma 
> ---
> 
> Changes in v2:
> - The kernel is the ultimate authority on enabling namespaces, so we
>   should let it make the decision of how to handle seed namespaces
>   instead of preemptively skipping them. Let the kernel make that
>   decision, and fix up error reporting after the fact.

These break the unit tests, so I'll have to take another look at this.
I suspect the added complexity is probably not worth the few extra
prints from seed namespaces for operations using the 'all' keyword.

___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: DAX filesystem support on ARMv8

2019-11-12 Thread Dan Williams
On Mon, Nov 11, 2019 at 6:12 PM Bharat Kumar Gogada  wrote:
>
> Hi All,
>
> As per Documentation/filesystems/dax.txt
>
> The DAX code does not work correctly on architectures which have virtually
> mapped caches such as ARM, MIPS and SPARC.
>
> Can anyone please shed light on dax filesystem issue w.r.t ARM architecture ?

The concern is VIVT caches since the kernel will want to flush pmem
addresses with different virtual addresses than what userspace is
using. As far as I know, ARMv8 has VIPT caches, so should not have an
issue. Willy initially wrote those restrictions, but I am assuming
that the concern was managing the caches in the presence of virtual
aliases.
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 11/16] libnvdimm: Simplify root read-only definition for the 'resource' attribute

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> Rather than update the permission in ->is_visible() set the permission
> directly at declaration time.
>
Reviewed-by: Aneesh Kumar K.V 

> Cc: Ira Weiny 
> Cc: Vishal Verma 
> Signed-off-by: Dan Williams 
> ---
>  drivers/nvdimm/namespace_devs.c |9 +++--
>  drivers/nvdimm/pfn_devs.c   |   10 +-
>  drivers/nvdimm/region_devs.c|   10 +++---
>  3 files changed, 7 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
> index 37471a272c1a..85b553094d19 100644
> --- a/drivers/nvdimm/namespace_devs.c
> +++ b/drivers/nvdimm/namespace_devs.c
> @@ -1303,7 +1303,7 @@ static ssize_t resource_show(struct device *dev,
>   return -ENXIO;
>   return sprintf(buf, "%#llx\n", (unsigned long long) res->start);
>  }
> -static DEVICE_ATTR_RO(resource);
> +static DEVICE_ATTR(resource, 0400, resource_show, NULL);
>  
>  static const unsigned long blk_lbasize_supported[] = { 512, 520, 528,
>   4096, 4104, 4160, 4224, 0 };
> @@ -1619,11 +1619,8 @@ static umode_t namespace_visible(struct kobject *kobj,
>  {
>   struct device *dev = container_of(kobj, struct device, kobj);
>  
> - if (a == _attr_resource.attr) {
> - if (is_namespace_blk(dev))
> - return 0;
> - return 0400;
> - }
> + if (a == _attr_resource.attr && is_namespace_blk(dev))
> + return 0;
>  
>   if (is_namespace_pmem(dev) || is_namespace_blk(dev)) {
>   if (a == _attr_size.attr)
> diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c
> index e809961e2b6f..9f9cb51301e7 100644
> --- a/drivers/nvdimm/pfn_devs.c
> +++ b/drivers/nvdimm/pfn_devs.c
> @@ -218,7 +218,7 @@ static ssize_t resource_show(struct device *dev,
>  
>   return rc;
>  }
> -static DEVICE_ATTR_RO(resource);
> +static DEVICE_ATTR(resource, 0400, resource_show, NULL);
>  
>  static ssize_t size_show(struct device *dev,
>   struct device_attribute *attr, char *buf)
> @@ -269,16 +269,8 @@ static struct attribute *nd_pfn_attributes[] = {
>   NULL,
>  };
>  
> -static umode_t pfn_visible(struct kobject *kobj, struct attribute *a, int n)
> -{
> - if (a == _attr_resource.attr)
> - return 0400;
> - return a->mode;
> -}
> -
>  static struct attribute_group nd_pfn_attribute_group = {
>   .attrs = nd_pfn_attributes,
> - .is_visible = pfn_visible,
>  };
>  
>  const struct attribute_group *nd_pfn_attribute_groups[] = {
> diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
> index 0afc1973e938..be3e429e86af 100644
> --- a/drivers/nvdimm/region_devs.c
> +++ b/drivers/nvdimm/region_devs.c
> @@ -553,7 +553,7 @@ static ssize_t resource_show(struct device *dev,
>  
>   return sprintf(buf, "%#llx\n", nd_region->ndr_start);
>  }
> -static DEVICE_ATTR_RO(resource);
> +static DEVICE_ATTR(resource, 0400, resource_show, NULL);
>  
>  static ssize_t persistence_domain_show(struct device *dev,
>   struct device_attribute *attr, char *buf)
> @@ -605,12 +605,8 @@ static umode_t region_visible(struct kobject *kobj, 
> struct attribute *a, int n)
>   if (!is_memory(dev) && a == _attr_badblocks.attr)
>   return 0;
>  
> - if (a == _attr_resource.attr) {
> - if (is_memory(dev))
> - return 0400;
> - else
> - return 0;
> - }
> + if (a == _attr_resource.attr && !is_memory(dev))
> + return 0;
>  
>   if (a == _attr_deep_flush.attr) {
>   int has_flush = nvdimm_has_flush(nd_region);
> ___
> Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
> To unsubscribe send an email to linux-nvdimm-le...@lists.01.org
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 10/16] dax: Simplify root read-only definition for the 'resource' attribute

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> Rather than update the permission in ->is_visible() set the permission
> directly at declaration time.
>
Reviewed-by: Aneesh Kumar K.V 

> Cc: Ira Weiny 
> Cc: Vishal Verma 
> Signed-off-by: Dan Williams 
> ---
>  drivers/dax/bus.c |4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> index f3e6e00ece40..ce6d648d7670 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -309,7 +309,7 @@ static ssize_t resource_show(struct device *dev,
>  
>   return sprintf(buf, "%#llx\n", dev_dax_resource(dev_dax));
>  }
> -static DEVICE_ATTR_RO(resource);
> +static DEVICE_ATTR(resource, 0400, resource_show, NULL);
>  
>  static ssize_t modalias_show(struct device *dev, struct device_attribute 
> *attr,
>   char *buf)
> @@ -329,8 +329,6 @@ static umode_t dev_dax_visible(struct kobject *kobj, 
> struct attribute *a, int n)
>  
>   if (a == _attr_target_node.attr && dev_dax_target_node(dev_dax) < 0)
>   return 0;
> - if (a == _attr_resource.attr)
> - return 0400;
>   return a->mode;
>  }
>  
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 09/16] dax: Create a dax device_type

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> Move the open coded release method and attribute groups to a 'struct
> device_type' instance.
>
Reviewed-by: Aneesh Kumar K.V 

> Cc: Ira Weiny 
> Cc: Vishal Verma 
> Signed-off-by: Dan Williams 
> ---
>  drivers/dax/bus.c |8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> index 8fafbeab510a..f3e6e00ece40 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -373,6 +373,11 @@ static void dev_dax_release(struct device *dev)
>   kfree(dev_dax);
>  }
>  
> +static const struct device_type dev_dax_type = {
> + .release = dev_dax_release,
> + .groups = dax_attribute_groups,
> +};
> +
>  static void unregister_dev_dax(void *dev)
>  {
>   struct dev_dax *dev_dax = to_dev_dax(dev);
> @@ -430,8 +435,7 @@ struct dev_dax *__devm_create_dev_dax(struct dax_region 
> *dax_region, int id,
>   else
>   dev->class = dax_class;
>   dev->parent = parent;
> - dev->groups = dax_attribute_groups;
> - dev->release = dev_dax_release;
> + dev->type = _dax_type;
>   dev_set_name(dev, "dax%d.%d", dax_region->id, id);
>  
>   rc = device_add(dev);
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 12/16] dax: Add numa_node to the default device-dax attributes

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> It is confusing that device-dax instances publish a 'target_node'
> attribute, but not a 'numa_node'. The 'numa_node' information is
> available elsewhere in the sysfs device hierarchy, but it is not obvious
> and not reliable from one device-dax instance-type (e.g. child devices
> of nvdimm namespaces) to the next (e.g. 'hmem' devices defined by EFI
> Specific Purpose Memory and the ACPI HMAT).
>

Reviewed-by: Aneesh Kumar K.V 

> Cc: Ira Weiny 
> Cc: Vishal Verma 
> Signed-off-by: Dan Williams 
> ---
>  drivers/dax/bus.c |   10 ++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c
> index ce6d648d7670..0879b9663eb7 100644
> --- a/drivers/dax/bus.c
> +++ b/drivers/dax/bus.c
> @@ -322,6 +322,13 @@ static ssize_t modalias_show(struct device *dev, struct 
> device_attribute *attr,
>  }
>  static DEVICE_ATTR_RO(modalias);
>  
> +static ssize_t numa_node_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + return sprintf(buf, "%d\n", dev_to_node(dev));
> +}
> +static DEVICE_ATTR_RO(numa_node);
> +
>  static umode_t dev_dax_visible(struct kobject *kobj, struct attribute *a, 
> int n)
>  {
>   struct device *dev = container_of(kobj, struct device, kobj);
> @@ -329,6 +336,8 @@ static umode_t dev_dax_visible(struct kobject *kobj, 
> struct attribute *a, int n)
>  
>   if (a == _attr_target_node.attr && dev_dax_target_node(dev_dax) < 0)
>   return 0;
> + if (a == _attr_numa_node.attr && !IS_ENABLED(CONFIG_NUMA))
> + return 0;
>   return a->mode;
>  }
>  
> @@ -337,6 +346,7 @@ static struct attribute *dev_dax_attributes[] = {
>   _attr_size.attr,
>   _attr_target_node.attr,
>   _attr_resource.attr,
> + _attr_numa_node.attr,
>   NULL,
>  };
>  
> ___
> Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
> To unsubscribe send an email to linux-nvdimm-le...@lists.01.org
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 08/16] libnvdimm: Move nvdimm_bus_attribute_group to device_type

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> A 'struct device_type' instance can carry default attributes for the
> device. Use this facility to remove the export of
> nvdimm_bus_attribute_group and put the responsibility on the core rather
> than leaf implementations to define this attribute.
>
Reviewed-by: Aneesh Kumar K.V 

> Cc: Ira Weiny 
> Cc: Michael Ellerman 
> Cc: "Oliver O'Halloran" 
> Cc: Vishal Verma 
> Cc: Aneesh Kumar K.V 
> Signed-off-by: Dan Williams 
> ---
>  arch/powerpc/platforms/pseries/papr_scm.c |6 --
>  drivers/acpi/nfit/core.c  |1 -
>  drivers/nvdimm/bus.c  |9 +++--
>  drivers/nvdimm/core.c |8 ++--
>  drivers/nvdimm/e820.c |6 --
>  drivers/nvdimm/nd.h   |1 +
>  drivers/nvdimm/of_pmem.c  |6 --
>  include/linux/libnvdimm.h |2 --
>  8 files changed, 14 insertions(+), 25 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c 
> b/arch/powerpc/platforms/pseries/papr_scm.c
> index 8354737ac340..33aa59e666e5 100644
> --- a/arch/powerpc/platforms/pseries/papr_scm.c
> +++ b/arch/powerpc/platforms/pseries/papr_scm.c
> @@ -284,11 +284,6 @@ int papr_scm_ndctl(struct nvdimm_bus_descriptor 
> *nd_desc, struct nvdimm *nvdimm,
>   return 0;
>  }
>  
> -static const struct attribute_group *bus_attr_groups[] = {
> - _bus_attribute_group,
> - NULL,
> -};
> -
>  static inline int papr_scm_node(int node)
>  {
>   int min_dist = INT_MAX, dist;
> @@ -319,7 +314,6 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
>   p->bus_desc.ndctl = papr_scm_ndctl;
>   p->bus_desc.module = THIS_MODULE;
>   p->bus_desc.of_node = p->pdev->dev.of_node;
> - p->bus_desc.attr_groups = bus_attr_groups;
>   p->bus_desc.provider_name = kstrdup(p->pdev->name, GFP_KERNEL);
>  
>   if (!p->bus_desc.provider_name)
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index 84fc1f865802..a3320f93616d 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -1404,7 +1404,6 @@ static const struct attribute_group 
> acpi_nfit_attribute_group = {
>  };
>  
>  static const struct attribute_group *acpi_nfit_attribute_groups[] = {
> - _bus_attribute_group,
>   _nfit_attribute_group,
>   NULL,
>  };
> diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
> index 28e1b265aa63..1d330d46d036 100644
> --- a/drivers/nvdimm/bus.c
> +++ b/drivers/nvdimm/bus.c
> @@ -300,9 +300,14 @@ static void nvdimm_bus_release(struct device *dev)
>   kfree(nvdimm_bus);
>  }
>  
> +static const struct device_type nvdimm_bus_dev_type = {
> + .release = nvdimm_bus_release,
> + .groups = nvdimm_bus_attribute_groups,
> +};
> +
>  bool is_nvdimm_bus(struct device *dev)
>  {
> - return dev->release == nvdimm_bus_release;
> + return dev->type == _bus_dev_type;
>  }
>  
>  struct nvdimm_bus *walk_to_nvdimm_bus(struct device *nd_dev)
> @@ -355,7 +360,7 @@ struct nvdimm_bus *nvdimm_bus_register(struct device 
> *parent,
>   badrange_init(_bus->badrange);
>   nvdimm_bus->nd_desc = nd_desc;
>   nvdimm_bus->dev.parent = parent;
> - nvdimm_bus->dev.release = nvdimm_bus_release;
> + nvdimm_bus->dev.type = _bus_dev_type;
>   nvdimm_bus->dev.groups = nd_desc->attr_groups;
>   nvdimm_bus->dev.bus = _bus_type;
>   nvdimm_bus->dev.of_node = nd_desc->of_node;
> diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c
> index 9204f1e9fd14..81231ca23db0 100644
> --- a/drivers/nvdimm/core.c
> +++ b/drivers/nvdimm/core.c
> @@ -385,10 +385,14 @@ static struct attribute *nvdimm_bus_attributes[] = {
>   NULL,
>  };
>  
> -struct attribute_group nvdimm_bus_attribute_group = {
> +static const struct attribute_group nvdimm_bus_attribute_group = {
>   .attrs = nvdimm_bus_attributes,
>  };
> -EXPORT_SYMBOL_GPL(nvdimm_bus_attribute_group);
> +
> +const struct attribute_group *nvdimm_bus_attribute_groups[] = {
> + _bus_attribute_group,
> + NULL,
> +};
>  
>  int nvdimm_bus_add_badrange(struct nvdimm_bus *nvdimm_bus, u64 addr, u64 
> length)
>  {
> diff --git a/drivers/nvdimm/e820.c b/drivers/nvdimm/e820.c
> index 9a971a59dec7..e02f60ad6c99 100644
> --- a/drivers/nvdimm/e820.c
> +++ b/drivers/nvdimm/e820.c
> @@ -8,11 +8,6 @@
>  #include 
>  #include 
>  
> -static const struct attribute_group *e820_pmem_attribute_groups[] = {
> - _bus_attribute_group,
> - NULL,
> -};
> -
>  static int e820_pmem_remove(struct platform_device *pdev)
>  {
>   struct nvdimm_bus *nvdimm_bus = platform_get_drvdata(pdev);
> @@ -55,7 +50,6 @@ static int e820_pmem_probe(struct platform_device *pdev)
>   struct nvdimm_bus *nvdimm_bus;
>   int rc = -ENXIO;
>  
> - nd_desc.attr_groups = e820_pmem_attribute_groups;
>   nd_desc.provider_name = "e820";
>   nd_desc.module = THIS_MODULE;
>   nvdimm_bus = nvdimm_bus_register(dev, _desc);
> diff --git 

Re: [PATCH 07/16] libnvdimm: Move nvdimm_attribute_group to device_type

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> A 'struct device_type' instance can carry default attributes for the
> device. Use this facility to remove the export of
> nvdimm_attribute_group and put the responsibility on the core rather
> than leaf implementations to define this attribute.
>
Reviewed-by: Aneesh Kumar K.V 
> Cc: Ira Weiny 
> Cc: Michael Ellerman 
> Cc: "Oliver O'Halloran" 
> Cc: Vishal Verma 
> Cc: Aneesh Kumar K.V 
> Signed-off-by: Dan Williams 
> ---
>  arch/powerpc/platforms/pseries/papr_scm.c |9 ++-
>  drivers/acpi/nfit/core.c  |1 -
>  drivers/nvdimm/dimm_devs.c|   36 
> +++--
>  include/linux/libnvdimm.h |1 -
>  4 files changed, 20 insertions(+), 27 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c 
> b/arch/powerpc/platforms/pseries/papr_scm.c
> index 0405fb769336..8354737ac340 100644
> --- a/arch/powerpc/platforms/pseries/papr_scm.c
> +++ b/arch/powerpc/platforms/pseries/papr_scm.c
> @@ -289,11 +289,6 @@ static const struct attribute_group *bus_attr_groups[] = 
> {
>   NULL,
>  };
>  
> -static const struct attribute_group *papr_scm_dimm_groups[] = {
> - _attribute_group,
> - NULL,
> -};
> -
>  static inline int papr_scm_node(int node)
>  {
>   int min_dist = INT_MAX, dist;
> @@ -339,8 +334,8 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
>   dimm_flags = 0;
>   set_bit(NDD_ALIASING, _flags);
>  
> - p->nvdimm = nvdimm_create(p->bus, p, papr_scm_dimm_groups,
> - dimm_flags, PAPR_SCM_DIMM_CMD_MASK, 0, NULL);
> + p->nvdimm = nvdimm_create(p->bus, p, NULL, dimm_flags,
> +   PAPR_SCM_DIMM_CMD_MASK, 0, NULL);
>   if (!p->nvdimm) {
>   dev_err(dev, "Error creating DIMM object for %pOF\n", p->dn);
>   goto err;
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index 69c406ecc3a6..84fc1f865802 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -1698,7 +1698,6 @@ static const struct attribute_group 
> acpi_nfit_dimm_attribute_group = {
>  };
>  
>  static const struct attribute_group *acpi_nfit_dimm_attribute_groups[] = {
> - _attribute_group,
>   _nfit_dimm_attribute_group,
>   NULL,
>  };
> diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
> index 278867c68682..94ea6dba6b4f 100644
> --- a/drivers/nvdimm/dimm_devs.c
> +++ b/drivers/nvdimm/dimm_devs.c
> @@ -202,22 +202,6 @@ static void nvdimm_release(struct device *dev)
>   kfree(nvdimm);
>  }
>  
> -static const struct attribute_group *nvdimm_attribute_groups[] = {
> - _device_attribute_group,
> - NULL,
> -};
> -
> -static const struct device_type nvdimm_device_type = {
> - .name = "nvdimm",
> - .release = nvdimm_release,
> - .groups = nvdimm_attribute_groups,
> -};
> -
> -bool is_nvdimm(struct device *dev)
> -{
> - return dev->type == _device_type;
> -}
> -
>  struct nvdimm *to_nvdimm(struct device *dev)
>  {
>   struct nvdimm *nvdimm = container_of(dev, struct nvdimm, dev);
> @@ -456,11 +440,27 @@ static umode_t nvdimm_visible(struct kobject *kobj, 
> struct attribute *a, int n)
>   return 0;
>  }
>  
> -struct attribute_group nvdimm_attribute_group = {
> +static const struct attribute_group nvdimm_attribute_group = {
>   .attrs = nvdimm_attributes,
>   .is_visible = nvdimm_visible,
>  };
> -EXPORT_SYMBOL_GPL(nvdimm_attribute_group);
> +
> +static const struct attribute_group *nvdimm_attribute_groups[] = {
> + _device_attribute_group,
> + _attribute_group,
> + NULL,
> +};
> +
> +static const struct device_type nvdimm_device_type = {
> + .name = "nvdimm",
> + .release = nvdimm_release,
> + .groups = nvdimm_attribute_groups,
> +};
> +
> +bool is_nvdimm(struct device *dev)
> +{
> + return dev->type == _device_type;
> +}
>  
>  struct nvdimm *__nvdimm_create(struct nvdimm_bus *nvdimm_bus,
>   void *provider_data, const struct attribute_group **groups,
> diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
> index eb597d1cb891..3644af97bcb4 100644
> --- a/include/linux/libnvdimm.h
> +++ b/include/linux/libnvdimm.h
> @@ -66,7 +66,6 @@ enum {
>  };
>  
>  extern struct attribute_group nvdimm_bus_attribute_group;
> -extern struct attribute_group nvdimm_attribute_group;
>  
>  struct nvdimm;
>  struct nvdimm_bus_descriptor;
> ___
> Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
> To unsubscribe send an email to linux-nvdimm-le...@lists.01.org
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 06/16] libnvdimm: Move nd_mapping_attribute_group to device_type

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> A 'struct device_type' instance can carry default attributes for the
> device. Use this facility to remove the export of
> nd_mapping_attribute_group and put the responsibility on the core rather
> than leaf implementations to define this attribute.
>

Reviewed-by: Aneesh Kumar K.V 

> Cc: Ira Weiny 
> Cc: Michael Ellerman 
> Cc: "Oliver O'Halloran" 
> Cc: Vishal Verma 
> Cc: Aneesh Kumar K.V 
> Signed-off-by: Dan Williams 
> ---
>  arch/powerpc/platforms/pseries/papr_scm.c |6 --
>  drivers/acpi/nfit/core.c  |1 -
>  drivers/nvdimm/region_devs.c  |4 ++--
>  include/linux/libnvdimm.h |1 -
>  4 files changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c 
> b/arch/powerpc/platforms/pseries/papr_scm.c
> index 6428834d7cd5..0405fb769336 100644
> --- a/arch/powerpc/platforms/pseries/papr_scm.c
> +++ b/arch/powerpc/platforms/pseries/papr_scm.c
> @@ -284,11 +284,6 @@ int papr_scm_ndctl(struct nvdimm_bus_descriptor 
> *nd_desc, struct nvdimm *nvdimm,
>   return 0;
>  }
>  
> -static const struct attribute_group *region_attr_groups[] = {
> - _mapping_attribute_group,
> - NULL,
> -};
> -
>  static const struct attribute_group *bus_attr_groups[] = {
>   _bus_attribute_group,
>   NULL,
> @@ -362,7 +357,6 @@ static int papr_scm_nvdimm_init(struct papr_scm_priv *p)
>   mapping.size = p->blocks * p->block_size; // XXX: potential overflow?
>  
>   memset(_desc, 0, sizeof(ndr_desc));
> - ndr_desc.attr_groups = region_attr_groups;
>   target_nid = dev_to_node(>pdev->dev);
>   online_nid = papr_scm_node(target_nid);
>   ndr_desc.numa_node = online_nid;
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index 99e20b8b6ea0..69c406ecc3a6 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -2196,7 +2196,6 @@ static const struct attribute_group 
> acpi_nfit_region_attribute_group = {
>  };
>  
>  static const struct attribute_group *acpi_nfit_region_attribute_groups[] = {
> - _mapping_attribute_group,
>   _nfit_region_attribute_group,
>   NULL,
>  };
> diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
> index f97166583294..0afc1973e938 100644
> --- a/drivers/nvdimm/region_devs.c
> +++ b/drivers/nvdimm/region_devs.c
> @@ -751,11 +751,10 @@ static struct attribute *mapping_attributes[] = {
>   NULL,
>  };
>  
> -struct attribute_group nd_mapping_attribute_group = {
> +static const struct attribute_group nd_mapping_attribute_group = {
>   .is_visible = mapping_visible,
>   .attrs = mapping_attributes,
>  };
> -EXPORT_SYMBOL_GPL(nd_mapping_attribute_group);
>  
>  static const struct attribute_group nd_region_attribute_group = {
>   .attrs = nd_region_attributes,
> @@ -766,6 +765,7 @@ static const struct attribute_group 
> *nd_region_attribute_groups[] = {
>   _device_attribute_group,
>   _region_attribute_group,
>   _numa_attribute_group,
> + _mapping_attribute_group,
>   NULL,
>  };
>  
> diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
> index 312248d334c7..eb597d1cb891 100644
> --- a/include/linux/libnvdimm.h
> +++ b/include/linux/libnvdimm.h
> @@ -67,7 +67,6 @@ enum {
>  
>  extern struct attribute_group nvdimm_bus_attribute_group;
>  extern struct attribute_group nvdimm_attribute_group;
> -extern struct attribute_group nd_mapping_attribute_group;
>  
>  struct nvdimm;
>  struct nvdimm_bus_descriptor;
> ___
> Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
> To unsubscribe send an email to linux-nvdimm-le...@lists.01.org
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 05/16] libnvdimm: Move nd_region_attribute_group to device_type

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> A 'struct device_type' instance can carry default attributes for the
> device. Use this facility to remove the export of
> nd_region_attribute_group and put the responsibility on the core rather
> than leaf implementations to define this attribute.
>

Reviewed-by: Aneesh Kumar K.V 

> Cc: Ira Weiny 
> Cc: Michael Ellerman 
> Cc: "Oliver O'Halloran" 
> Cc: Vishal Verma 
> Cc: Aneesh Kumar K.V 
> Signed-off-by: Dan Williams 
> ---
>  arch/powerpc/platforms/pseries/papr_scm.c |1 -
>  drivers/acpi/nfit/core.c  |1 -
>  drivers/nvdimm/e820.c |6 --
>  drivers/nvdimm/of_pmem.c  |6 --
>  drivers/nvdimm/region_devs.c  |4 ++--
>  include/linux/libnvdimm.h |1 -
>  6 files changed, 2 insertions(+), 17 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c 
> b/arch/powerpc/platforms/pseries/papr_scm.c
> index 6ffda03a6349..6428834d7cd5 100644
> --- a/arch/powerpc/platforms/pseries/papr_scm.c
> +++ b/arch/powerpc/platforms/pseries/papr_scm.c
> @@ -285,7 +285,6 @@ int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, 
> struct nvdimm *nvdimm,
>  }
>  
>  static const struct attribute_group *region_attr_groups[] = {
> - _region_attribute_group,
>   _mapping_attribute_group,
>   NULL,
>  };
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index b3213faf37b5..99e20b8b6ea0 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -2196,7 +2196,6 @@ static const struct attribute_group 
> acpi_nfit_region_attribute_group = {
>  };
>  
>  static const struct attribute_group *acpi_nfit_region_attribute_groups[] = {
> - _region_attribute_group,
>   _mapping_attribute_group,
>   _nfit_region_attribute_group,
>   NULL,
> diff --git a/drivers/nvdimm/e820.c b/drivers/nvdimm/e820.c
> index adde2864c6a4..9a971a59dec7 100644
> --- a/drivers/nvdimm/e820.c
> +++ b/drivers/nvdimm/e820.c
> @@ -13,11 +13,6 @@ static const struct attribute_group 
> *e820_pmem_attribute_groups[] = {
>   NULL,
>  };
>  
> -static const struct attribute_group *e820_pmem_region_attribute_groups[] = {
> - _region_attribute_group,
> - NULL,
> -};
> -
>  static int e820_pmem_remove(struct platform_device *pdev)
>  {
>   struct nvdimm_bus *nvdimm_bus = platform_get_drvdata(pdev);
> @@ -45,7 +40,6 @@ static int e820_register_one(struct resource *res, void 
> *data)
>  
>   memset(_desc, 0, sizeof(ndr_desc));
>   ndr_desc.res = res;
> - ndr_desc.attr_groups = e820_pmem_region_attribute_groups;
>   ndr_desc.numa_node = e820_range_to_nid(res->start);
>   ndr_desc.target_node = ndr_desc.numa_node;
>   set_bit(ND_REGION_PAGEMAP, _desc.flags);
> diff --git a/drivers/nvdimm/of_pmem.c b/drivers/nvdimm/of_pmem.c
> index 41348fa6b74c..c0b5ac36df9d 100644
> --- a/drivers/nvdimm/of_pmem.c
> +++ b/drivers/nvdimm/of_pmem.c
> @@ -9,11 +9,6 @@
>  #include 
>  #include 
>  
> -static const struct attribute_group *region_attr_groups[] = {
> - _region_attribute_group,
> - NULL,
> -};
> -
>  static const struct attribute_group *bus_attr_groups[] = {
>   _bus_attribute_group,
>   NULL,
> @@ -65,7 +60,6 @@ static int of_pmem_region_probe(struct platform_device 
> *pdev)
>* structures so passing a stack pointer is fine.
>*/
>   memset(_desc, 0, sizeof(ndr_desc));
> - ndr_desc.attr_groups = region_attr_groups;
>   ndr_desc.numa_node = dev_to_node(>dev);
>   ndr_desc.target_node = ndr_desc.numa_node;
>   ndr_desc.res = >resource[i];
> diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
> index e4281f806adc..f97166583294 100644
> --- a/drivers/nvdimm/region_devs.c
> +++ b/drivers/nvdimm/region_devs.c
> @@ -757,14 +757,14 @@ struct attribute_group nd_mapping_attribute_group = {
>  };
>  EXPORT_SYMBOL_GPL(nd_mapping_attribute_group);
>  
> -struct attribute_group nd_region_attribute_group = {
> +static const struct attribute_group nd_region_attribute_group = {
>   .attrs = nd_region_attributes,
>   .is_visible = region_visible,
>  };
> -EXPORT_SYMBOL_GPL(nd_region_attribute_group);
>  
>  static const struct attribute_group *nd_region_attribute_groups[] = {
>   _device_attribute_group,
> + _region_attribute_group,
>   _numa_attribute_group,
>   NULL,
>  };
> diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
> index e9a4e25fc708..312248d334c7 100644
> --- a/include/linux/libnvdimm.h
> +++ b/include/linux/libnvdimm.h
> @@ -67,7 +67,6 @@ enum {
>  
>  extern struct attribute_group nvdimm_bus_attribute_group;
>  extern struct attribute_group nvdimm_attribute_group;
> -extern struct attribute_group nd_region_attribute_group;
>  extern struct attribute_group nd_mapping_attribute_group;
>  
>  struct nvdimm;
___
Linux-nvdimm 

Re: [PATCH 00/16] Memory Hierarchy: Enable target node lookups for reserved memory

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> Yes, this patch series looks like a pile of boring libnvdimm cleanups,
> but buried at the end are some small gems that testing with libnvdimm
> uncovered. These gems will prove more valuable over time for Memory
> Hierarchy management as more platforms, via the ACPI HMAT and EFI
> Specific Purpose Memory, publish reserved or "soft-reserved" ranges to
> Linux. Linux system administrators will expect to be able to interact
> with those ranges with a unique numa node number when/if that memory is
> onlined via the dax_kmem driver [1].
>
> One configuration that currently fails to properly convey the target
> node for the resulting memory hotplug operation is persistent memory
> defined by the memmap=nn!ss parameter. For example, today if node1 is a
> memory only node, and all the memory from node1 is specified to
> memmap=nn!ss and subsequently onlined, it will end up being onlined as
> node0 memory. As it stands, memory_add_physaddr_to_nid() can only
> identify online nodes and since node1 in this example has no online cpus
> / memory the target node is initialized node0.
>
> The fix is to preserve rather than discard the numa_meminfo entries that
> are relevant for reserved memory ranges, and to uplevel the node
> distance helper for determining the "local" (closest) node relative to
> an initiator node.
>
> The first 12 patches are cleanups to make sure that all nvdimm devices
> and their children properly export a numa_node attribute. The switch to
> a device-type is less code and less error prone as a result.


Will this still allow leaf driver to have platform specific attribute
exposed via sysfs? Or do we want to still keep them in nvdimm core and
control the visibility via is_visible() callback?

-aneesh
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 03/16] libnvdimm: Move nd_device_attribute_group to device_type

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> A 'struct device_type' instance can carry default attributes for the
> device. Use this facility to remove the export of
> nd_device_attribute_group and put the responsibility on the core rather
> than leaf implementations to define this attribute.
>
> For regions this creates a new nd_region_attribute_groups[] added to the
> per-region device-type instances.
>

Reviewed-by: Aneesh Kumar K.V 

> Cc: Ira Weiny 
> Cc: Michael Ellerman 
> Cc: "Oliver O'Halloran" 
> Cc: Vishal Verma 
> Cc: Aneesh Kumar K.V 
> Signed-off-by: Dan Williams 
> ---
>  arch/powerpc/platforms/pseries/papr_scm.c |2 --
>  drivers/acpi/nfit/core.c  |2 --
>  drivers/nvdimm/bus.c  |3 +--
>  drivers/nvdimm/dimm_devs.c|8 +++-
>  drivers/nvdimm/e820.c |1 -
>  drivers/nvdimm/nd.h   |1 +
>  drivers/nvdimm/of_pmem.c  |1 -
>  drivers/nvdimm/region_devs.c  |   18 +-
>  include/linux/libnvdimm.h |1 -
>  9 files changed, 22 insertions(+), 15 deletions(-)
>
> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c 
> b/arch/powerpc/platforms/pseries/papr_scm.c
> index 61883291defc..04726f8fd189 100644
> --- a/arch/powerpc/platforms/pseries/papr_scm.c
> +++ b/arch/powerpc/platforms/pseries/papr_scm.c
> @@ -286,7 +286,6 @@ int papr_scm_ndctl(struct nvdimm_bus_descriptor *nd_desc, 
> struct nvdimm *nvdimm,
>  
>  static const struct attribute_group *region_attr_groups[] = {
>   _region_attribute_group,
> - _device_attribute_group,
>   _mapping_attribute_group,
>   _numa_attribute_group,
>   NULL,
> @@ -299,7 +298,6 @@ static const struct attribute_group *bus_attr_groups[] = {
>  
>  static const struct attribute_group *papr_scm_dimm_groups[] = {
>   _attribute_group,
> - _device_attribute_group,
>   NULL,
>  };
>  
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index 14e68f202f81..dec7c2b08672 100644
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -1699,7 +1699,6 @@ static const struct attribute_group 
> acpi_nfit_dimm_attribute_group = {
>  
>  static const struct attribute_group *acpi_nfit_dimm_attribute_groups[] = {
>   _attribute_group,
> - _device_attribute_group,
>   _nfit_dimm_attribute_group,
>   NULL,
>  };
> @@ -2199,7 +2198,6 @@ static const struct attribute_group 
> acpi_nfit_region_attribute_group = {
>  static const struct attribute_group *acpi_nfit_region_attribute_groups[] = {
>   _region_attribute_group,
>   _mapping_attribute_group,
> - _device_attribute_group,
>   _numa_attribute_group,
>   _nfit_region_attribute_group,
>   NULL,
> diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
> index d47412dcdf38..eb422527dd57 100644
> --- a/drivers/nvdimm/bus.c
> +++ b/drivers/nvdimm/bus.c
> @@ -669,10 +669,9 @@ static struct attribute *nd_device_attributes[] = {
>  /*
>   * nd_device_attribute_group - generic attributes for all devices on an nd 
> bus
>   */
> -struct attribute_group nd_device_attribute_group = {
> +const struct attribute_group nd_device_attribute_group = {
>   .attrs = nd_device_attributes,
>  };
> -EXPORT_SYMBOL_GPL(nd_device_attribute_group);
>  
>  static ssize_t numa_node_show(struct device *dev,
>   struct device_attribute *attr, char *buf)
> diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
> index 196aa44c4936..278867c68682 100644
> --- a/drivers/nvdimm/dimm_devs.c
> +++ b/drivers/nvdimm/dimm_devs.c
> @@ -202,9 +202,15 @@ static void nvdimm_release(struct device *dev)
>   kfree(nvdimm);
>  }
>  
> -static struct device_type nvdimm_device_type = {
> +static const struct attribute_group *nvdimm_attribute_groups[] = {
> + _device_attribute_group,
> + NULL,
> +};
> +
> +static const struct device_type nvdimm_device_type = {
>   .name = "nvdimm",
>   .release = nvdimm_release,
> + .groups = nvdimm_attribute_groups,
>  };
>  
>  bool is_nvdimm(struct device *dev)
> diff --git a/drivers/nvdimm/e820.c b/drivers/nvdimm/e820.c
> index 87f72f725e4f..adde2864c6a4 100644
> --- a/drivers/nvdimm/e820.c
> +++ b/drivers/nvdimm/e820.c
> @@ -15,7 +15,6 @@ static const struct attribute_group 
> *e820_pmem_attribute_groups[] = {
>  
>  static const struct attribute_group *e820_pmem_region_attribute_groups[] = {
>   _region_attribute_group,
> - _device_attribute_group,
>   NULL,
>  };
>  
> diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
> index 5c8b077b3237..3f509bb6b5c0 100644
> --- a/drivers/nvdimm/nd.h
> +++ b/drivers/nvdimm/nd.h
> @@ -298,6 +298,7 @@ struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn,
>   struct nd_namespace_common *ndns);
>  int nd_pfn_validate(struct nd_pfn *nd_pfn, const char *sig);
>  extern const struct attribute_group *nd_pfn_attribute_groups[];
> +extern const struct attribute_group 

Re: [PATCH 01/16] libnvdimm: Move attribute groups to device type

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> Statically initialize the attribute groups for each libnvdimm
> device_type. This is a preparation step for removing unnecessary exports
> of attributes that can be included in the device_type by default.
>
> Also take the opportunity to mark 'struct device_type' instances const.

Reviewed-by: Aneesh Kumar K.V 
>
> Cc: Ira Weiny 
> Cc: Vishal Verma 
> Signed-off-by: Dan Williams 
> ---
>  drivers/nvdimm/btt_devs.c   |   24 +++---
>  drivers/nvdimm/dax_devs.c   |   27 ++-
>  drivers/nvdimm/namespace_devs.c |   68 
> +--
>  drivers/nvdimm/nd.h |2 +
>  drivers/nvdimm/pfn_devs.c   |   28 
>  5 files changed, 73 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
> index 3508a79110c7..05feb97e11ce 100644
> --- a/drivers/nvdimm/btt_devs.c
> +++ b/drivers/nvdimm/btt_devs.c
> @@ -25,17 +25,6 @@ static void nd_btt_release(struct device *dev)
>   kfree(nd_btt);
>  }
>  
> -static struct device_type nd_btt_device_type = {
> - .name = "nd_btt",
> - .release = nd_btt_release,
> -};
> -
> -bool is_nd_btt(struct device *dev)
> -{
> - return dev->type == _btt_device_type;
> -}
> -EXPORT_SYMBOL(is_nd_btt);
> -
>  struct nd_btt *to_nd_btt(struct device *dev)
>  {
>   struct nd_btt *nd_btt = container_of(dev, struct nd_btt, dev);
> @@ -178,6 +167,18 @@ static const struct attribute_group 
> *nd_btt_attribute_groups[] = {
>   NULL,
>  };
>  
> +static const struct device_type nd_btt_device_type = {
> + .name = "nd_btt",
> + .release = nd_btt_release,
> + .groups = nd_btt_attribute_groups,
> +};
> +
> +bool is_nd_btt(struct device *dev)
> +{
> + return dev->type == _btt_device_type;
> +}
> +EXPORT_SYMBOL(is_nd_btt);
> +
>  static struct device *__nd_btt_create(struct nd_region *nd_region,
>   unsigned long lbasize, u8 *uuid,
>   struct nd_namespace_common *ndns)
> @@ -204,7 +205,6 @@ static struct device *__nd_btt_create(struct nd_region 
> *nd_region,
>   dev_set_name(dev, "btt%d.%d", nd_region->id, nd_btt->id);
>   dev->parent = _region->dev;
>   dev->type = _btt_device_type;
> - dev->groups = nd_btt_attribute_groups;
>   device_initialize(_btt->dev);
>   if (ndns && !__nd_attach_ndns(_btt->dev, ndns, _btt->ndns)) {
>   dev_dbg(>dev, "failed, already claimed by %s\n",
> diff --git a/drivers/nvdimm/dax_devs.c b/drivers/nvdimm/dax_devs.c
> index 6d22b0f83b3b..99965077bac4 100644
> --- a/drivers/nvdimm/dax_devs.c
> +++ b/drivers/nvdimm/dax_devs.c
> @@ -23,17 +23,6 @@ static void nd_dax_release(struct device *dev)
>   kfree(nd_dax);
>  }
>  
> -static struct device_type nd_dax_device_type = {
> - .name = "nd_dax",
> - .release = nd_dax_release,
> -};
> -
> -bool is_nd_dax(struct device *dev)
> -{
> - return dev ? dev->type == _dax_device_type : false;
> -}
> -EXPORT_SYMBOL(is_nd_dax);
> -
>  struct nd_dax *to_nd_dax(struct device *dev)
>  {
>   struct nd_dax *nd_dax = container_of(dev, struct nd_dax, nd_pfn.dev);
> @@ -43,13 +32,18 @@ struct nd_dax *to_nd_dax(struct device *dev)
>  }
>  EXPORT_SYMBOL(to_nd_dax);
>  
> -static const struct attribute_group *nd_dax_attribute_groups[] = {
> - _pfn_attribute_group,
> - _device_attribute_group,
> - _numa_attribute_group,
> - NULL,
> +static const struct device_type nd_dax_device_type = {
> + .name = "nd_dax",
> + .release = nd_dax_release,
> + .groups = nd_pfn_attribute_groups,
>  };
>  
> +bool is_nd_dax(struct device *dev)
> +{
> + return dev ? dev->type == _dax_device_type : false;
> +}
> +EXPORT_SYMBOL(is_nd_dax);
> +
>  static struct nd_dax *nd_dax_alloc(struct nd_region *nd_region)
>  {
>   struct nd_pfn *nd_pfn;
> @@ -69,7 +63,6 @@ static struct nd_dax *nd_dax_alloc(struct nd_region 
> *nd_region)
>  
>   dev = _pfn->dev;
>   dev_set_name(dev, "dax%d.%d", nd_region->id, nd_pfn->id);
> - dev->groups = nd_dax_attribute_groups;
>   dev->type = _dax_device_type;
>   dev->parent = _region->dev;
>  
> diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
> index cca0a3ba1d2c..37471a272c1a 100644
> --- a/drivers/nvdimm/namespace_devs.c
> +++ b/drivers/nvdimm/namespace_devs.c
> @@ -44,35 +44,9 @@ static void namespace_blk_release(struct device *dev)
>   kfree(nsblk);
>  }
>  
> -static const struct device_type namespace_io_device_type = {
> - .name = "nd_namespace_io",
> - .release = namespace_io_release,
> -};
> -
> -static const struct device_type namespace_pmem_device_type = {
> - .name = "nd_namespace_pmem",
> - .release = namespace_pmem_release,
> -};
> -
> -static const struct device_type namespace_blk_device_type = {
> - .name = "nd_namespace_blk",
> - .release = namespace_blk_release,
> -};
> -
> -static bool is_namespace_pmem(const struct device *dev)
> -{
> - return dev ? 

Re: [PATCH 02/16] libnvdimm: Move region attribute group definition

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> In preparation for moving region attributes from device attribute groups
> to the region device-type, reorder the declaration so that it can be
> referenced by the device-type definition without forward declarations.
> No functional changes are intended to result from this change.
>
Reviewed-by: Aneesh Kumar K.V 

> Cc: Ira Weiny 
> Cc: Vishal Verma 
> Signed-off-by: Dan Williams 
> ---
>  drivers/nvdimm/region_devs.c |  208 
> +-
>  1 file changed, 104 insertions(+), 104 deletions(-)
>
> diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
> index ef423ba1a711..e89f2eb3678c 100644
> --- a/drivers/nvdimm/region_devs.c
> +++ b/drivers/nvdimm/region_devs.c
> @@ -140,36 +140,6 @@ static void nd_region_release(struct device *dev)
>   kfree(nd_region);
>  }
>  
> -static struct device_type nd_blk_device_type = {
> - .name = "nd_blk",
> - .release = nd_region_release,
> -};
> -
> -static struct device_type nd_pmem_device_type = {
> - .name = "nd_pmem",
> - .release = nd_region_release,
> -};
> -
> -static struct device_type nd_volatile_device_type = {
> - .name = "nd_volatile",
> - .release = nd_region_release,
> -};
> -
> -bool is_nd_pmem(struct device *dev)
> -{
> - return dev ? dev->type == _pmem_device_type : false;
> -}
> -
> -bool is_nd_blk(struct device *dev)
> -{
> - return dev ? dev->type == _blk_device_type : false;
> -}
> -
> -bool is_nd_volatile(struct device *dev)
> -{
> - return dev ? dev->type == _volatile_device_type : false;
> -}
> -
>  struct nd_region *to_nd_region(struct device *dev)
>  {
>   struct nd_region *nd_region = container_of(dev, struct nd_region, dev);
> @@ -674,80 +644,6 @@ static umode_t region_visible(struct kobject *kobj, 
> struct attribute *a, int n)
>   return 0;
>  }
>  
> -struct attribute_group nd_region_attribute_group = {
> - .attrs = nd_region_attributes,
> - .is_visible = region_visible,
> -};
> -EXPORT_SYMBOL_GPL(nd_region_attribute_group);
> -
> -u64 nd_region_interleave_set_cookie(struct nd_region *nd_region,
> - struct nd_namespace_index *nsindex)
> -{
> - struct nd_interleave_set *nd_set = nd_region->nd_set;
> -
> - if (!nd_set)
> - return 0;
> -
> - if (nsindex && __le16_to_cpu(nsindex->major) == 1
> - && __le16_to_cpu(nsindex->minor) == 1)
> - return nd_set->cookie1;
> - return nd_set->cookie2;
> -}
> -
> -u64 nd_region_interleave_set_altcookie(struct nd_region *nd_region)
> -{
> - struct nd_interleave_set *nd_set = nd_region->nd_set;
> -
> - if (nd_set)
> - return nd_set->altcookie;
> - return 0;
> -}
> -
> -void nd_mapping_free_labels(struct nd_mapping *nd_mapping)
> -{
> - struct nd_label_ent *label_ent, *e;
> -
> - lockdep_assert_held(_mapping->lock);
> - list_for_each_entry_safe(label_ent, e, _mapping->labels, list) {
> - list_del(_ent->list);
> - kfree(label_ent);
> - }
> -}
> -
> -/*
> - * When a namespace is activated create new seeds for the next
> - * namespace, or namespace-personality to be configured.
> - */
> -void nd_region_advance_seeds(struct nd_region *nd_region, struct device *dev)
> -{
> - nvdimm_bus_lock(dev);
> - if (nd_region->ns_seed == dev) {
> - nd_region_create_ns_seed(nd_region);
> - } else if (is_nd_btt(dev)) {
> - struct nd_btt *nd_btt = to_nd_btt(dev);
> -
> - if (nd_region->btt_seed == dev)
> - nd_region_create_btt_seed(nd_region);
> - if (nd_region->ns_seed == _btt->ndns->dev)
> - nd_region_create_ns_seed(nd_region);
> - } else if (is_nd_pfn(dev)) {
> - struct nd_pfn *nd_pfn = to_nd_pfn(dev);
> -
> - if (nd_region->pfn_seed == dev)
> - nd_region_create_pfn_seed(nd_region);
> - if (nd_region->ns_seed == _pfn->ndns->dev)
> - nd_region_create_ns_seed(nd_region);
> - } else if (is_nd_dax(dev)) {
> - struct nd_dax *nd_dax = to_nd_dax(dev);
> -
> - if (nd_region->dax_seed == dev)
> - nd_region_create_dax_seed(nd_region);
> - if (nd_region->ns_seed == _dax->nd_pfn.ndns->dev)
> - nd_region_create_ns_seed(nd_region);
> - }
> - nvdimm_bus_unlock(dev);
> -}
> -
>  static ssize_t mappingN(struct device *dev, char *buf, int n)
>  {
>   struct nd_region *nd_region = to_nd_region(dev);
> @@ -861,6 +757,110 @@ struct attribute_group nd_mapping_attribute_group = {
>  };
>  EXPORT_SYMBOL_GPL(nd_mapping_attribute_group);
>  
> +struct attribute_group nd_region_attribute_group = {
> + .attrs = nd_region_attributes,
> + .is_visible = region_visible,
> +};
> +EXPORT_SYMBOL_GPL(nd_region_attribute_group);
> +
> +static struct device_type nd_blk_device_type = {
> + .name = "nd_blk",
> + 

Re: DAX filesystem support on ARMv8

2019-11-12 Thread Jan Kara
Hi!

On Tue 12-11-19 02:12:09, Bharat Kumar Gogada wrote:
> As per Documentation/filesystems/dax.txt
> 
> The DAX code does not work correctly on architectures which have virtually
> mapped caches such as ARM, MIPS and SPARC.
> 
> Can anyone please shed light on dax filesystem issue w.r.t ARM architecture ? 

I've CCed Dan, he might have idea what that comment means :)

Out of curiosity, why do you care?

Honza

-- 
Jan Kara 
SUSE Labs, CR
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: Inquiry (REVISED PROFORMA) - Urgent!!

2019-11-12 Thread Paul Clever
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org


Re: [PATCH 04/16] libnvdimm: Move nd_numa_attribute_group to device_type

2019-11-12 Thread Aneesh Kumar K.V
Dan Williams  writes:

> A 'struct device_type' instance can carry default attributes for the
> device. Use this facility to remove the export of
> nd_numa_attribute_group and put the responsibility on the core rather
> than leaf implementations to define this attribute.
>
> Cc: Ira Weiny 
> Cc: Michael Ellerman 
> Cc: "Oliver O'Halloran" 
> Cc: Vishal Verma 
> Cc: Aneesh Kumar K.V 
> Signed-off-by: Dan Williams 


can we also expose target_node in a similar way? This allows application
to better understand the node locality of the SCM device.

-aneesh
___
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org