DPDK patches and discussions
 help / color / mirror / Atom feed
From: Long Li <longli@microsoft.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
	"longli@linuxonhyperv.com" <longli@linuxonhyperv.com>
Cc: Ferruh Yigit <ferruh.yigit@amd.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Wei Hu <weh@microsoft.com>, "dev@dpdk.org" <dev@dpdk.org>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: RE: [EXTERNAL] Re: [PATCH] net/mana: use mana_local_data for tracking usage data for primary process
Date: Sat, 8 Feb 2025 01:40:47 +0000	[thread overview]
Message-ID: <SA6PR21MB42319E6E18AC3411729727BACEF02@SA6PR21MB4231.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20250207162124.112f0c00@hermes.local>

> On Fri,  7 Feb 2025 15:21:45 -0800
> longli@linuxonhyperv.com wrote:
> 
> > +	/* At least one eth_dev is probed, init shared data */
> > +	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> > +		rte_spinlock_lock(&mana_shared_data_lock);
> > +		mana_local_data.primary_cnt++;
> > +		rte_spinlock_unlock(&mana_shared_data_lock);
> > +	} else {
> > +		rte_spinlock_lock(&mana_shared_data_lock);
> > +		mana_local_data.secondary_cnt++;
> > +		rte_spinlock_unlock(&mana_shared_data_lock);
> > +
> > +		rte_spinlock_lock(&mana_shared_data->lock);
> > +		mana_shared_data->secondary_cnt++;
> > +		rte_spinlock_unlock(&mana_shared_data->lock);
> 
> If all you are doing is wanting a MP safe counter, use atomic operations instead of
> the overhead of a spin lock.

mana_shared_data_lock is also used to protect init_done, mana_shared_mz and mana_shared_data.  That's why I'm reusing it for primary_cnt and secondary_cnt as those values are initialized in locked context at the beginning for the local process. I think this will make the code look clean. 

I can remove mana_shared_data->lock and use atomic for mana_shared_data->secondary_cnt.

Will send v2.

Thanks,

Long

      reply	other threads:[~2025-02-08  1:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-07 23:21 longli
2025-02-08  0:21 ` Stephen Hemminger
2025-02-08  1:40   ` Long Li [this message]

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=SA6PR21MB42319E6E18AC3411729727BACEF02@SA6PR21MB4231.namprd21.prod.outlook.com \
    --to=longli@microsoft.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=longli@linuxonhyperv.com \
    --cc=stable@dpdk.org \
    --cc=stephen@networkplumber.org \
    --cc=weh@microsoft.com \
    /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).