DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Burakov, Anatoly" <anatoly.burakov@intel.com>
Cc: xiangxia.m.yue@gmail.com, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] eal/linux: add operation LOCK_NB to flock()
Date: Thu, 29 Jun 2023 20:47:45 -0700	[thread overview]
Message-ID: <20230629204745.0abfe19e@hermes.local> (raw)
In-Reply-To: <13b8ee99-39a7-c0a6-39fc-e126802d656d@intel.com>

On Thu, 15 Apr 2021 15:24:01 +0100
"Burakov, Anatoly" <anatoly.burakov@intel.com> wrote:

> On 25-Mar-21 8:21 AM, xiangxia.m.yue@gmail.com wrote:
> > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > 
> > The hugepage of different size, 2MB, 1GB may be mounted on
> > the same directory (e.g /dev/hugepages). Then dpdk
> > primary process will be blocked. To address this issue,
> > add the LOCK_NB flags to flock().
> > 
> > $ cat /proc/mounts
> > ...
> > none /dev/hugepages hugetlbfs rw,seclabel,relatime,pagesize=1024M 0 0
> > none /dev/hugepages hugetlbfs rw,seclabel,relatime,pagesize=2M 0 0
> > 
> > Add more details for err logs.
> > 
> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > ---
> >   lib/librte_eal/linux/eal_hugepage_info.c | 7 +++++--
> >   1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/lib/librte_eal/linux/eal_hugepage_info.c b/lib/librte_eal/linux/eal_hugepage_info.c
> > index d97792cadeb6..1ff76e539053 100644
> > --- a/lib/librte_eal/linux/eal_hugepage_info.c
> > +++ b/lib/librte_eal/linux/eal_hugepage_info.c
> > @@ -451,9 +451,12 @@ hugepage_info_init(void)
> >   		hpi->lock_descriptor = open(hpi->hugedir, O_RDONLY);
> >   
> >   		/* if blocking lock failed */
> > -		if (flock(hpi->lock_descriptor, LOCK_EX) == -1) {
> > +		if (flock(hpi->lock_descriptor, LOCK_EX | LOCK_NB) == -1) {
> >   			RTE_LOG(CRIT, EAL,
> > -				"Failed to lock hugepage directory!\n");
> > +				"Failed to lock hugepage directory! "
> > +				"The hugepage dir (%s) was locked by "
> > +				"other processes or self twice.\n",
> > +				hpi->hugedir);
> >   			break;
> >   		}
> >   		/* clear out the hugepages dir from unused pages */
> >   
> 
> Use cases such as "having two hugetlbfs page sizes on the same hugetlbfs 
> mountpoint" are user error, but i agree that deadlocking is probably not 
> the way we want to go about it.
> 
> An alternative way would be to check if we already have a mountpoint 
> with the same path, and this would produce a better error message (as a 
> user, "hugepage dir is locked by self twice" doesn't tell me anything 
> useful), at a cost of slightly more complicated code.
> 
> I'm not sure which way i want to go here. Normally, hugetlbfs shouldn't 
> be staying locked for long, so i'm wary of adding a LOCK_NB here, so i 
> feel slightly uneasy about this patch. Do you have any opinions?
> 
> Also, do other OS's EALs need similar fix?
> 

Dropping this patch. It is one of those:
"It hurts when I do this stupid thing" patches.

      reply	other threads:[~2023-06-30  3:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25  8:21 xiangxia.m.yue
2021-04-13  8:32 ` Tonghao Zhang
2021-04-15 14:24 ` Burakov, Anatoly
2023-06-30  3:47   ` Stephen Hemminger [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=20230629204745.0abfe19e@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=xiangxia.m.yue@gmail.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).