nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] libnvdimm, region_devs: stop NDD_ALIASING bit test if one test pass
@ 2018-08-19  4:01 Ocean He
  2018-08-30 21:51 ` Verma, Vishal L
  0 siblings, 1 reply; 3+ messages in thread
From: Ocean He @ 2018-08-19  4:01 UTC (permalink / raw)
  To: dan.j.williams, ross.zwisler, vishal.l.verma, dave.jiang
  Cc: Ocean He, linux-kernel, linux-nvdimm

From: Ocean He <hehy1@lenovo.com>

There is no need to finish entire loop to execute NDD_ALIASING bit test
against every nvdimm->flags. In practice, all the nd_mapping->nvdimm
have the same flags.

Because the check of alias is "if (alias)" but not 
"if (alias == nd_region->ndr_mappings)", there is no function change while
just save a few cycles.  

Signed-off-by: Ocean He <hehy1@lenovo.com>
---
A test to check if all the nd_mapping->nvdimm have the same flags, using 
Lenovo ThinkSystem SR630 and 4.18-rc6.

# ipmctl show -dimm

DimmID  Capacity        HealthState     ActionRequired  LockState       FWVersion
0x0021  125.7 GiB       Healthy         0               Disabled        01.00.00.4888
0x0121  125.7 GiB       Healthy         0               Disabled        01.00.00.4888
0x1021  125.7 GiB       Healthy         0               Disabled        01.00.00.4888
0x1121  125.7 GiB       Healthy         0               Disabled        01.00.00.4888

# ipmctl create -f -goal -socket 0x0 PersistentMemoryType=AppDirect

# ipmctl create -f -goal -socket 0x1 PersistentMemoryType=AppDirect

# reboot, to make goal configuration take effect.

# ndctl create-namespace -r region0 -s 100m -t pmem -m fsdax

# ndctl create-namespace -r region1 -s 100m -t pmem -m fsdax

# reboot and find all the nd_mapping->nvdimm have the same flags.

 drivers/nvdimm/region_devs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index ec3543b..fc3bc1c 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -234,8 +234,10 @@ int nd_region_to_nstype(struct nd_region *nd_region)
 			struct nd_mapping *nd_mapping = &nd_region->mapping[i];
 			struct nvdimm *nvdimm = nd_mapping->nvdimm;
 
-			if (test_bit(NDD_ALIASING, &nvdimm->flags))
+			if (test_bit(NDD_ALIASING, &nvdimm->flags)) {
 				alias++;
+				break;
+			}
 		}
 		if (alias)
 			return ND_DEVICE_NAMESPACE_PMEM;
-- 
1.8.3.1

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] libnvdimm, region_devs: stop NDD_ALIASING bit test if one test pass
  2018-08-19  4:01 [PATCH] libnvdimm, region_devs: stop NDD_ALIASING bit test if one test pass Ocean He
@ 2018-08-30 21:51 ` Verma, Vishal L
  2018-09-02 12:40   ` [External] " Ocean HY1 He
  0 siblings, 1 reply; 3+ messages in thread
From: Verma, Vishal L @ 2018-08-30 21:51 UTC (permalink / raw)
  To: Williams, Dan J, ross.zwisler, oceanhehy, Jiang, Dave
  Cc: hehy1, linux-kernel, linux-nvdimm


On Sun, 2018-08-19 at 00:01 -0400, Ocean He wrote:
> From: Ocean He <hehy1@lenovo.com>
> 
> There is no need to finish entire loop to execute NDD_ALIASING bit
> test
> against every nvdimm->flags. In practice, all the nd_mapping->nvdimm
> have the same flags.
> 
> Because the check of alias is "if (alias)" but not 
> "if (alias == nd_region->ndr_mappings)", there is no function change
> while
> just save a few cycles.  
> 
> Signed-off-by: Ocean He <hehy1@lenovo.com>
> ---
> A test to check if all the nd_mapping->nvdimm have the same flags,
> using 
> Lenovo ThinkSystem SR630 and 4.18-rc6.
> 
> # ipmctl show -dimm
> 
> DimmID  Capacity        HealthState     ActionRequired  LockState    
>    FWVersion
> 0x0021  125.7
> GiB       Healthy         0               Disabled        01.00.00.48
> 88
> 0x0121  125.7
> GiB       Healthy         0               Disabled        01.00.00.48
> 88
> 0x1021  125.7
> GiB       Healthy         0               Disabled        01.00.00.48
> 88
> 0x1121  125.7
> GiB       Healthy         0               Disabled        01.00.00.48
> 88
> 
> # ipmctl create -f -goal -socket 0x0 PersistentMemoryType=AppDirect
> 
> # ipmctl create -f -goal -socket 0x1 PersistentMemoryType=AppDirect
> 
> # reboot, to make goal configuration take effect.
> 
> # ndctl create-namespace -r region0 -s 100m -t pmem -m fsdax
> 
> # ndctl create-namespace -r region1 -s 100m -t pmem -m fsdax
> 
> # reboot and find all the nd_mapping->nvdimm have the same flags.
> 
>  drivers/nvdimm/region_devs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvdimm/region_devs.c
> b/drivers/nvdimm/region_devs.c
> index ec3543b..fc3bc1c 100644
> --- a/drivers/nvdimm/region_devs.c
> +++ b/drivers/nvdimm/region_devs.c
> @@ -234,8 +234,10 @@ int nd_region_to_nstype(struct nd_region
> *nd_region)
>  			struct nd_mapping *nd_mapping = &nd_region-
> >mapping[i];
>  			struct nvdimm *nvdimm = nd_mapping->nvdimm;
>  
> -			if (test_bit(NDD_ALIASING, &nvdimm->flags))
> +			if (test_bit(NDD_ALIASING, &nvdimm->flags))
> {
>  				alias++;
> +				break;

I think we can go a step further, and instead of the 'break' followed
by a check for the 'alias' variable, in the loop, just return
ND_DEVICE_NAMESPACE_PMEM if the NDD_ALIASING bit is found for any
mapping. Outside the loop, simply return ND_DEVICE_NAMESPACE_IO. That
makes it much cleaner and now we can get rid of 'alias' entirely.

> +			}
>  		}
>  		if (alias)
>  			return ND_DEVICE_NAMESPACE_PMEM;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [External]  Re: [PATCH] libnvdimm, region_devs: stop NDD_ALIASING bit test if one test pass
  2018-08-30 21:51 ` Verma, Vishal L
