DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vladyslav Buslov <Vladyslav.Buslov@harmonicinc.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
	Ferruh Yigit <ferruh.yigit@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] kni: add support for core_id param in single threaded mode
Date: Thu, 22 Sep 2016 09:29:00 +0000	[thread overview]
Message-ID: <MWHPR11MB1360E450C464F800242859329DC90@MWHPR11MB1360.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20160921164444.6ea1030e@xeon-e3>

> On Wed, 21 Sep 2016 19:23:47 +0100
> Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> 
> > On 9/21/2016 6:15 PM, Vladyslav Buslov wrote:
> > >> On 9/20/2016 7:36 PM, Stephen Hemminger wrote:
> > >>> On Tue, 20 Sep 2016 21:16:37 +0300 Vladyslav Buslov
> > >>> <vladyslav.buslov@harmonicinc.com> wrote:
> > >>>
> > >>>> @@ -123,6 +125,9 @@ static int __net_init kni_init_net(struct net
> *net)
> > >>>>  	/* Clear the bit of device in use */
> > >>>>  	clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet-
> >device_in_use);
> > >>>>
> > >>>> +	mutex_init(&knet->kni_kthread_lock);
> > >>>> +	knet->kni_kthread = NULL;
> > >>>> +
> > >>>
> > >>> Why not just use kzalloc() here? You would still need to init the
> > >>> mutex etc, but it would be safer.
> > >>>
> > >>
> > >> Hi Vladyslav,
> > >>
> > >> This is good suggestion, if you send a new version for this update,
> > >> please keep my Ack.
> > >>
> > >> Thanks,
> > >> ferruh
> > >
> > > Hi Ferruh, Stephen,
> > >
> > > Could you please elaborate on using kzalloc for this code.
> > > Currently kni_thread_lock is value member of kni_net structure and
> never explicitly allocated or deallocated.
> > > Kni_kthread is pointer member of kni_net and is implicitly created and
> destroyed by kthread_run, kthread_stop functions.
> > > Which one of those do you suggest to allocate with kzalloc() and how
> would it improve safety?
> > >
> >
> > Currently:
> >
> > kni_init_net() {
> >     knet = kmalloc(..);
> >     ..
> >     mutex_init(..);
> >     knet->kni_thread = NULL;
> > }
> >
> > If you allocate knet via kzalloc(), no need to assign NULL to
> > kni_thread. Also this is safer because any uninitialized knet field
> > will be zero instead of random value.
> >
> > This is what I understood at least J
> 
> Also any additional fields in knet will be set, avoiding any present or future
> uninitialized memory bugs.
> 

What about net_generic which is used instead of kmalloc in KNI code for newer kernels?
Quick skim through Linux code indicates that it doesn't zero out memory and people memset it manually.
Just add memset(0) in HAVE_SIMPLIFIED_PERNET_OPERATIONS code?

  reply	other threads:[~2016-09-22  9:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 11:25 [dpdk-dev] [PATCH] " Vladyslav Buslov
2016-09-06 11:25 ` [dpdk-dev] [PATCH] kni: " Vladyslav Buslov
2016-09-06 14:14   ` Ferruh Yigit
2016-09-06 14:22     ` Ferruh Yigit
2016-09-06 14:30     ` Ferruh Yigit
2016-09-06 14:38       ` Vladyslav Buslov
2016-09-10 13:50   ` [dpdk-dev] [PATCH v2 1/2] " Vladyslav Buslov
2016-09-10 13:50     ` [dpdk-dev] [PATCH v2 2/2] " Vladyslav Buslov
2016-09-12 17:08       ` Ferruh Yigit
2016-09-13 10:57         ` Vladyslav Buslov
2016-09-20 18:16       ` [dpdk-dev] [PATCH] " Vladyslav Buslov
2016-09-20 18:36         ` Stephen Hemminger
2016-09-21 16:49           ` Ferruh Yigit
2016-09-21 17:15             ` Vladyslav Buslov
2016-09-21 18:23               ` Ferruh Yigit
2016-09-21 23:44                 ` Stephen Hemminger
2016-09-22  9:29                   ` Vladyslav Buslov [this message]
2016-09-22 15:47                     ` Ferruh Yigit
2016-09-21 14:38         ` Ferruh Yigit
2016-09-24 13:13         ` Vladyslav Buslov
2016-09-26 13:58           ` Ferruh Yigit
2016-10-13 20:24             ` Thomas Monjalon
  -- strict thread matches above, loose matches on Subject: below --
2016-08-25 14:46 [dpdk-dev] [PATCH] kni: add module parameter 'bind_to_core' Ferruh Yigit
2016-09-02 15:13 ` [dpdk-dev] [PATCH] kni: add support for core_id param in single threaded mode Vladyslav Buslov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MWHPR11MB1360E450C464F800242859329DC90@MWHPR11MB1360.namprd11.prod.outlook.com \
    --to=vladyslav.buslov@harmonicinc.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).