DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: Sarosh Arif <sarosh.arif@emumba.com>,
	sthemmin@microsoft.com, dev@dpdk.org
Subject: Re: [dpdk-dev] [v4 PATCH] usertools: show valid hugepage sizes if user requests an invalid hugepage size
Date: Thu, 11 Feb 2021 15:16:02 -0800	[thread overview]
Message-ID: <20210211151602.78260c9a@hermes.local> (raw)
In-Reply-To: <7682463.TU6WbEMXMz@thomas>

On Thu, 11 Feb 2021 22:44:03 +0100
Thomas Monjalon <thomas@monjalon.net> wrote:

> 11/02/2021 09:20, Sarosh Arif:
> > If user requests a hugepage size which is not supported by the system,
> > currently user gets an error message saying that the requested size
> > is not a valid system huge page size. In addition to this if we display
> > the valid hugepage sizes it will be convenient for the user to request
> > the right size next time.
> > 
> > Signed-off-by: Sarosh Arif <sarosh.arif@emumba.com>
> > ---
> > --- a/usertools/dpdk-hugepages.py
> > +++ b/usertools/dpdk-hugepages.py
> > @@ -43,6 +43,12 @@ def is_numa():
> >      return os.path.exists('/sys/devices/system/node')
> >  
> >  
> > +def get_valid_page_sizes(path):
> > +    '''Extract valid hugepage sizes'''
> > +    dir = os.path.dirname(path)
> > +    pg_sizes = (d.split("-")[1] for d in os.listdir(dir))
> > +    return " ".join(pg_sizes)
> > +  
> 
> A second blank line is required here.
> 
> >  def get_hugepages(path):
> >      '''Read number of reserved pages'''
> >      with open(path + '/nr_hugepages') as nr_hugepages:
> > @@ -59,9 +65,8 @@ def set_hugepages(path, pages):
> >      except PermissionError:
> >          sys.exit('Permission denied: need to be root!')
> >      except FileNotFoundError:
> > -        filename = os.path.basename(path)
> > -        size = filename[10:]
> > -        sys.exit('{} is not a valid system huge page size'.format(size))
> > +        sys.exit("Invalid page size. Valid page sizes: {}".format(
> > +                get_valid_page_sizes(path)))  
> 
> Alignment needs a small fixup.
> 
> After these small changes, flake8 is OK.
> 
> Applied, thanks.

I used Yet-Another-Python-Formmatter originally (yapf).
Its preferred style for that would be:
diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py
index fb368b693399..28eba86641f7 100755
--- a/usertools/dpdk-hugepages.py
+++ b/usertools/dpdk-hugepages.py
@@ -67,7 +67,7 @@ def set_hugepages(path, pages):
         sys.exit('Permission denied: need to be root!')
     except FileNotFoundError:
         sys.exit("Invalid page size. Valid page sizes: {}".format(
-                 get_valid_page_sizes(path)))
+            get_valid_page_sizes(path)))
     if get_hugepages(path) != pages:
         sys.exit('Unable to reserve required pages.')
 

      reply	other threads:[~2021-02-11 23:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 12:47 [dpdk-dev] [PATCH] " Sarosh Arif
2020-11-30 16:46 ` Stephen Hemminger
2020-11-30 16:47 ` Stephen Hemminger
2020-12-02 11:06 ` [dpdk-dev] [v2 PATCH] " Sarosh Arif
2021-02-05 18:17   ` Thomas Monjalon
2021-02-08 22:12     ` Stephen Hemminger
2021-02-09 11:34   ` Burakov, Anatoly
2021-02-10  6:16   ` [dpdk-dev] [v3 " Sarosh Arif
2021-02-10 17:41     ` Burakov, Anatoly
2021-02-11  8:20     ` [dpdk-dev] [v4 " Sarosh Arif
2021-02-11 16:26       ` Stephen Hemminger
2021-02-11 21:44       ` Thomas Monjalon
2021-02-11 23:16         ` 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=20210211151602.78260c9a@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=sarosh.arif@emumba.com \
    --cc=sthemmin@microsoft.com \
    --cc=thomas@monjalon.net \
    /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).