@ 2018-09-02 12:40   ` Ocean HY1 He
  0 siblings, 0 replies; 3+ messages in thread
From: Ocean HY1 He @ 2018-09-02 12:40 UTC (permalink / raw)
  To: Verma, Vishal L, Williams, Dan J, ross.zwisler, oceanhehy, Jiang, Dave
  Cc: linux-kernel, linux-nvdimm



> -----Original Message-----
> From: Verma, Vishal L <vishal.l.verma@intel.com>
> Sent: Friday, August 31, 2018 5:51 AM
> To: Williams, Dan J <dan.j.williams@intel.com>; ross.zwisler@linux.intel.com;
> oceanhehy@gmail.com; Jiang, Dave <dave.jiang@intel.com>
> Cc: linux-kernel@vger.kernel.org; linux-nvdimm@lists.01.org; Ocean HY1 He
> <hehy1@lenovo.com>
> Subject: [External] Re: [PATCH] libnvdimm, region_devs: stop NDD_ALIASING
> bit test if one test pass
> 
> 
> On Sun, 2018-08-19 at 00:01 -0400, Ocean He wrote:
> > From: Ocean He <hehy1@lenovo.com>
> >
> > There is no need to finish entire loop to execute NDD_ALIASING bit
> > test
> > against every nvdimm->flags. In practice, all the nd_mapping->nvdimm
> > have the same flags.
> >
> > Because the check of alias is "if (alias)" but not
> > "if (alias == nd_region->ndr_mappings)", there is no function change
> > while
> > just save a few cycles.
> >
> > Signed-off-by: Ocean He <hehy1@lenovo.com>
> > ---
> > A test to check if all the nd_mapping->nvdimm have the same flags,
> > using
> > Lenovo ThinkSystem SR630 and 4.18-rc6.
> >
> > # ipmctl show -dimm
> >
> > DimmID  Capacity        HealthState     ActionRequired  LockState
> >    FWVersion
> > 0x0021  125.7
> > GiB       Healthy         0               Disabled        01.00.00.48
> > 88
> > 0x0121  125.7
> > GiB       Healthy         0               Disabled        01.00.00.48
> > 88
> > 0x1021  125.7
> > GiB       Healthy         0               Disabled        01.00.00.48
> > 88
> > 0x1121  125.7
> > GiB       Healthy         0               Disabled        01.00.00.48
> > 88
> >
> > # ipmctl create -f -goal -socket 0x0 PersistentMemoryType=AppDirect
> >
> > # ipmctl create -f -goal -socket 0x1 PersistentMemoryType=AppDirect
> >
> > # reboot, to make goal configuration take effect.
> >
> > # ndctl create-namespace -r region0 -s 100m -t pmem -m fsdax
> >
> > # ndctl create-namespace -r region1 -s 100m -t pmem -m fsdax
> >
> > # reboot and find all the nd_mapping->nvdimm have the same flags.
> >
> >  drivers/nvdimm/region_devs.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/nvdimm/region_devs.c
> > b/drivers/nvdimm/region_devs.c
> > index ec3543b..fc3bc1c 100644
> > --- a/drivers/nvdimm/region_devs.c
> > +++ b/drivers/nvdimm/region_devs.c
> > @@ -234,8 +234,10 @@ int nd_region_to_nstype(struct nd_region
> > *nd_region)
> >  			struct nd_mapping *nd_mapping = &nd_region-
> > >mapping[i];
> >  			struct nvdimm *nvdimm = nd_mapping->nvdimm;
> >
> > -			if (test_bit(NDD_ALIASING, &nvdimm->flags))
> > +			if (test_bit(NDD_ALIASING, &nvdimm->flags))
> > {
> >  				alias++;
> > +				break;
> 
> I think we can go a step further, and instead of the 'break' followed
> by a check for the 'alias' variable, in the loop, just return
> ND_DEVICE_NAMESPACE_PMEM if the NDD_ALIASING bit is found for any
> mapping. Outside the loop, simply return ND_DEVICE_NAMESPACE_IO. That
> makes it much cleaner and now we can get rid of 'alias' entirely.
> 
Hi Vishal,

Thanks for comments and I would send version 2 patch later.

Ocean.
> > +			}
> >  		}
> >  		if (alias)
> >  			return ND_DEVICE_NAMESPACE_PMEM;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-02 12:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-19  4:01 [PATCH] libnvdimm, region_devs: stop NDD_ALIASING bit test if one test pass Ocean He
2018-08-30 21:51 ` Verma, Vishal L
2018-09-02 12:40   ` [External] " Ocean HY1 He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).