diff mbox

IB/hfi1: Using kfree_rcu() to simplify the code

Message ID 1470649818-30040-1-git-send-email-weiyj.lk@gmail.com (mailing list archive)
State Superseded
Headers show

Commit Message

Wei Yongjun Aug. 8, 2016, 9:50 a.m. UTC
The callback function of call_rcu() just calls a kfree(), so we
can use kfree_rcu() instead of call_rcu() + callback function.

Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
---
 drivers/infiniband/hw/hfi1/mad.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)




--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

kernel test robot Aug. 8, 2016, 3:15 p.m. UTC | #1
Hi Wei,

[auto build test ERROR on rdma/master]
[also build test ERROR on v4.8-rc1 next-20160805]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Wei-Yongjun/IB-hfi1-Using-kfree_rcu-to-simplify-the-code/20160808-175215
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma.git master
config: x86_64-randconfig-n0-08082041 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `postinit_cleanup':
>> init.c:(.text+0x589e7a): undefined reference to `cc_state_reclaim'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Aug. 8, 2016, 9:41 p.m. UTC | #2
Hi Wei,

[auto build test ERROR on rdma/master]
[also build test ERROR on v4.8-rc1 next-20160808]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Wei-Yongjun/IB-hfi1-Using-kfree_rcu-to-simplify-the-code/20160808-175215
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma.git master
config: x86_64-allmodconfig
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        make ARCH=x86_64  allmodconfig
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "cc_state_reclaim" [drivers/infiniband/hw/hfi1/hfi1.ko] undefined!

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marciniszyn, Mike Aug. 9, 2016, 4:20 p.m. UTC | #3
> -----Original Message-----
> From: Wei Yongjun [mailto:weiyj.lk@gmail.com]
> Sent: Monday, August 8, 2016 5:50 AM
> To: Marciniszyn, Mike <mike.marciniszyn@intel.com>; Dalessandro, Dennis
> <dennis.dalessandro@intel.com>; Doug Ledford <dledford@redhat.com>;
> Hefty, Sean <sean.hefty@intel.com>; Hal Rosenstock
> <hal.rosenstock@gmail.com>
> Cc: Wei Yongjun <weiyj.lk@gmail.com>; linux-rdma@vger.kernel.org
> Subject: [PATCH] IB/hfi1: Using kfree_rcu() to simplify the code
> 
> The callback function of call_rcu() just calls a kfree(), so we can use
> kfree_rcu() instead of call_rcu() + callback function.
> 
> Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
> ---
>  drivers/infiniband/hw/hfi1/mad.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/hfi1/mad.c
> b/drivers/infiniband/hw/hfi1/mad.c
> index 1263abe..95c43e1 100644
> --- a/drivers/infiniband/hw/hfi1/mad.c
> +++ b/drivers/infiniband/hw/hfi1/mad.c
> @@ -3398,7 +3398,7 @@ static void apply_cc_state(struct hfi1_pportdata
> *ppd)
> 
>  	spin_unlock(&ppd->cc_state_lock);
> 
> -	call_rcu(&old_cc_state->rcu, cc_state_reclaim);
> +	kfree_rcu(old_cc_state, rcu);
>  }
> 

This patch misses another call_rcu() that needs to be replaced in cleanup_device_data()
and that seems to be causing 0day issues.

Doug, have you put this anywhere to elicit the 0day issues?

Nacked-by: Mike Marciniszyn <mike.marciniszyn@intel.com> 


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky Aug. 9, 2016, 5:51 p.m. UTC | #4
On Tue, Aug 09, 2016 at 04:20:08PM +0000, Marciniszyn, Mike wrote:
> 
> 
> > -----Original Message-----
> > From: Wei Yongjun [mailto:weiyj.lk@gmail.com]
> > Sent: Monday, August 8, 2016 5:50 AM
> > To: Marciniszyn, Mike <mike.marciniszyn@intel.com>; Dalessandro, Dennis
> > <dennis.dalessandro@intel.com>; Doug Ledford <dledford@redhat.com>;
> > Hefty, Sean <sean.hefty@intel.com>; Hal Rosenstock
> > <hal.rosenstock@gmail.com>
> > Cc: Wei Yongjun <weiyj.lk@gmail.com>; linux-rdma@vger.kernel.org
> > Subject: [PATCH] IB/hfi1: Using kfree_rcu() to simplify the code
> > 
> > The callback function of call_rcu() just calls a kfree(), so we can use
> > kfree_rcu() instead of call_rcu() + callback function.
> > 
> > Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
> > ---
> >  drivers/infiniband/hw/hfi1/mad.c | 9 +--------
> >  1 file changed, 1 insertion(+), 8 deletions(-)
> > 
> > diff --git a/drivers/infiniband/hw/hfi1/mad.c
> > b/drivers/infiniband/hw/hfi1/mad.c
> > index 1263abe..95c43e1 100644
> > --- a/drivers/infiniband/hw/hfi1/mad.c
> > +++ b/drivers/infiniband/hw/hfi1/mad.c
> > @@ -3398,7 +3398,7 @@ static void apply_cc_state(struct hfi1_pportdata
> > *ppd)
> > 
> >  	spin_unlock(&ppd->cc_state_lock);
> > 
> > -	call_rcu(&old_cc_state->rcu, cc_state_reclaim);
> > +	kfree_rcu(old_cc_state, rcu);
> >  }
> > 
> 
> This patch misses another call_rcu() that needs to be replaced in cleanup_device_data()
> and that seems to be causing 0day issues.
> 
> Doug, have you put this anywhere to elicit the 0day issues?

0day bot runs on patches in mailing list too.

> 
> Nacked-by: Mike Marciniszyn <mike.marciniszyn@intel.com> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/hw/hfi1/mad.c b/drivers/infiniband/hw/hfi1/mad.c
index 1263abe..95c43e1 100644
--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -3398,7 +3398,7 @@  static void apply_cc_state(struct hfi1_pportdata *ppd)
 
 	spin_unlock(&ppd->cc_state_lock);
 
-	call_rcu(&old_cc_state->rcu, cc_state_reclaim);
+	kfree_rcu(old_cc_state, rcu);
 }
 
 static int __subn_set_opa_cong_setting(struct opa_smp *smp, u32 am, u8 *data,
@@ -3553,13 +3553,6 @@  static int __subn_get_opa_cc_table(struct opa_smp *smp, u32 am, u8 *data,
 	return reply((struct ib_mad_hdr *)smp);
 }
 
-void cc_state_reclaim(struct rcu_head *rcu)
-{
-	struct cc_state *cc_state = container_of(rcu, struct cc_state, rcu);
-
-	kfree(cc_state);
-}
-
 static int __subn_set_opa_cc_table(struct opa_smp *smp, u32 am, u8 *data,
 				   struct ib_device *ibdev, u8 port,
 				   u32 *resp_len)