[dpdk-dev] [RFC PATCH 0/7] support multi-phtread per lcore

Bruce Richardson bruce.richardson at intel.com
Tue Dec 23 10:23:08 CET 2014


On Tue, Dec 23, 2014 at 09:19:54AM +0000, Walukiewicz, Miroslaw wrote:
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen
> > Hemminger
> > Sent: Monday, December 22, 2014 7:29 PM
> > To: Richardson, Bruce
> > Cc: dev at dpdk.org
> > Subject: Re: [dpdk-dev] [RFC PATCH 0/7] support multi-phtread per lcore
> > 
> > On Mon, 22 Dec 2014 09:46:03 +0000
> > Bruce Richardson <bruce.richardson at intel.com> wrote:
> > 
> > > On Mon, Dec 22, 2014 at 01:51:27AM +0000, Liang, Cunming wrote:
> > > > ...
> > > > > I'm conflicted on this one. However, I think far more applications would
> > be
> > > > > broken
> > > > > to start having to use thread_id in place of an lcore_id than would be
> > broken
> > > > > by having the lcore_id no longer actually correspond to a core.
> > > > > I'm actually struggling to come up with a large number of scenarios
> > where it's
> > > > > important to an app to determine the cpu it's running on, compared to
> > the large
> > > > > number of cases where you need to have a data-structure per thread.
> > In DPDK
> > > > > libs
> > > > > alone, you see this assumption that lcore_id == thread_id a large
> > number of
> > > > > times.
> > > > >
> > > > > Despite the slight logical inconsistency, I think it's better to avoid
> > introducing
> > > > > a thread-id and continue having lcore_id representing a unique thread.
> > > > >
> > > > > /Bruce
> > > >
> > > > Ok, I understand it.
> > > > I list the implicit meaning if using lcore_id representing the unique thread.
> > > > 1). When lcore_id less than RTE_MAX_LCORE, it still represents the logical
> > core id.
> > > > 2). When lcore_id large equal than RTE_MAX_LCORE, it represents an
> > unique id for thread.
> > > > 3). Most of APIs(except rte_lcore_id()) in rte_lcore.h suggest to be used
> > only in CASE 1)
> > > > 4). rte_lcore_id() can be used in CASE 2), but the return value no matter
> > represent a logical core id.
> > > >
> > > > If most of us feel it's acceptable, I'll prepare for the RFC v2 base on this
> > conclusion.
> > > >
> > > > /Cunming
> > >
> > > Sorry, I don't like that suggestion either, as having lcore_id values greater
> > > than RTE_MAX_LCORE is terrible, as how will people know how to
> > dimension arrays
> > > to be indexes by lcore id? Given the choice, if we are not going to just use
> > > lcore_id as a generic thread id, which is always between 0 and
> > RTE_MAX_LCORE
> > > we can look to define a new thread_id variable to hold that. However, it
> > should
> > > have a bounded range.
> > > From an ease-of-porting perspective, I still think that the simplest option is
> > to
> > > use the existing lcore_id and accept the fact that it's now a thread id rather
> > > than an actual physical lcore. Question is, is would that cause us lots of
> > issues
> > > in the future?
> > >
> > > /Bruce
> > 
> > The current rte_lcore_id() has different meaning the thread. Your proposal
> > will
> > break code that uses lcore_id to do per-cpu statistics and the lcore_config
> > code in the samples.
> > q
> It depends on application context and how application treats rte_lcore_id() core. When number of the threads will not exceed the number of cores (let's say old-fashioned DPDK application) all stuff like per-cpu statistics will work correctly. 
> 
> When we treat threads on cores as ordinary threads as we introducing the special function rte_pthread_create() - the meaning of rte_lcore_id() changes to indicate 
>  thread number what is correct under new assumptions and new application model.
> 
> I do not  want to limit DPDK design  to only per-cpu application. There is much more application models that could be supported using DPDK. 
> Current per-cpu approach is only a subset of the possible applications.
> 
> Maybe we should indicate something like CONFIG_RTE_PTHREAD_ENABLE to change a meaning of rte_lcore_id() and introducing rte_pthread_create() family. 
> 
> Mirek
> 
>From the discussion it does look to me like we do need a separate thread id
value, separate from core id. Unfortunately that means that many(most?) places in libs
and examples where we use lcore_id right now, we probably need to use the new
thread id. :-(

/Bruce


More information about the dev mailing list