linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: obd_support: Add obd_cpt_alloc function
@ 2015-05-02 21:16 Julia Lawall
  2015-05-02 21:38 ` Drokin, Oleg
  2015-05-02 21:47 ` Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Julia Lawall @ 2015-05-02 21:16 UTC (permalink / raw)
  To: Oleg Drokin
  Cc: kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
	HPDD-discuss, devel, linux-kernel

Summarize OBD_CPT_ALLOC_GFP, OBD_CPT_ALLOC, and OBD_CPT_ALLOC_PTR as a
function, obd_cpt_alloc.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---

Some questions: Is the name OK?  Is the NULL test needed?  If not, should
the call to kzalloc_node with the call to cfs_cpt_spread_node just be
inlined into the call sites?

 drivers/staging/lustre/lustre/include/obd_support.h |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
index 2991d2e..3d380f0 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -655,6 +655,15 @@ do {									      \
 #define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt)				      \
 	OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof(*(ptr)))
 
+static inline void *obd_cpt_alloc(struct cfs_cpt_table *cptab, int cpt,
+				  size_t size, gfp_t flags)
+{
+	return (cptab) == NULL ?
+		kzalloc(size, flags) :
+		kzalloc_node(size, flags, cfs_cpt_spread_node(cptab, cpt));
+}
+
+
 # define __OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size)			      \
 do {									      \
 	(ptr) = cptab == NULL ?						      \


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

* Re: [PATCH] staging: lustre: obd_support: Add obd_cpt_alloc function
  2015-05-02 21:16 [PATCH] staging: lustre: obd_support: Add obd_cpt_alloc function Julia Lawall
@ 2015-05-02 21:38 ` Drokin, Oleg
  2015-05-03  5:53   ` Julia Lawall
  2015-05-02 21:47 ` Dan Carpenter
  1 sibling, 1 reply; 5+ messages in thread
From: Drokin, Oleg @ 2015-05-02 21:38 UTC (permalink / raw)
  To: Julia Lawall
  Cc: <kernel-janitors@vger.kernel.org>,
	Dilger, Andreas, Greg Kroah-Hartman,
	<HPDD-discuss@lists.01.org>,
	<devel@driverdev.osuosl.org>,
	<linux-kernel@vger.kernel.org>


On May 2, 2015, at 5:16 PM, Julia Lawall wrote:

> Summarize OBD_CPT_ALLOC_GFP, OBD_CPT_ALLOC, and OBD_CPT_ALLOC_PTR as a
> function, obd_cpt_alloc.
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
> 
> Some questions: Is the name OK?  Is the NULL test needed?  If not, should
> the call to kzalloc_node with the call to cfs_cpt_spread_node just be
> inlined into the call sites?

I think we don't need this function at all, we can use kzalloc/kzalloc_node directly with cfs_cpt_spread_node call in.

What we do need is obd_cpt_alloc_large similar to how we need obd_alloc_large (I know I still owe you a proper patch with that).
The only differences between the two would then be passing down of the cpt (and it's use) or not.

Bye,
    Oleg

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

* Re: [PATCH] staging: lustre: obd_support: Add obd_cpt_alloc function
  2015-05-02 21:16 [PATCH] staging: lustre: obd_support: Add obd_cpt_alloc function Julia Lawall
  2015-05-02 21:38 ` Drokin, Oleg
@ 2015-05-02 21:47 ` Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2015-05-02 21:47 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Oleg Drokin, devel, Andreas Dilger, Greg Kroah-Hartman,
	kernel-janitors, linux-kernel, HPDD-discuss

On Sat, May 02, 2015 at 11:16:48PM +0200, Julia Lawall wrote:

> Some questions: Is the name OK?  Is the NULL test needed?  If not, should
> the call to kzalloc_node with the call to cfs_cpt_spread_node just be
> inlined into the call sites?
> 
>  drivers/staging/lustre/lustre/include/obd_support.h |    9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
> index 2991d2e..3d380f0 100644
> --- a/drivers/staging/lustre/lustre/include/obd_support.h
> +++ b/drivers/staging/lustre/lustre/include/obd_support.h
> @@ -655,6 +655,15 @@ do {									      \
>  #define OBD_CPT_ALLOC_PTR(ptr, cptab, cpt)				      \
>  	OBD_CPT_ALLOC(ptr, cptab, cpt, sizeof(*(ptr)))
>  
> +static inline void *obd_cpt_alloc(struct cfs_cpt_table *cptab, int cpt,
> +				  size_t size, gfp_t flags)
> +{
> +	return (cptab) == NULL ?

These parens aren't needed any more.

I feel like people shouldn't deliberately call this with dptab == NULL.
I looked at it a bit and wasn't sure, (was sleepy though), so it's maybe
safest to keep the test.

I wish that cfs_cpt_spread_node() accepted NULL pointers so that we
didn't have to have the check for "cptab == NULL".  But your patch seems
like the way forward for now.

> +		kzalloc(size, flags) :
> +		kzalloc_node(size, flags, cfs_cpt_spread_node(cptab, cpt));
> +}
> +

regards,
dan carpenter

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

* Re: [PATCH] staging: lustre: obd_support: Add obd_cpt_alloc function
  2015-05-02 21:38 ` Drokin, Oleg
@ 2015-05-03  5:53   ` Julia Lawall
  2015-05-03 10:29     ` Drokin, Oleg
  0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2015-05-03  5:53 UTC (permalink / raw)
  To: Drokin, Oleg
  Cc: Julia Lawall, <kernel-janitors@vger.kernel.org>,
	Dilger, Andreas, Greg Kroah-Hartman,
	<HPDD-discuss@lists.01.org>,
	<devel@driverdev.osuosl.org>,
	<linux-kernel@vger.kernel.org>

On Sat, 2 May 2015, Drokin, Oleg wrote:

> 
> On May 2, 2015, at 5:16 PM, Julia Lawall wrote:
> 
> > Summarize OBD_CPT_ALLOC_GFP, OBD_CPT_ALLOC, and OBD_CPT_ALLOC_PTR as a
> > function, obd_cpt_alloc.
> > 
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> > 
> > ---
> > 
> > Some questions: Is the name OK?  Is the NULL test needed?  If not, should
> > the call to kzalloc_node with the call to cfs_cpt_spread_node just be
> > inlined into the call sites?
> 
> I think we don't need this function at all, we can use kzalloc/kzalloc_node directly with cfs_cpt_spread_node call in.

So everywhere the CPT macro is called, it is known that the value is not 
NULL?  I looked at some call sites, but it's not obvious to determine 
that.

> What we do need is obd_cpt_alloc_large similar to how we need 
> obd_alloc_large (I know I still owe you a proper patch with that). The 
> only differences between the two would then be passing down of the cpt 
> (and it's use) or not.

I saw that patch.  Thanks.

julia

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

* Re: [PATCH] staging: lustre: obd_support: Add obd_cpt_alloc function
  2015-05-03  5:53   ` Julia Lawall
@ 2015-05-03 10:29     ` Drokin, Oleg
  0 siblings, 0 replies; 5+ messages in thread
From: Drokin, Oleg @ 2015-05-03 10:29 UTC (permalink / raw)
  To: Julia Lawall
  Cc: <kernel-janitors@vger.kernel.org>,
	Dilger, Andreas, Greg Kroah-Hartman,
	<HPDD-discuss@lists.01.org>,
	<devel@driverdev.osuosl.org>,
	<linux-kernel@vger.kernel.org>


On May 3, 2015, at 1:53 AM, Julia Lawall wrote:

> On Sat, 2 May 2015, Drokin, Oleg wrote:
> 
>> 
>> On May 2, 2015, at 5:16 PM, Julia Lawall wrote:
>> 
>>> Summarize OBD_CPT_ALLOC_GFP, OBD_CPT_ALLOC, and OBD_CPT_ALLOC_PTR as a
>>> function, obd_cpt_alloc.
>>> 
>>> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>>> 
>>> ---
>>> 
>>> Some questions: Is the name OK?  Is the NULL test needed?  If not, should
>>> the call to kzalloc_node with the call to cfs_cpt_spread_node just be
>>> inlined into the call sites?
>> 
>> I think we don't need this function at all, we can use kzalloc/kzalloc_node directly with cfs_cpt_spread_node call in.
> 
> So everywhere the CPT macro is called, it is known that the value is not 
> NULL?  I looked at some call sites, but it's not obvious to determine 
> that.

It's not obvious, but I believe this is true now.

Basically in lustre/ptlrpc/service.c we use service->srv_cptable
and that comes from ptlrpc_register_service:
        cptable = cconf->cc_cptable;
        if (cptable == NULL)
                cptable = cfs_cpt_table;
….
        service->srv_cptable            = cptable;
        service->srv_cpts               = cpts;
        service->srv_ncpts              = ncpts;

that on the client it's only called from:
lustre/ldlm/ldlm_lockd.c::ldlm_setup() where we unconditionally assign
                .psc_cpt                = {
                        .cc_pattern             = ldlm_cpts,
                },
But even if there was a different caller, we always use cfs_cpt_table as fallback.

It's also directly used in ptlrpc_hr_init():
        ptlrpc_hr.hr_cpt_table = cfs_cpt_table;

Two callers in lustre/ptlrpc/nrs.c use the same stuff as above.

One caller in lustre/ptlrpc/nrs_fifo.c uses nrs_pol2cptab which is defined as
nrs_pol2svc(policy)->srv_cptable which is again same as above.

There are no other callers.

Bye,
    Oleg

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

end of thread, other threads:[~2015-05-03 10:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-02 21:16 [PATCH] staging: lustre: obd_support: Add obd_cpt_alloc function Julia Lawall
2015-05-02 21:38 ` Drokin, Oleg
2015-05-03  5:53   ` Julia Lawall
2015-05-03 10:29     ` Drokin, Oleg
2015-05-02 21:47 ` Dan Carpenter

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).