DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Sarosh Arif <sarosh.arif@emumba.com>
Cc: sthemmin@microsoft.com, dev@dpdk.org, stephen@networkplumber.org
Subject: Re: [dpdk-dev] [v2 PATCH] usertools: show valid hugepage sizes if user requests an invalid hugepage size
Date: Fri, 05 Feb 2021 19:17:52 +0100	[thread overview]
Message-ID: <2159847.9U2c7sIdO1@thomas> (raw)
In-Reply-To: <20201202110654.20923-1-sarosh.arif@emumba.com>

02/12/2020 12:06, 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>
> ---
> v2:
> pass string in sys.exit() to remove pylint warning

Stephen, is this version OK?

> +def get_valid_page_sizes(path):
> +    valid_page_sizes = ""
> +    hugepage_dir_path = os.path.split(path)[0]

Sorry for not following. Why this split?
Maybe add a comment?

> +    hugepage_dirs = os.listdir(hugepage_dir_path)
> +    for each_dir in hugepage_dirs:
> +        hugepage_size = each_dir.split("-")[1]
> +        valid_page_sizes = valid_page_sizes + " " + hugepage_size

Why not using += here?

> +    return valid_page_sizes
>  
>  def set_hugepages(path, pages):
>      '''Write the number of reserved huge pages'''
> @@ -59,10 +67,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)))




  reply	other threads:[~2021-02-05 18:17 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 [this message]
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

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=2159847.9U2c7sIdO1@thomas \
    --to=thomas@monjalon.net \
    --cc=dev@dpdk.org \
    --cc=sarosh.arif@emumba.com \
    --cc=stephen@networkplumber.org \
    --cc=sthemmin@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).